Skip to content

XYZ parser guesses the elements #2420

@jbarnoud

Description

@jbarnoud

Expected behavior

The first column of a XYZ file is, by definition, the element symbol (or the element number in the UniChem variant. The element being provided by the file, AtomGroup.elements should be filled and that should be used to guess the mass.

Actual behavior

The first column is treated as atom type and atom name, but not as element symbol. The elements are guessed in order to latter guess the masses. The elements attribute is not filled.

Code to reproduce the behavior

import MDAnalysis as mda
from MDAnalysis.tests.datafiles import XYZ

u = mda.Universe(XYZ)
u.atoms.elements
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-22-1d38b5e1bdf4> in <module>
      3 
      4 u = mda.Universe(XYZ)
----> 5 u.atoms.elements

~/dev/mdanalysis/package/MDAnalysis/core/groups.py in __getattr__(self, attr)
   2291             except selection.SelectionError:
   2292                 pass
-> 2293         raise AttributeError("{cls} has no attribute {attr}".format(
   2294             cls=self.__class__.__name__, attr=attr))
   2295 

AttributeError: AtomGroup has no attribute elements

Currently version of MDAnalysis

  • Which version are you using? 0.20.2-dev0 4adbd6c
  • Which version of Python (python -V)? '3.8.0 | packaged by conda-forge | (default, Nov 22 2019, 19:11:38) \n[GCC 7.3.0]'
  • Which operating system? Ubuntu 18.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions