Skip to content

Commit f71ecaa

Browse files
authored
Update inputs.py (#223)
1 parent 138fda6 commit f71ecaa

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

alphafold3_pytorch/inputs.py

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,29 +2400,37 @@ def load_msa_from_msa_dir(
24002400
msas[chain_id] = None
24012401
continue
24022402

2403-
# NOTE: A single chain-specific MSA file contains alignments for all polymer residues in the chain,
2404-
# but the chain's ligands are not included in the MSA file and therefore must be manually inserted
2405-
# into the MSAs as unknown amino acid residues.
2406-
assert len(msa_fpaths) == 1, (
2407-
f"{len(msa_fpaths)} MSA files found for chain {chain_id} of file {file_id}. "
2408-
"Please ensure that one MSA file is present for each chain."
2409-
)
2410-
msa_fpath = msa_fpaths[0]
2411-
msa_type = os.path.splitext(os.path.basename(msa_fpath))[0].split("_")[-1]
2412-
2413-
with open(msa_fpath, "r") as f:
2414-
msa = f.read()
2415-
msa = msa_parsing.parse_a3m(msa, msa_type)
2416-
msa = (
2417-
(
2418-
msa.random_truncate(max_msas_per_chain)
2419-
if randomly_truncate
2420-
else msa.truncate(max_msas_per_chain)
2421-
)
2422-
if exists(max_msas_per_chain)
2423-
else msa
2403+
try:
2404+
# NOTE: A single chain-specific MSA file contains alignments for all polymer residues in the chain,
2405+
# but the chain's ligands are not included in the MSA file and therefore must be manually inserted
2406+
# into the MSAs as unknown amino acid residues.
2407+
assert len(msa_fpaths) == 1, (
2408+
f"{len(msa_fpaths)} MSA files found for chain {chain_id} of file {file_id}. "
2409+
"Please ensure that one MSA file is present for each chain."
24242410
)
2425-
msas[chain_id] = msa
2411+
msa_fpath = msa_fpaths[0]
2412+
msa_type = os.path.splitext(os.path.basename(msa_fpath))[0].split("_")[-1]
2413+
2414+
with open(msa_fpath, "r") as f:
2415+
msa = f.read()
2416+
msa = msa_parsing.parse_a3m(msa, msa_type)
2417+
msa = (
2418+
(
2419+
msa.random_truncate(max_msas_per_chain)
2420+
if randomly_truncate
2421+
else msa.truncate(max_msas_per_chain)
2422+
)
2423+
if exists(max_msas_per_chain)
2424+
else msa
2425+
)
2426+
msas[chain_id] = msa
2427+
2428+
except Exception as e:
2429+
if verbose:
2430+
logger.warning(
2431+
f"Failed to load MSA for chain {chain_id} of file {file_id} due to: {e}. Skipping MSA loading."
2432+
)
2433+
msas[chain_id] = None
24262434

24272435
features = make_msa_features(msas, chain_id_to_residue)
24282436
features = make_msa_mask(features)

0 commit comments

Comments
 (0)