We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f93f355 + cc5f05e commit 25060e7Copy full SHA for 25060e7
ugropy/core/get_rdkit_object.py
@@ -34,9 +34,15 @@ def instantiate_mol_object(
34
chem_object = Chem.MolFromSmiles(smiles)
35
36
elif identifier_type.lower() == "name":
37
- pcp_object = pcp.get_compounds(identifier, identifier_type)[0]
38
- smiles = pcp_object.canonical_smiles
39
- chem_object = Chem.MolFromSmiles(smiles)
+ try:
+ pcp_object = pcp.get_compounds(identifier, identifier_type)[0]
+ smiles = pcp_object.canonical_smiles
40
+ chem_object = Chem.MolFromSmiles(smiles)
41
+ except IndexError:
42
+ raise ValueError(
43
+ f"Could not find a molecule with the name '{identifier}' on "
44
+ "PubChem"
45
+ )
46
47
elif identifier_type.lower() == "mol":
48
chem_object = identifier
0 commit comments