Skip to content

Commit ac8b5c3

Browse files
committed
Skip existing Chai-1 inputs
1 parent bdf0f94 commit ac8b5c3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

posebench/data/chai_input_preparation.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ def write_scripts(
6464
]
6565
output_dir = os.path.join(output_scripts_path, input_id)
6666
fasta_filepath = os.path.join(output_dir, f"{input_id}.fasta")
67+
if os.path.exists(fasta_filepath):
68+
logger.warning(
69+
f"FASTA file already exists for input ID {input_id}. Skipping writing to file..."
70+
)
71+
return
6772
for chain_index, sequence in enumerate(protein_sequence_list, start=1):
6873
with open(fasta_filepath, "a") as f:
6974
f.write(f">protein|{input_id}-chain-{chain_index}\n{sequence}\n")
@@ -100,11 +105,17 @@ def write_scripts(
100105
if len(seq) > 0
101106
]
102107
ligand_smiles_list = smiles_string.split("|")
108+
fasta_filepath = os.path.join(output_dir, f"{pdb_id}.fasta")
109+
if os.path.exists(fasta_filepath):
110+
logger.warning(
111+
f"FASTA file already exists for PDB ID {pdb_id}. Skipping writing to file..."
112+
)
113+
continue
103114
for chain_index, sequence in enumerate(protein_sequence_list, start=1):
104-
with open(os.path.join(output_dir, f"{pdb_id}.fasta"), "a") as f:
115+
with open(fasta_filepath, "a") as f:
105116
f.write(f">protein|{pdb_id}-chain-{chain_index}\n{sequence}\n")
106117
for chain_index, sequence in enumerate(ligand_smiles_list, start=1):
107-
with open(os.path.join(output_dir, f"{pdb_id}.fasta"), "a") as f:
118+
with open(fasta_filepath, "a") as f:
108119
f.write(f">ligand|{pdb_id}-chain-{chain_index}\n{sequence}\n")
109120

110121

0 commit comments

Comments
 (0)