Skip to content

PDB writer ignores the elements topology attribute #2423

@jbarnoud

Description

@jbarnoud

Related to #2422 and #2421

Expected behavior

If the elements topology attribute is present in an AtomGroup, it is used to write the element field of the PDB file instead of the element being guessed.

Actual behavior

The elements topology attribute is ignored by the PDB writer.

Code to reproduce the behavior

import io
import MDAnalysis as mda
from MDAnalysis.tests.datafiles import PDB

u = mda.Universe(PDB)
u.add_TopologyAttr('elements', ['Zn'] * len(u.atoms))

output_io = io.StringIO()
output = mda.lib.util.NamedStream(output_io, 'plop.pdb')
u.atoms.write(output, file_format='PDB')
print(output_io.getvalue())

Columns 77 and 78 contains element symbols guessed from atom names instead of Zn as specified in the elements attribute.

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