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

Standardizer gets stuck on a molecule #4

Closed
adlvdl opened this issue Dec 12, 2016 · 3 comments
Closed

Standardizer gets stuck on a molecule #4

adlvdl opened this issue Dec 12, 2016 · 3 comments
Assignees
Labels

Comments

@adlvdl
Copy link

adlvdl commented Dec 12, 2016

Hi, I have been trying your module to standardize molecules. However it gets stuck with molecule ZINC000100026244. By the stacktrace when I do a keyboard interruption, it seems to get stuck at the reionize step. Is there a way to set a timeout period so that if it gets stuck like this I can just disregard this molecule and continue?
I put below the bug example and the stacktrace:

from rdkit import Chem
import molvs
smi="CCOC(=O)C(=O)[CH-]C#N"
s = molvs.Standardizer()
mol=Chem.MolFromSmiles(smi)
mol = s.standardize(mol)


KeyboardInterrupt Traceback (most recent call last)
in ()
2 s = molvs.Standardizer()
3 mol=Chem.MolFromSmiles(smi)
----> 4 mol = s.standardize(mol)
5 print(Chem.MolToSmiles(mol, True))

C:\Software\Miniconda\lib\site-packages\molvs\standardize.py in standardize(self, mol)
97 mol = self.disconnect_metals(mol)
98 mol = self.normalize(mol)
---> 99 mol = self.reionize(mol)
100 Chem.AssignStereochemistry(mol, force=True, cleanIt=True)
101 # TODO: Check this removes symmetric stereocenters

C:\Software\Miniconda\lib\site-packages\molvs\charge.py in call(self, mol)
152 def call(self, mol):
153 """Calling a Reionizer instance like a function is the same as calling its reionize(mol) method."""
--> 154 return self.reionize(mol)
155
156 def reionize(self, mol):

C:\Software\Miniconda\lib\site-packages\molvs\charge.py in reionize(self, mol)
195
196 while True:
--> 197 ppos, poccur = self._strongest_protonated(mol)
198 ipos, ioccur = self._weakest_ionized(mol)
199 if ioccur and poccur and ppos < ipos:

C:\Software\Miniconda\lib\site-packages\molvs\charge.py in _strongest_protonated(self, mol)
211 def _strongest_protonated(self, mol):
212 for position, pair in enumerate(self.acid_base_pairs):
--> 213 for occurrence in mol.GetSubstructMatches(pair.acid):
214 return position, occurrence
215 return None, None

KeyboardInterrupt:

@mcs07 mcs07 self-assigned this Dec 12, 2016
@mcs07 mcs07 closed this as completed in bef8530 Dec 12, 2016
@mcs07 mcs07 removed the in progress label Dec 12, 2016
@mcs07
Copy link
Owner

mcs07 commented Dec 12, 2016

Thanks for the bug report.

This should now be fixed - there was a bug in the patterns that are used to decide whether the ionised atom should be changed, resulting in an infinite loop.

Run pip install -U molvs to update to the latest version.

@adlvdl
Copy link
Author

adlvdl commented Dec 13, 2016

Yes, with the update the example now completes. However a new molecule (ZINC000060321958) that previously finished now is giving problems. Like before I paste the example and traceback.

smi="C[N+]1=C[CH-]N(C(=N)N)/C1=C/N+[O-]"
s = molvs.Standardizer()
mol=Chem.MolFromSmiles(smi)
mol = s.standardize(mol)


StandardizeError Traceback (most recent call last)
in ()
2 s = molvs.Standardizer()
3 mol=Chem.MolFromSmiles(smi)
----> 4 mol = s.standardize(mol)
5 print(Chem.MolToSmiles(mol, True))

C:\Software\Miniconda\lib\site-packages\molvs\standardize.py in standardize(self, mol)
97 mol = self.disconnect_metals(mol)
98 mol = self.normalize(mol)
---> 99 mol = self.reionize(mol)
100 Chem.AssignStereochemistry(mol, force=True, cleanIt=True)
101 # TODO: Check this removes symmetric stereocenters

C:\Software\Miniconda\lib\site-packages\molvs\charge.py in call(self, mol)
153 def call(self, mol):
154 """Calling a Reionizer instance like a function is the same as calling its reionize(mol) method."""
--> 155 return self.reionize(mol)
156
157 def reionize(self, mol):

C:\Software\Miniconda\lib\site-packages\molvs\charge.py in reionize(self, mol)
200 if ioccur and poccur and ppos < ipos:
201 if poccur[-1] == ioccur[-1]:
--> 202 raise StandardizeError('Reionizer entered an infinite loop! Please report as a MolVS bug.')
203 log.info('Moved proton from %s to %s', self.acid_base_pairs[ppos].name, self.acid_base_pairs[ipos].name)
204 patom = mol.GetAtomWithIdx(poccur[-1])

StandardizeError: Reionizer entered an infinite loop! Please report as a MolVS bug.

mcs07 added a commit that referenced this issue Jan 24, 2017
@mcs07
Copy link
Owner

mcs07 commented Jan 27, 2017

Sorry for dropping this - I hope this is now fixed with v0.0.9.

Let me know if there are still any problems.

@mcs07 mcs07 added the bug label Feb 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants