9.2.3. Topology attribute objects — MDAnalysis.core.topologyattrs

Common TopologyAttr instances that are used by most topology parsers.

TopologyAttrs are used to contain attributes such as atom names or resids. These are usually read by the TopologyParser.

class MDAnalysis.core.topologyattrs.AltLocs(values, guessed=False)[source]

AltLocs for each atom

class MDAnalysis.core.topologyattrs.Angles(values, types=None, guessed=False, order=None)[source]

Angles between three atoms

Initialise with a list of 3 long tuples E.g., [(0, 1, 2), (1, 2, 3), (2, 3, 4)]

These indices refer to the atom indices.

class MDAnalysis.core.topologyattrs.AtomAttr(values, guessed=False)[source]

Base class for atom attributes.

get_residues(rg)[source]

By default, the values for each atom present in the set of residues are returned in a single array. This behavior can be overriden in child attributes.

get_segments(sg)[source]

By default, the values for each atom present in the set of residues are returned in a single array. This behavior can be overriden in child attributes.

class MDAnalysis.core.topologyattrs.Atomids(values, guessed=False)[source]

ID for each atom.

class MDAnalysis.core.topologyattrs.Atomindices[source]

Globally unique indices for each atom in the group.

If the group is an AtomGroup, then this gives the index for each atom in the group. This is the unambiguous identifier for each atom in the topology, and it is not alterable.

If the group is a ResidueGroup or SegmentGroup, then this gives the indices of each atom represented in the group in a 1-D array, in the order of the elements in that group.

class MDAnalysis.core.topologyattrs.Atomnames(values, guessed=False)[source]

Name for each atom.

chi1_selection(residue)[source]

AtomGroup corresponding to the chi1 sidechain dihedral N-CA-CB-CG.

Returns:
  • AtomGroup – 4-atom selection in the correct order. If no CB and/or CG is found then this method returns None.
  • .. versionadded:: 0.7.5
omega_selection(residue)[source]

AtomGroup corresponding to the omega protein backbone dihedral CA-C-N’-CA’.

omega describes the -C-N- peptide bond. Typically, it is trans (180 degrees) although cis-bonds (0 degrees) are also occasionally observed (especially near Proline).

Returns:4-atom selection in the correct order. If no C’ found in the previous residue (by resid) then this method returns None.
Return type:AtomGroup
phi_selection(residue)[source]

AtomGroup corresponding to the phi protein backbone dihedral C’-N-CA-C.

Returns:4-atom selection in the correct order. If no C’ found in the previous residue (by resid) then this method returns None.
Return type:AtomGroup
psi_selection(residue)[source]

AtomGroup corresponding to the psi protein backbone dihedral N-CA-C-N’.

Returns:4-atom selection in the correct order. If no N’ found in the following residue (by resid) then this method returns None.
Return type:AtomGroup
class MDAnalysis.core.topologyattrs.Atomtypes(values, guessed=False)[source]

Type for each atom

class MDAnalysis.core.topologyattrs.Bfactors(values, guessed=False)[source]

Crystallographic B-factors in A**2 for each atom

class MDAnalysis.core.topologyattrs.Bonds(values, types=None, guessed=False, order=None)[source]

Bonds between two atoms

Must be initialised by a list of zero based tuples. These indices refer to the atom indices. E.g., ` [(0, 1), (1, 2), (2, 3)]`

Also adds the bonded_atoms, fragment and fragments attributes.

bonded_atoms()[source]

An AtomGroup of all atoms bonded to this Atom

fragment()[source]

The fragment that this Atom is part of

New in version 0.9.0.

fragments()[source]

Read-only list of fragments.

Contains all fragments that any Atom in this AtomGroup is part of, the contents of the fragments may extend beyond the contents of this AtomGroup.

class MDAnalysis.core.topologyattrs.ChainIDs(values, guessed=False)[source]

ChainID per atom

Note

This is an attribute of the Atom, not Residue or Segment

class MDAnalysis.core.topologyattrs.Dihedrals(values, types=None, guessed=False, order=None)[source]

A connection between four sequential atoms

class MDAnalysis.core.topologyattrs.Elements(values, guessed=False)[source]

Element for each atom

class MDAnalysis.core.topologyattrs.ICodes(values, guessed=False)[source]

Insertion code for Atoms

class MDAnalysis.core.topologyattrs.Impropers(values, types=None, guessed=False, order=None)[source]

An imaginary dihedral between four atoms

class MDAnalysis.core.topologyattrs.Radii(values, guessed=False)[source]

Radii for each atom

class MDAnalysis.core.topologyattrs.Resids(values, guessed=False)[source]

Residue ID

class MDAnalysis.core.topologyattrs.ResidueAttr(values, guessed=False)[source]

Base class for Topology attributes.

Note

This class is intended to be subclassed, and mostly amounts to a skeleton. The methods here should be present in all TopologyAttr child classes, but by default they raise appropriate exceptions.

get_segments(sg)[source]

By default, the values for each residue present in the set of segments are returned in a single array. This behavior can be overriden in child attributes.

class MDAnalysis.core.topologyattrs.Resindices[source]

Globally unique resindices for each residue in the group.

If the group is an AtomGroup, then this gives the resindex for each atom in the group. This unambiguously determines each atom’s residue membership. Resetting these values changes the residue membership of the atoms.

If the group is a ResidueGroup or SegmentGroup, then this gives the resindices of each residue represented in the group in a 1-D array, in the order of the elements in that group.

class MDAnalysis.core.topologyattrs.Segindices[source]

Globally unique segindices for each segment in the group.

If the group is an AtomGroup, then this gives the segindex for each atom in the group. This unambiguously determines each atom’s segment membership. It is not possible to set these, since membership in a segment is an attribute of each atom’s residue.

If the group is a ResidueGroup or SegmentGroup, then this gives the segindices of each segment represented in the group in a 1-D array, in the order of the elements in that group.

class MDAnalysis.core.topologyattrs.SegmentAttr(values, guessed=False)[source]

Base class for segment attributes.

class MDAnalysis.core.topologyattrs.Tempfactors(values, guessed=False)[source]

Tempfactor for atoms

class MDAnalysis.core.topologyattrs.TopologyAttr(values, guessed=False)[source]

Base class for Topology attributes.

Note

This class is intended to be subclassed, and mostly amounts to a skeleton. The methods here should be present in all TopologyAttr child classes, but by default they raise appropriate exceptions.

attrname

str – the name used for the attribute when attached to a Topology object

singular

str – name for the attribute on a singular object (Atom/Residue/Segment)

per_object

str – If there is a strict mapping between Component and Attribute

top

Topology – handle for the Topology object TopologyAttr is associated with

get_atoms(ag)[source]

Get atom attributes for a given AtomGroup

get_residues(rg)[source]

Get residue attributes for a given ResidueGroup

get_segments(sg)[source]

Get segment attributes for a given SegmentGroup

is_guessed

Bool of if the source of this information is a guess

set_atoms(ag, values)[source]

Set atom attributes for a given AtomGroup

set_residues(rg, values)[source]

Set residue attributes for a given ResidueGroup

set_segments(sg, values)[source]

Set segmentattributes for a given SegmentGroup