Skip to content

Commit 344735c

Browse files
Augustin-Zidekcopybara-github
authored andcommitted
Check that ccdCodes is a list
Provides a more user-friendly error message than what a user reported in #428. PiperOrigin-RevId: 767193009 Change-Id: Iaba288b1d22173886967c1339bb0b7d6c07becab
1 parent 06d28ca commit 344735c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/alphafold3/common/folding_input.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,17 @@ def from_dict(
783783
if json_dict.get('ccdCodes') and json_dict.get('smiles'):
784784
raise ValueError(
785785
'Ligand cannot have both CCD code and SMILES set at the same time, '
786-
f'got CCD: {json_dict["ccdCode"]} and SMILES: {json_dict["smiles"]}'
786+
f'got CCD: {json_dict["ccdCodes"]} and SMILES: {json_dict["smiles"]}'
787787
)
788788

789789
if 'ccdCodes' in json_dict:
790-
return cls(id=seq_id or json_dict['id'], ccd_ids=json_dict['ccdCodes'])
790+
ccd_codes = json_dict['ccdCodes']
791+
if not isinstance(ccd_codes, (list, tuple)):
792+
raise ValueError(
793+
'CCD codes must be a list of strings, got '
794+
f'{type(ccd_codes).__name__} instead: {ccd_codes}'
795+
)
796+
return cls(id=seq_id or json_dict['id'], ccd_ids=ccd_codes)
791797
elif 'smiles' in json_dict:
792798
return cls(id=seq_id or json_dict['id'], smiles=json_dict['smiles'])
793799
else:

0 commit comments

Comments
 (0)