MolVS 0.1.0 Standardization fails on Python 3
See original GitHub issueHi Matt, a bug report for something I’ve noticed in the latest release.
The standardize_smiles, Standardizer().tautomer_parent and Standardizer().standardize functions all fail because of line 133. These all work okay in 0.0.9
>>> mol = Chem.MolFromSmiles('[Na]OC(=O)c1ccc(C[S+2]([O-])([O-]))cc1')
>>> Standardizer().standardize(mol)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/travis/anaconda3/envs/rdkit/lib/python3.6/site-packages/molvs/standardize.py", line 98, in standardize
mol = self.normalize(mol)
File "/home/travis/anaconda3/envs/rdkit/lib/python3.6/site-packages/molvs/normalize.py", line 105, in __call__
return self.normalize(mol)
File "/home/travis/anaconda3/envs/rdkit/lib/python3.6/site-packages/molvs/normalize.py", line 124, in normalize
fragments.append(self._normalize_fragment(fragment))
File "/home/travis/anaconda3/envs/rdkit/lib/python3.6/site-packages/molvs/normalize.py", line 133, in _normalize_fragment
for n in six.moves.range(self.max_restarts):
NameError: name 'six' is not defined
I had a look at the file and it seems that the ‘import six’ line is missing. When this is added, I get another error, but I think this may be a Py2 vs Py3 difference:
>>> Standardizer().standardize(mol)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/travis/anaconda3/envs/rdkit/lib/python3.6/site-packages/molvs/standardize.py", line 98, in standardize
mol = self.normalize(mol)
File "/home/travis/anaconda3/envs/rdkit/lib/python3.6/site-packages/molvs/normalize.py", line 106, in __call__
return self.normalize(mol)
File "/home/travis/anaconda3/envs/rdkit/lib/python3.6/site-packages/molvs/normalize.py", line 125, in normalize
fragments.append(self._normalize_fragment(fragment))
File "/home/travis/anaconda3/envs/rdkit/lib/python3.6/site-packages/molvs/normalize.py", line 137, in _normalize_fragment
product = self._apply_transform(mol, normalization.transform)
File "/home/travis/anaconda3/envs/rdkit/lib/python3.6/site-packages/molvs/utils.py", line 28, in fget_memoized
setattr(self, attr_name, fget(self))
File "/home/travis/anaconda3/envs/rdkit/lib/python3.6/site-packages/molvs/normalize.py", line 42, in transform
return AllChem.ReactionFromSmarts(self.transform_str.encode('utf8'))
Boost.Python.ArgumentError: Python argument types in
rdkit.Chem.rdChemReactions.ReactionFromSmarts(bytes)
did not match C++ signature:
ReactionFromSmarts(char const* SMARTS, boost::python::dict replacements={}, bool useSmiles=False)
When I move “.encode(‘utf8’)” from line 42 it works as expected in Py3, but I think this would probably produce an error on Py2.
Hope this helps, thanks for working on this, it’s been really useful!
EDIT: I see that these changes are already reflected in the file on GitHub, it seems that the PyPI version is just a bit out of date
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
MolVS Documentation
MolVS Documentation, Release 0.1.1. MolVS is a molecule validation and standardization tool, written in Python using the RDKit.
Read more >MolVS - PyPI
MolVS is a molecule validation and standardization tool, written in Python using the RDKit chemistry framework. Building a collection of chemical structures ...
Read more >gypsum_dl/molvs/CHANGELOG.md · 1.1.0 · jdurrant ... - Projects
MolVS 0.1.0 Standardization fails on Python 3 #22; molvs hugs on some molecules #21 · v0.1.0 (2018-02-07). Full Changelog.
Read more >Compound sanitization different between Knime Node and ...
Hi everyone, I am trying to standardize my compounds with KNIME and RDKit. I am using a Python node and the MolVS library....
Read more >canSAR chemistry registration and standardization pipeline
Structures standardization according to MolVS [25] rules as implemented in RDKit Standardized Module (Cleanup function). 3. Generation of ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh dear, yes there’s definitely something wrong specifically with the wheel file on PyPI. I’ve removed it, so pip should use the source distribution instead, which looks fine to me.
Weird, the
import six
line definitely should already be there: https://github.com/mcs07/MolVS/blob/v0.1.0/molvs/normalize.py#L19Likewise I think the string encoding for py2/py3 was fixed while ago: https://github.com/mcs07/MolVS/commit/0e96acf9527c55a72b5ec6d385b6a779d9927b61#diff-36072b6ed94d3d5dd8829d1effae2cd5
How did you install MolVS? Is it possible you have an older version? What do you see if you do:
Might be worth trying to uninstall and install again.