Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
wukevin committed Feb 8, 2025
1 parent 165e0db commit 618854d
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions chai_lab/data/parsing/templates/m8.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,10 @@
logger = logging.getLogger(name=__name__)


def parse_m8_to_template_hits(
query_pdb_id: str,
query_sequence: str,
m8_path: Path,
template_cif_folder: Path | None = None,
) -> Iterator[TemplateHit]:
assert m8_path.is_file() and m8_path.stat().st_size > 0

if template_cif_folder is not None:
template_cif_folder.mkdir(parents=True, exist_ok=True)

table = pd.read_csv(
m8_path,
def parse_m8_file(fname: Path) -> pd.DataFrame:
"""Parse the m8 alignment format describing template information."""
return pd.read_csv(
fname,
delimiter="\t",
header=None,
names=[
Expand All @@ -51,6 +42,20 @@ def parse_m8_to_template_hits(
],
).sort_values(by=["query_id", "evalue"])


def parse_m8_to_template_hits(
query_pdb_id: str,
query_sequence: str,
m8_path: Path,
template_cif_folder: Path | None = None,
) -> Iterator[TemplateHit]:
assert m8_path.is_file() and m8_path.stat().st_size > 0

if template_cif_folder is not None:
template_cif_folder.mkdir(parents=True, exist_ok=True)

table = parse_m8_file(m8_path)

# Subset to those matching the query pdb id
table = table.loc[table.query_id.astype(str) == query_pdb_id]
if len(table) == 0:
Expand Down

0 comments on commit 618854d

Please sign in to comment.