Skip to content

Commit

Permalink
Skip existing Chai-1 inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
amorehead committed Sep 26, 2024
1 parent bdf0f94 commit ac8b5c3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions posebench/data/chai_input_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def write_scripts(
]
output_dir = os.path.join(output_scripts_path, input_id)
fasta_filepath = os.path.join(output_dir, f"{input_id}.fasta")
if os.path.exists(fasta_filepath):
logger.warning(
f"FASTA file already exists for input ID {input_id}. Skipping writing to file..."
)
return
for chain_index, sequence in enumerate(protein_sequence_list, start=1):
with open(fasta_filepath, "a") as f:
f.write(f">protein|{input_id}-chain-{chain_index}\n{sequence}\n")
Expand Down Expand Up @@ -100,11 +105,17 @@ def write_scripts(
if len(seq) > 0
]
ligand_smiles_list = smiles_string.split("|")
fasta_filepath = os.path.join(output_dir, f"{pdb_id}.fasta")
if os.path.exists(fasta_filepath):
logger.warning(
f"FASTA file already exists for PDB ID {pdb_id}. Skipping writing to file..."
)
continue
for chain_index, sequence in enumerate(protein_sequence_list, start=1):
with open(os.path.join(output_dir, f"{pdb_id}.fasta"), "a") as f:
with open(fasta_filepath, "a") as f:
f.write(f">protein|{pdb_id}-chain-{chain_index}\n{sequence}\n")
for chain_index, sequence in enumerate(ligand_smiles_list, start=1):
with open(os.path.join(output_dir, f"{pdb_id}.fasta"), "a") as f:
with open(fasta_filepath, "a") as f:
f.write(f">ligand|{pdb_id}-chain-{chain_index}\n{sequence}\n")


Expand Down

0 comments on commit ac8b5c3

Please sign in to comment.