Open haroldgrosjean opened 2 years ago
Hmm, that's interesting. Not sure how you put the system together, but I'm guessing that the elements of the not-ligand are adequately guessed from the atomic number field, and the ligand either has none or invalid numbers given:
>>> lig.atoms.elements
array(['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
''], dtype=object)
You could probably get around this by just guessing elements from the names:
>>> lig.atoms.elements = [re.sub("[0-9]+", "", name) for name in lig.atoms.names]
>>> lig.atoms.elements
array(['C', 'O', 'N', 'C', 'C', 'N', 'C', 'O', 'N', 'C', 'C', 'C', 'C',
'N', 'C', 'O', 'C', 'O', 'C', 'C', 'C', 'H', 'H', 'H', 'H', 'H',
'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'], dtype=object)
>>> lig_rdk = lig.convert_to("RDKIT")
>>> lig_rdk.GetNumAtoms()
35
That worked well for the few ligands I've tried so fare, thanks!
Do we need to consider maybe raising a user warning when elements aren't found? Other topology parsers do this but TPR doesn't?
They are found here, they're just not valid (''). Possibly from the gromacs atomtype atomic number, which might be set to 0. Notably, the protein elements are fine.
They are found here, they're just not valid (''). Possibly from the gromacs atomtype atomic number, which might be set to 0. Notably, the protein elements are fine.
not found == unrecognisable I really mean both cases here
Expected behavior
I would like to load a trajectory using gmx tpr and xtc files to later transform the ligand into an rdkit object.
Actual behavior
When I extract the ligand atom group and proceed with the transformation the following error is returned:
I have processed ligands in that fashion before and without problems so I am a little bit unsure how to resolve the situation. I thank you very much in advance for your assistance.
Code to reproduce the behavior
prod.tpr.txt
Current version of MDAnalysis