From ac8b5c3715908cf0078c73b12079c12d9247e1a1 Mon Sep 17 00:00:00 2001 From: Alex Morehead Date: Wed, 25 Sep 2024 21:30:41 -0500 Subject: [PATCH] Skip existing Chai-1 inputs --- posebench/data/chai_input_preparation.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/posebench/data/chai_input_preparation.py b/posebench/data/chai_input_preparation.py index a923362..bcfe18e 100644 --- a/posebench/data/chai_input_preparation.py +++ b/posebench/data/chai_input_preparation.py @@ -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") @@ -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")