Hierarchical Views

This module defines HierView class that builds a hierarchical views of atom groups.

class HierView(atoms, **kwargs)[source]

Hierarchical views can be generated for AtomGroup, Selection, and Chain instances. Indexing a HierView instance returns a Chain instance.

Some object methods are customized as follows:

  • len() returns the number of atoms, i.e. numChains()

  • iter() yields Chain instances

  • indexing by:
    • segment name (str()), e.g. "PROT", returns a Segment
    • chain identifier (str()), e.g. "A", returns a Chain
    • [segment name,] chain identifier, residue number[, insertion code] (tuple()), e.g. "A", 10 or "A", 10, "B" or "PROT", "A", 10, "B", returns a Residue

Note that when an AtomGroup instance have distinct segments, they will be considered when building the hierarchical view. A Segment instance will be generated for each distinct segment name. Then, for each segment chains and residues will be evaluated. Having segments in the structure will not change most behaviors of this class, except indexing. For example, when indexing a hierarchical view for chain P in segment PROT needs to be indexed as hv['PROT', 'P'].

getAtoms()

Returns atoms for which the hierarchical view was built.

getChain(chid, segname=None)

Returns chain with identifier chid, if it is present.

getResidue(chid, resnum, icode=None, segname=None)

Returns residue with number resnum and insertion code icode from the chain with identifier chid in segment with name segname.

getSegment(segname)

Returns segment with name segname, if it is present.

iterChains()

Yield chains.

iterResidues()

Yield residues.

iterSegments()

Yield segments.

numChains()

Returns number of chains.

numResidues()

Returns number of residues.

numSegments()

Returns number of chains.

update(**kwargs)

Update (or build) hierarchical view of atoms. This method is called at instantiation, but can be used to rebuild the hierarchical view when attributes of atoms change.