-
Notifications
You must be signed in to change notification settings - Fork 825
Description
Hello,
I have to experience a rather odd behaviour from .convert_to("RDKIT") and I can't really make sense of it. Hopefully, someone will be able to help me here. I am trying to convert groups to rdkit objects which is done successfully most of the time. On some occasions, the following error appears:
File "/anaconda3/envs/mdcontacts/lib/python3.7/site-packages/MDAnalysis/core/groups.py", line 3188, in convert_to
return converter().convert(self.atoms)
File "/anaconda3/envs/mdcontacts/lib/python3.7/site-packages/MDAnalysis/coordinates/RDKit.py", line 333, in convert
xyz = ag.positions[idx].astype(float)
IndexError: index 18 is out of bounds for axis 0 with size 18
Annoyingly, the error appears not to be reproducible as different atom groups induce the error on different runs and/or iteration. For example, the code worked on the attached PDB (example.pdb) in the two first iterations but not on the third. When I repeat the code different atom groups can lead to failure while the one that precedently bugged is correctly processed.
PDB: example.pdb.txt
Any help resolving this issue would be greatly appreciated. Maybe @cbouy would be able to help?
Many thanks in advance for your help.
Expected behavior
import MDAnalysis as mda
pdb = 'example.pdb.txt'
ag = u.select_atoms('protein or resname LIG').convert_to("RDKIT")
lig = u.select_atoms('resname LIG').convert_to("RDKIT")
prot = u.select_atoms('protein').convert_to("RDKIT")
print(ag)
<rdkit.Chem.rdchem.Mol object at 0x7f92e7669850>
print(lig)
<rdkit.Chem.rdchem.Mol object at 0x7f92e76693f0>
print(prot)
<rdkit.Chem.rdchem.Mol object at 0x7f92e76696c0>
Actual behavior
import MDAnalysis as mda
pdb = 'example.pdb'
ag = u.select_atoms('protein or resname LIG').convert_to("RDKIT")
lig = u.select_atoms('resname LIG').convert_to("RDKIT")
Traceback (most recent call last):
[...]
lig = u.select_atoms('resname LIG').convert_to("RDKIT")
File "anaconda3/envs/mdcontacts/lib/python3.7/site-packages/MDAnalysis/core/groups.py", line 3188, in convert_to
return converter().convert(self.atoms)
File "/anaconda3/envs/mdcontacts/lib/python3.7/site-packages/MDAnalysis/coordinates/RDKit.py", line 333, in convert
xyz = ag.positions[idx].astype(float)
IndexError: index 18 is out of bounds for axis 0 with size 18
Code to reproduce the behavior
As explained above, the error seems unreproducible.
Current version of MDAnalysis
- Which version are you using? (run
python -c "import MDAnalysis as mda; print(mda.__version__)"): 2.0.0-dev0 - Which version of Python (
python -V)? Python 3.7.9 - Which operating system? macOS Catalina v10.15.7 AND Ubuntu 18.04.5 LTS