@@ -839,6 +839,7 @@ def get_method_predictions(
839839 cfg : DictConfig ,
840840 binding_site_method : Optional [str ] = None ,
841841 input_protein_filepath : Optional [str ] = None ,
842+ is_ss_method : bool = False ,
842843) -> List [Tuple [str , str ]]:
843844 """Get the predictions generated by the method.
844845
@@ -848,11 +849,13 @@ def get_method_predictions(
848849 :param binding_site_method: Optional name of the method used to predict AutoDock Vina's binding
849850 sites.
850851 :param input_protein_filepath: Optional path to the input protein structure PDB file.
852+ :param is_ss_method: Whether the method is a single-sequence method.
851853 :return: List of method predictions, each as a tuple of the output protein filepath and the
852854 output ligand filepath.
853855 """
854856 pocket_only_suffix = "_pocket_only" if cfg .pocket_only_baseline else ""
855857 no_ilcl_suffix = "_no_ilcl" if cfg .neuralplexer_no_ilcl else ""
858+ single_seq_suffix = "_ss" if is_ss_method else ""
856859
857860 if method == "diffdock" :
858861 ensemble_benchmarking_output_dir = (
@@ -981,7 +984,7 @@ def get_method_predictions(
981984 elif method == "neuralplexer" :
982985 ensemble_benchmarking_output_dir = (
983986 Path (cfg .input_dir if cfg .input_dir else cfg .neuralplexer_out_path ).parent
984- / f"neuralplexer{ pocket_only_suffix } { no_ilcl_suffix } _{ cfg .ensemble_benchmarking_dataset } _outputs_{ cfg .ensemble_benchmarking_repeat_index } "
987+ / f"neuralplexer{ single_seq_suffix } { pocket_only_suffix } { no_ilcl_suffix } _{ cfg .ensemble_benchmarking_dataset } _outputs_{ cfg .ensemble_benchmarking_repeat_index } "
985988 if cfg .ensemble_benchmarking
986989 else (cfg .input_dir if cfg .input_dir else cfg .neuralplexer_out_path )
987990 )
@@ -1078,7 +1081,7 @@ def get_method_predictions(
10781081 elif method == "chai-lab" :
10791082 ensemble_benchmarking_output_dir = (
10801083 Path (cfg .input_dir if cfg .input_dir else cfg .chai_out_path ).parent
1081- / f"chai-lab{ pocket_only_suffix } _{ cfg .ensemble_benchmarking_dataset } _outputs_{ cfg .ensemble_benchmarking_repeat_index } "
1084+ / f"chai-lab{ single_seq_suffix } { pocket_only_suffix } _{ cfg .ensemble_benchmarking_dataset } _outputs_{ cfg .ensemble_benchmarking_repeat_index } "
10821085 if cfg .ensemble_benchmarking
10831086 else (cfg .input_dir if cfg .input_dir else cfg .chai_out_path )
10841087 )
@@ -1112,7 +1115,7 @@ def get_method_predictions(
11121115 elif method == "alphafold3" :
11131116 ensemble_benchmarking_output_dir = (
11141117 Path (cfg .input_dir if cfg .input_dir else cfg .alphafold3_out_path ).parent
1115- / f"alphafold3{ pocket_only_suffix } _{ cfg .ensemble_benchmarking_dataset } _outputs_{ cfg .ensemble_benchmarking_repeat_index } "
1118+ / f"alphafold3{ single_seq_suffix } { pocket_only_suffix } _{ cfg .ensemble_benchmarking_dataset } _outputs_{ cfg .ensemble_benchmarking_repeat_index } "
11161119 if cfg .ensemble_benchmarking
11171120 else (cfg .input_dir if cfg .input_dir else cfg .alphafold3_out_path )
11181121 )
@@ -1340,7 +1343,7 @@ def generate_ensemble_predictions(
13401343
13411344 if cfg .resume :
13421345 ensemble_predictions_dict = {}
1343- for method in cfg .ensemble_methods :
1346+ for method , is_ss_method in zip ( cfg .ensemble_methods , cfg . is_ss_ensemble_method ) :
13441347 if method == "vina" :
13451348 for binding_site_method in cfg .vina_binding_site_methods :
13461349 method_predictions = get_method_predictions (
@@ -1349,11 +1352,16 @@ def generate_ensemble_predictions(
13491352 cfg ,
13501353 binding_site_method = binding_site_method ,
13511354 input_protein_filepath = protein_filepath ,
1355+ is_ss_method = is_ss_method ,
13521356 )
13531357 ensemble_predictions_dict [f"vina_{ binding_site_method } " ] = method_predictions
13541358 else :
13551359 method_predictions = get_method_predictions (
1356- method , input_id , cfg , input_protein_filepath = protein_filepath
1360+ method ,
1361+ input_id ,
1362+ cfg ,
1363+ input_protein_filepath = protein_filepath ,
1364+ is_ss_method = is_ss_method ,
13571365 )
13581366 ensemble_predictions_dict [method ] = method_predictions
13591367
@@ -1570,11 +1578,16 @@ def rank_ensemble_predictions(
15701578 and apo_reference_protein_filepath is not None
15711579 ):
15721580 try :
1573- align_complex_to_protein_only (
1581+ alignment_return_code = align_complex_to_protein_only (
15741582 protein_filepath , ligand_filepath , apo_reference_protein_filepath
15751583 )
1576- protein_filepath = protein_filepath .replace (".pdb" , "_aligned.pdb" )
1577- ligand_filepath = ligand_filepath .replace (".sdf" , "_aligned.sdf" )
1584+ if alignment_return_code == 0 :
1585+ protein_filepath = protein_filepath .replace (".pdb" , "_aligned.pdb" )
1586+ ligand_filepath = ligand_filepath .replace (".sdf" , "_aligned.sdf" )
1587+ else :
1588+ logger .warning (
1589+ f"Failed to align predicted complex structure { protein_filepath } and ligand structure { ligand_filepath } to the apo protein structure { apo_reference_protein_filepath } from method { method } . Skipping alignment..."
1590+ )
15781591 except Exception as e :
15791592 logger .warning (
15801593 f"Failed to align protein-ligand complex { protein_filepath } and { ligand_filepath } to apo protein structure { apo_reference_protein_filepath } . Skipping alignment due to: { e } "
@@ -2247,6 +2260,7 @@ def main(cfg: DictConfig):
22472260 with open_dict (cfg ):
22482261 # NOTE: besides their output directories, single-sequence baselines are treated like their multi-sequence counterparts
22492262 output_dir = copy .deepcopy (cfg .output_dir )
2263+ cfg .is_ss_ensemble_method = [s .endswith ("_ss" ) for s in cfg .ensemble_methods ]
22502264 cfg .ensemble_methods = [s .removesuffix ("_ss" ) for s in cfg .ensemble_methods ]
22512265 cfg .output_dir = output_dir
22522266
0 commit comments