@@ -2113,15 +2113,16 @@ def pdb_input_to_molecule_input(
21132113 """Convert a PDBInput to a MoleculeInput."""
21142114 i = pdb_input
21152115
2116+ filepath = pdb_input .mmcif_filepath
2117+ file_id = os .path .splitext (os .path .basename (filepath ))[0 ]
2118+
21162119 # acquire a `Biomolecule` object for the given `PDBInput`
21172120
21182121 if not exists (biomol ) and exists (i .biomol ):
21192122 biomol = i .biomol
21202123 else :
21212124 # construct a `Biomolecule` object from the input PDB mmCIF file
21222125
2123- filepath = pdb_input .mmcif_filepath
2124- file_id = os .path .splitext (os .path .basename (filepath ))[0 ]
21252126 assert os .path .exists (filepath ), f"PDB input file `{ filepath } ` does not exist."
21262127
21272128 mmcif_object = mmcif_parsing .parse_mmcif_object (
@@ -2162,14 +2163,20 @@ def pdb_input_to_molecule_input(
21622163 assert exists (
21632164 i .cropping_config
21642165 ), "A cropping configuration must be provided during training."
2165- biomol = biomol .crop (
2166- contiguous_weight = i .cropping_config ["contiguous_weight" ],
2167- spatial_weight = i .cropping_config ["spatial_weight" ],
2168- spatial_interface_weight = i .cropping_config ["spatial_interface_weight" ],
2169- n_res = i .cropping_config ["n_res" ],
2170- chain_1 = i .chains [0 ],
2171- chain_2 = i .chains [1 ],
2172- )
2166+ try :
2167+ assert exists (i .chains ), "Chain IDs must be provided for cropping during training."
2168+ chain_id_1 , chain_id_2 = i .chains
2169+
2170+ biomol = biomol .crop (
2171+ contiguous_weight = i .cropping_config ["contiguous_weight" ],
2172+ spatial_weight = i .cropping_config ["spatial_weight" ],
2173+ spatial_interface_weight = i .cropping_config ["spatial_interface_weight" ],
2174+ n_res = i .cropping_config ["n_res" ],
2175+ chain_1 = chain_id_1 if chain_id_1 else None ,
2176+ chain_2 = chain_id_2 if chain_id_2 else None ,
2177+ )
2178+ except Exception as e :
2179+ raise ValueError (f"Failed to crop the biomolecule for input { file_id } due to: { e } " )
21732180
21742181 # retrieve features directly available within the `Biomolecule` object
21752182
0 commit comments