Skip to content

Commit

Permalink
Merge pull request #31 from ipqa-research/30-cant-resolve-trans-2-eic…
Browse files Browse the repository at this point in the history
…osene

Better not found on PubChem error
  • Loading branch information
SalvadorBrandolin authored Nov 24, 2024
2 parents f93f355 + cc5f05e commit 25060e7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ugropy/core/get_rdkit_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ def instantiate_mol_object(
chem_object = Chem.MolFromSmiles(smiles)

elif identifier_type.lower() == "name":
pcp_object = pcp.get_compounds(identifier, identifier_type)[0]
smiles = pcp_object.canonical_smiles
chem_object = Chem.MolFromSmiles(smiles)
try:
pcp_object = pcp.get_compounds(identifier, identifier_type)[0]
smiles = pcp_object.canonical_smiles
chem_object = Chem.MolFromSmiles(smiles)
except IndexError:
raise ValueError(
f"Could not find a molecule with the name '{identifier}' on "
"PubChem"
)

elif identifier_type.lower() == "mol":
chem_object = identifier
Expand Down

0 comments on commit 25060e7

Please sign in to comment.