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 chains, 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()[source]

Returns atoms for which the hierarchical view was built.

getChain(chid, segname=None)[source]

Returns chain with identifier chid, if it is present.

getResidue(chid, resnum, icode=None, segname=None)[source]

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

getSegment(segname)[source]

Returns segment with name segname, if it is present.

iterChains()[source]

Yield chains.

iterResidues()[source]

Yield residues.

iterSegments()[source]

Yield segments.

numChains()[source]

Returns number of chains.

numResidues()[source]

Returns number of residues.

numSegments()[source]

Returns number of chains.

update(**kwargs)[source]

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.