Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
MDAnalysis returns first letter of atom name as element #2313
This is an excerpt of my real PDB file for ATP:
I think these atoms should have atom type/elements H, C, O, H, C, O.
MDAnalysis thinks that all these atom types are 'A' with mass 0.0 (presumably because A is not an element).
Code to reproduce the behavior
Show us how to reproduce the failiure. If you can, use trajectory files from the test data.
import MDAnalysis as mda u = mda.Universe('my_pdb_file.pdb') print(u.atoms.types)
Currently version of MDAnalysis
This is because of this code here:
Which isn't the best guesser imaginable. I think especially because it should always verify that what it returns is an element...
I'm not too up-to-date on GitHub etiquette, so perhaps this comment would be better suited in the pull request, but --
I did put together a patchy version at guessing cases like the above in #2314 . I would have thought that elements would only be the symbols, but MDAnalysisTests has a special test requiring that guess_atom_element('1') returns '1'. I haven't looked through the code to see if this functionality is used anywhere -- would you know if any file formats require elements to be numbers?
Currently the pull request checks atom names composed of letters for elements up to Calcium and returns anything that is composed entirely of digits and symbols. I figured I could optimise it for one task or another if the specification was clearer -- for now I just wanted to read in ATP :-)