Atom Group

This module defines AtomGroup class that stores atomic data and multiple coordinate sets in numpy.ndarray instances.

class AtomGroup(title='Unnamed')[source]

A class for storing and accessing atomic data. The number of atoms of the atom group is inferred at the first set method call from the size of the data array.

Atomic data

All atomic data is stored in numpy.ndarray instances.

Get and set methods

get methods, e.g. getResnames(), return copies of the data arrays.

set methods, e.g. setResnums(), accept data in list() or ndarray instances. The length of the list or array must match the number of atoms in the atom group. These methods set attributes of all atoms at once.

Coordinate sets

Atom groups with multiple coordinate sets may have one of these sets as the active coordinate set. The active coordinate set may be changed using setACSIndex() method. getCoords() returns coordinates from the active set.

Atom subsets

To access and modify data associated with a subset of atoms in an atom group, Selection instances may be used. A Selection has initially the same coordinate set as the active coordinate set, but it may be changed using Selection.setACSIndex() method.

Customizations

Following built-in functions are customized for this class:

Indexing AtomGroup instances by:
  • int (int()), e.g, 10, returns an Atom
  • slice (slice()), e.g, 10:20:2, returns a Selection
  • segment name (str()), e.g. 'PROT', returns a a Segment
  • chain identifier (str()), e.g. 'A', returns a 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

Addition

Addition of two AtomGroup instances, let’s say A and B, results in a new AtomGroup instance, say C. C stores an independent copy of the data of A and B. If A or B is missing a certain data type, zero values will be used for that part in C. If A and B has same number of coordinate sets, C will have a copy of all coordinate sets, otherwise C will have a single coordinate set, which is a copy of of active coordinate sets of A and B.

addCoordset(coords, label=None)[source]

Add a coordinate set. coords argument may be an object with getCoordsets() method.

copy()

Return a copy of atoms (and atomic data) in an AtomGroup instance.

delCoordset(index)[source]

Delete a coordinate set from the atom group.

delData(label)[source]

Return data associated with label and remove from the instance. If data associated with label is not found, return None.

delFlags(label)[source]

Return flags associated with label and remove from the instance. If flags associated with label is not found, return None.

getACSIndex()[source]

Return index of the coordinate set.

getACSLabel()[source]

Return active coordinate set label.

getAltlocs()

Return a copy of alternate location indicators. Alternate location indicators can be used in atom selections, e.g. 'altloc A B', 'altloc _'.

getAnisous()

Return a copy of anisotropic temperature factors.

getAnistds()

Return a copy of standard deviations for anisotropic temperature factors.

getBetas()

Return a copy of β-values (or temperature factors). β-values can be used in atom selections, e.g. 'beta 555.55', 'beta 0 to 500', 'beta 0:500', 'beta < 500'.

getBySerial(serial, stop=None, step=None)[source]

Get an atom(s) by serial number (range). serial must be zero or a positive integer. stop may be None, or an integer greater than serial. getBySerial(i, j) will return atoms whose serial numbers are i+1, i+2, ..., j-1. Atom whose serial number is stop will be excluded as it would be in indexing a Python list. step (default is 1) specifies increment. If atoms with matching serial numbers are not found, None will be returned.

getCSLabels()[source]

Return coordinate set labels.

getCharges()

Return a copy of partial charges. Partial charges can be used in atom selections, e.g. 'charge 1', 'abs(charge) == 1', 'charge < 0'.

getChids()

Return a copy of chain identifiers. Chain identifiers can be used in atom selections, e.g. 'chain A', 'chid A B C', 'chain _'. Note that chid is a synonym for chain.

getChindices()

Return a copy of chain indices. Chain indices are assigned to subsets of atoms with distinct pairs of chain identifier and segment name. Chain indices start from zero, are incremented by one, and are assigned in the order of appearance in AtomGroup instance. Chain indices can be used in atom selections, e.g. 'chindex 0'.

getCoords()[source]

Return a copy of coordinates from active coordinate set.

getCoordsets(indices=None)[source]

Return a copy of coordinate set(s) at given indices. indices may be an integer, a list of integers, or None meaning all coordinate sets.

getData(label)[source]

Return a copy of the data array associated with label, or None if such data is not present.

getDataLabels(which=None)[source]

Return data labels. For which='user', return only labels of user provided data.

getDataType(label)[source]

Return type of the data (i.e. data.dtype) associated with label, or None label is not used.

getElements()

Return a copy of element symbols. Element symbols can be used in atom selections, e.g. 'element C O N'.

getFlagLabels(which=None)[source]

Return flag labels. For which='user', return labels of user or parser (e.g. hetatm) provided flags, for which='all' return all possible Atom Flags labels in addition to those present in the instance.

getFlags(label)[source]

Return a copy of atom flags for given label, or None when flags for label is not set.

getFragindices()

Return a copy of fragment indices. Fragment indices are assigned to connected subsets of atoms. Bonds needs to be set using AtomGroup.setBonds() method. Fragment indices start from zero, are incremented by one, and are assigned in the order of appearance in AtomGroup instance. Fragment indices can be used in atom selections, e.g. 'fragindex 0', 'fragment 1'. Note that fragment is a synonym for fragindex.

getHierView(**kwargs)[source]

Return a hierarchical view of the atom group.

getIcodes()

Return a copy of insertion codes. Insertion codes can be used in atom selections, e.g. 'icode A', 'icode _'.

getMasses()

Return a copy of masses. Masses can be used in atom selections, e.g. '12 <= mass <= 13.5'.

getNames()

Return a copy of names. Names can be used in atom selections, e.g. 'name CA CB'.

getOccupancies()

Return a copy of occupancy values. Occupancy values can be used in atom selections, e.g. 'occupancy 1', 'occupancy > 0'.

getRadii()

Return a copy of radii. Radii can be used in atom selections, e.g. 'radii < 1.5', 'radii ** 2 < 2.3'.

getResindices()

Return a copy of residue indices. Residue indices are assigned to subsets of atoms with distinct sequences of residue number, insertion code, chain identifier, and segment name. Residue indices start from zero, are incremented by one, and are assigned in the order of appearance in AtomGroup instance. Residue indices can be used in atom selections, e.g. 'resindex 0'.

getResnames()

Return a copy of residue names. Residue names can be used in atom selections, e.g. 'resname ALA GLY'.

getResnums()

Return a copy of residue numbers. Residue numbers can be used in atom selections, e.g. 'resnum 1 2 3', 'resnum 120A 120B', 'resnum 10 to 20', 'resnum 10:20:2', 'resnum < 10'. Note that resid is a synonym for resnum.

getSecstrs()

Return a copy of secondary structure assignments. Secondary structure assignments can be used in atom selections, e.g. 'secondary H E', 'secstr H E'. Note that secstr is a synonym for secondary.

getSegindices()

Return a copy of segment indices. Segment indices are assigned to subsets of atoms with distinct segment names. Segment indices start from zero, are incremented by one, and are assigned in the order of appearance in AtomGroup instance. Segment indices can be used in atom selections, e.g. 'segindex 0'.

getSegnames()

Return a copy of segment names. Segment names can be used in atom selections, e.g. 'segment PROT', 'segname PROT'. Note that segname is a synonym for segment.

getSerials()

Return a copy of serial numbers (from file). Serial numbers can be used in atom selections, e.g. 'serial 1 2 3', 'serial 1 to 10', 'serial 1:10:2', 'serial < 10'.

getTitle()[source]

Return title of the instance.

getTypes()

Return a copy of types. Types can be used in atom selections, e.g. 'type CT1 CT2 CT3'.

isDataLabel(label)[source]

Return True if data associated with label is present.

isFlagLabel(label)[source]

Return True if flags associated with label are present.

iterAtoms()

Yield atom instances.

iterBonds()[source]

Yield bonds. Use setBonds() for setting bonds.

iterChains()[source]

Iterate over chains.

iterCoordsets()[source]

Iterate over coordinate sets by returning a copy of each coordinate set.

iterFragments()[source]

Yield connected atom subsets as Selection instances.

iterResidues()[source]

Iterate over residues.

iterSegments()[source]

Iterate over chains.

numAtoms(flag=None)[source]

Return number of atoms, or number of atoms with given flag.

numBonds()[source]

Return number of bonds. Use setBonds() for setting bonds.

numBytes(all=False)[source]

Return number of bytes used by atomic data arrays, such as coordinate, flag, and attribute arrays. If all is True, internal arrays for indexing hierarchical views, bonds, and fragments will also be included. Note that memory usage of Python objects is not taken into account and that this may change in the future.

numChains()[source]

Return number of chains.

numCoordsets()[source]

Return number of coordinate sets.

numFragments()[source]

Return number of connected atom subsets.

numResidues()[source]

Return number of residues.

numSegments()[source]

Return number of segments.

select(selstr, **kwargs)

Return atoms matching selstr criteria. See select module documentation for details and usage examples.

setACSIndex(index)[source]

Set the coordinate set at index active.

setACSLabel(label)[source]

Set active coordinate set label.

setAltlocs(data)

Set alternate location indicators. Alternate location indicators can be used in atom selections, e.g. 'altloc A B', 'altloc _'.

setAnisous(data)

Set anisotropic temperature factors.

setAnistds(data)

Set standard deviations for anisotropic temperature factors.

setBetas(data)

Set β-values (or temperature factors). β-values can be used in atom selections, e.g. 'beta 555.55', 'beta 0 to 500', 'beta 0:500', 'beta < 500'.

setBonds(bonds)[source]

Set covalent bonds between atoms. bonds must be a list or an array of pairs of indices. All bonds must be set at once. Bonding information can be used to make atom selections, e.g. "bonded to index 1". See select module documentation for details. Also, a data array with number of bonds will be generated and stored with label numbonds. This can be used in atom selections, e.g. 'numbonds 0' can be used to select ions in a system.

setCSLabels(labels)[source]

Set coordinate set labels. labels must be a list of strings.

setCharges(data)

Set partial charges. Partial charges can be used in atom selections, e.g. 'charge 1', 'abs(charge) == 1', 'charge < 0'.

setChids(data)

Set chain identifiers. Chain identifiers can be used in atom selections, e.g. 'chain A', 'chid A B C', 'chain _'. Note that chid is a synonym for chain.

setCoords(coords, label='')[source]

Set coordinates of atoms. coords may be any array like object or an object instance with getCoords() method. If the shape of coordinate array is (n_csets > 1, n_atoms, 3), it will replace all coordinate sets and the active coordinate set index will reset to zero. This situation can be avoided using addCoordset(). If shape of coords is (n_atoms, 3) or (1, n_atoms, 3), it will replace the active coordinate set. label argument may be used to label coordinate set(s). label may be a string or a list of strings length equal to the number of coordinate sets.

setData(label, data)[source]

Store atomic data under label, which must:

  • start with a letter
  • contain only alphanumeric characters and underscore
  • not be a reserved word (see listReservedWords())

data must be a list() or a ndarray and its length must be equal to the number of atoms. If the dimension of the data array is 1, i.e. data.ndim==1, label may be used to make atom selections, e.g. "label 1 to 10" or "label C1 C2". Note that, if data with label is present, it will be overwritten.

setElements(data)

Set element symbols. Element symbols can be used in atom selections, e.g. 'element C O N'.

setFlags(label, flags)[source]

Set atom flags for label.

setIcodes(data)

Set insertion codes. Insertion codes can be used in atom selections, e.g. 'icode A', 'icode _'.

setMasses(data)

Set masses. Masses can be used in atom selections, e.g. '12 <= mass <= 13.5'.

setNames(data)

Set names. Names can be used in atom selections, e.g. 'name CA CB'.

setOccupancies(data)

Set occupancy values. Occupancy values can be used in atom selections, e.g. 'occupancy 1', 'occupancy > 0'.

setRadii(data)

Set radii. Radii can be used in atom selections, e.g. 'radii < 1.5', 'radii ** 2 < 2.3'.

setResnames(data)

Set residue names. Residue names can be used in atom selections, e.g. 'resname ALA GLY'.

setResnums(data)

Set residue numbers. Residue numbers can be used in atom selections, e.g. 'resnum 1 2 3', 'resnum 120A 120B', 'resnum 10 to 20', 'resnum 10:20:2', 'resnum < 10'. Note that resid is a synonym for resnum.

setSecstrs(data)

Set secondary structure assignments. Secondary structure assignments can be used in atom selections, e.g. 'secondary H E', 'secstr H E'. Note that secstr is a synonym for secondary.

setSegnames(data)

Set segment names. Segment names can be used in atom selections, e.g. 'segment PROT', 'segname PROT'. Note that segname is a synonym for segment.

setSerials(data)

Set serial numbers (from file). Serial numbers can be used in atom selections, e.g. 'serial 1 2 3', 'serial 1 to 10', 'serial 1:10:2', 'serial < 10'.

setTitle(title)[source]

Set title of the instance.

setTypes(data)

Set types. Types can be used in atom selections, e.g. 'type CT1 CT2 CT3'.

Read the Docs v: v1.5
Versions
latest
v1.5
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.