Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resolve "trans-2-EICOSENE" #30

Closed
fedebenelli opened this issue Nov 24, 2024 · 2 comments · Fixed by #31
Closed

Can't resolve "trans-2-EICOSENE" #30

fedebenelli opened this issue Nov 24, 2024 · 2 comments · Fixed by #31
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@fedebenelli
Copy link
Member

print("trans-2-EICOSENE")
ug.get_groups(ug.joback, NAME)
IndexError                                Traceback (most recent call last)
Cell In[201], [line 5](vscode-notebook-cell:?execution_count=201&line=5)
      [1](vscode-notebook-cell:?execution_count=201&line=1) # df = pd.DataFrame({"id":names, **params})
      [2](vscode-notebook-cell:?execution_count=201&line=2) # df.to_csv("pures/only_dens/params.csv", index=False)
      [4](vscode-notebook-cell:?execution_count=201&line=4) print(NAME)
----> [5](vscode-notebook-cell:?execution_count=201&line=5) ug.get_groups(ug.joback, NAME)

File ~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:52, in get_groups(model, identifier, identifier_type)
     [32](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:32) """Obtain the FragmentationModel's subgroups of an RDkit Mol object.
     [33](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:33) 
     [34](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:34) Parameters
   (...)
     [49](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:49)     FragmentationModel's subgroups
     [50](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:50) """
     [51](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:51) # RDKit Mol object
---> [52](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:52) mol_object = instantiate_mol_object(identifier, identifier_type)
     [54](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:54) # =========================================================================
     [55](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:55) # Direct detection of groups presence and occurences
     [56](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:56) # =========================================================================
     [57](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:57) groups, groups_ocurrences = detect_groups(
     [58](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:58)     mol_object=mol_object, model=model
     [59](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_model_groups.py:59) )

File ~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_rdkit_object.py:37, in instantiate_mol_object(identifier, identifier_type)
...
---> [37](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_rdkit_object.py:37)     pcp_object = pcp.get_compounds(identifier, identifier_type)[0]
     [38](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_rdkit_object.py:38)     smiles = pcp_object.canonical_smiles
     [39](https://file+.vscode-resource.vscode-cdn.net/home/ruther/docs/research/thermo/algos/yaeos-fitting/~/docs/programming/python/virtualenvs/thermo/lib/python3.12/site-packages/ugropy/core/get_rdkit_object.py:39)     chem_object = Chem.MolFromSmiles(smiles)
@SalvadorBrandolin
Copy link
Member

The identifier "trans-2-EICOSENE" doesn't figure in PubChem. The IndexError is from pubchempy I have to give a better error message. Using 2-Eicosene works.

@SalvadorBrandolin SalvadorBrandolin self-assigned this Nov 24, 2024
@SalvadorBrandolin SalvadorBrandolin added enhancement New feature or request good first issue Good for newcomers labels Nov 24, 2024
@SalvadorBrandolin SalvadorBrandolin linked a pull request Nov 24, 2024 that will close this issue
@SalvadorBrandolin
Copy link
Member

Now on the dev branch, the error message is improved.

from ugropy import joback

joback.get_groups("trans-2-EICOSENE")
File ~/code/ugropy/ugropy/core/get_rdkit_object.py:42, in instantiate_mol_object(identifier, identifier_type)
     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         )
     47 elif identifier_type.lower() == "mol":
     48     chem_object = identifier

ValueError: Could not find a molecule with the name 'trans-2-EICOSENE' on PubChem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants