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

Better parsing of molecule inputs #40

Open
mattwthompson opened this issue Apr 24, 2020 · 0 comments
Open

Better parsing of molecule inputs #40

mattwthompson opened this issue Apr 24, 2020 · 0 comments

Comments

@mattwthompson
Copy link
Member

Arguably trivial but it would be nice to handle the wrong input separately from checking that toolkit(s) are installed. Here I accidentally pass in an OpenFF Molecule and confused myself since I knew I had the toolkits installed

In [1]: import cmiles

In [2]: from openforcefield.topology.molecule import Molecule
Warning: Unable to load toolkit 'AmberTools'.
_ColormakerRegistry()

In [3]: cmiles.utils.mol_to_smiles(Molecule.from_smiles('C'))
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-3-f0a9fb86fb26> in <module>
----> 1 cmiles.utils.mol_to_smiles(Molecule.from_smiles('C'))

~/software/cmiles/cmiles/utils.py in mol_to_smiles(molecule, **kwargs)
    165     """
    166     molecule = copy.deepcopy(molecule)
--> 167     toolkit = _set_toolkit(molecule)
    168     if has_atom_map(molecule):
    169         remove_atom_map(molecule)

~/software/cmiles/cmiles/utils.py in _set_toolkit(molecule)
    556         import cmiles._cmiles_rd as toolkit
    557     else:
--> 558         raise RuntimeError("Must have openeye or rdkit installed")
    559     return toolkit
    560

RuntimeError: Must have openeye or rdkit installed

In [4]: cmiles.utils.mol_to_smiles(Molecule.from_smiles('C').to_openeye())
Out[4]: '[H:2][C:1]([H:3])([H:4])[H:5]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant