The ihm.model
Python module¶
Classes for handling models (sets of coordinates) as well as groups of models.
-
class
ihm.model.
Sphere
(asym_unit, seq_id_range, x, y, z, radius, rmsf=None)[source]¶ Coordinates of part of the model represented by a sphere.
See
Model.get_spheres()
for more details.Parameters: - asym_unit (
ihm.AsymUnit
) – The asymmetric unit that this sphere represents - seq_id_range (tuple) – The range of residues represented by this sphere (as a two-element tuple)
- x (float) – x coordinate of the center of the sphere
- y (float) – y coordinate of the center of the sphere
- z (float) – z coordinate of the center of the sphere
- radius (float) – radius of the sphere
- rmsf (float) – root-mean-square fluctuation of the coordinates
- asym_unit (
-
class
ihm.model.
Atom
(asym_unit, seq_id, atom_id, type_symbol, x, y, z, het=False, biso=None, occupancy=None)[source]¶ Coordinates of part of the model represented by an atom.
See
Model.get_atoms()
for more details. Note that this class is used only to represent the coordinates of an atom. To access atom-specific properties of the model, see theihm.Atom
class.Parameters: - asym_unit (
ihm.AsymUnit
) – The asymmetric unit that this atom represents - seq_id (int) – The sequence ID of the residue represented by this atom. This should generally be a number starting at 1 for any polymer chain or water, or None for a ligand.
- atom_id (str) – The name of the atom in the residue
- type_symbol (str) – Element name
- x (float) – x coordinate of the atom
- y (float) – y coordinate of the atom
- z (float) – z coordinate of the atom
- het (bool) – True for HETATM sites, False (default) for ATOM
- biso (float) – Temperature factor or equivalent (if applicable)
- occupancy (float) – Fraction of the atom type present (if applicable)
- asym_unit (
-
class
ihm.model.
Model
(assembly, protocol, representation, name=None)[source]¶ A single set of coordinates (conformation).
Models are added to the system by placing them inside
ModelGroup
objects, which in turn are placed insideState
objects, which are grouped inStateGroup
objects, which are finally added to the system viaihm.System.state_groups
.Parameters: - assembly (
Assembly
) – The parts of the system that were modeled. - protocol (
Protocol
) – Description of how the modeling was done. - representation (
Representation
) – Level of detail at which the system was represented. - name (str) – Descriptive name for this model.
-
add_atom
(atom)[source]¶ Add to the model’s set of
Atom
objects.See
get_spheres()
for more details.
-
add_sphere
(sphere)[source]¶ Add to the model’s set of
Sphere
objects.See
get_spheres()
for more details.
-
get_atoms
()[source]¶ Yield
Atom
objects that represent this model.See
get_spheres()
for more details.
-
get_spheres
()[source]¶ Yield
Sphere
objects that represent this model.The default implementation simply iterates over an internal list of spheres, but this is not very memory-efficient, particularly if the spheres are already stored somewhere else, e.g. in the software’s own data structures. It is recommended to subclass and provide a more efficient implementation. For example, the modeling of Nup133 uses a custom subclass to pass BioPython objects through to python-ihm.
Note that the set of spheres should match the model’s
Representation
. This is not currently enforced.
- assembly (
-
class
ihm.model.
ModelGroup
(elements=(), name=None)[source]¶ A set of related models. See
Model
. It is implemented as a simple list of the models.These objects are typically stored in a
State
,Ensemble
, orOrderedProcess
.Parameters: - elements – Initial set of models in the group.
- name (str) – Descriptive name for the group.
-
class
ihm.model.
State
(elements=(), type=None, name=None, details=None, experiment_type=None, population_fraction=None)[source]¶ A set of model groups that constitute a single state of the system. It is implemented as a simple list of the model groups. See
StateGroup
.Parameters: elements – The initial set of ModelGroup
objects in this state.
-
class
ihm.model.
StateGroup
(elements=())[source]¶ A set of related states. See
State
andihm.System.state_groups
. It is implemented as a simple list of the states.Parameters: elements – Initial set of states in the group.
-
class
ihm.model.
Ensemble
(model_group, num_models, post_process=None, clustering_method=None, clustering_feature=None, name=None, precision=None, file=None, details=None, superimposed=None)[source]¶ Details about a model cluster or ensemble. See
ihm.System.ensembles
.Parameters: - model_group (
ModelGroup
) – The set of models in this ensemble. - num_models (int) – The total number of models in this ensemble. This may be more than the number of models in model_group, for example if only representative or top-scoring models are deposited.
- post_process (
ihm.analysis.Step
) – The final analysis step that generated this ensemble. - clustering_method (str) – The method used to obtain the ensemble, if applicable.
- clustering_feature (str) – The feature used for clustering the models, if applicable.
- name (str) – A descriptive name for this ensemble.
- precision (float) – The precision of the entire ensemble.
- file (
ihm.location.OutputFileLocation
) – A reference to an external file containing coordinates for the entire ensemble, for example as a DCD file (seeDCDWriter
). See alsosubsamples
. - details (str) – Additional text describing this ensemble
- superimposed (bool) – True if the models in the group are structurally aligned.
-
clustering_feature
¶ The feature used for clustering the models, if applicable
-
clustering_method
¶ The clustering method used to obtain the ensemble, if applicable
-
densities
= None¶ All localization densities for this ensemble, as
LocalizationDensity
objects
-
num_models_deposited
¶ Number of models in this ensemble that are in the mmCIF file
- model_group (
-
class
ihm.model.
OrderedProcess
(ordered_by, description=None)[source]¶ Details about a process that orders two or more model groups.
A process is represented as a directed graph, where the nodes are
ModelGroup
objects and the edges represent transitions.These objects are generally added to
ihm.System.ordered_processes
.Parameters: - ordered_by (str) – Text that explains how the ordering is done, such as “time steps”.
- description (str) – Text that describes this process.
-
steps
= None¶ All steps in this process, as a simple list of
ProcessStep
objects
-
class
ihm.model.
ProcessStep
(elements=(), description=None)[source]¶ A single step in an
OrderedProcess
.This is implemented as a simple list of
ProcessEdge
objects, each of which orders twoModelGroup
objects. (To order more than two groups, for example to represent a branched reaction step that generates two products, simply add multiple edges to the step.)Parameters: - elements (sequence) – Initial set of
ProcessEdge
objects. - description (str) – Text that describes this step.
- elements (sequence) – Initial set of
-
class
ihm.model.
ProcessEdge
(group_begin, group_end, description=None)[source]¶ A single directed edge in the graph for a
OrderedProcess
, representing the transition from oneModelGroup
to another. These objects are added toProcessStep
objects.Parameters: - group_begin (
ModelGroup
) – The set of models at the origin of the edge. - group_end (
ModelGroup
) – The set of models at the end of the edge. - description (str) – Text that describes this edge.
- group_begin (
-
class
ihm.model.
LocalizationDensity
(file, asym_unit)[source]¶ Localization density of part of the system, over all models in an ensemble.
See
Ensemble.densities
.Parameters: - file (
ihm.location.OutputFileLocation
) – A reference to an external file containing the density, for example as an MRC file. - asym_unit (
AsymUnit
orAsymUnitRange
) – The asymmetric unit (or part of one) that this density represents.
- file (
-
class
ihm.model.
DCDWriter
(fh)[source]¶ Utility class to write model coordinates to a binary DCD file.
See
Ensemble
andModel
. Since mmCIF is a text-based format, it is not efficient to store entire ensembles in this format. Instead, representative models should be deposited as mmCIF and theEnsemble
then linked to an external file containing only model coordinates. One such format is CHARMM/NAMD’s DCD, which is written out by this class. The DCD files simply contain the xyz coordinates of allAtom
andSphere
objects in eachModel
. (Note that no other data is stored, such as sphere radii or restraint parameters.)Parameters: fh (file) – The filelike object to write the coordinates to. This should be open in binary mode and should be a seekable object.
-
class
ihm.model.
Subsample
(name, num_models, model_group=None, file=None)[source]¶ Base class for a subsample within an ensemble.
In some cases the models that make up an
Ensemble
may be partitioned into subsamples, for example to determine if the sampling was exhaustive (see Viswanath et al. 2017). This base class can be used to describe the set of models in the subsample, for example by pointing to an externally-deposited set of conformations.Usually a derived class (
RandomSubsample
orIndependentSubsample
) is used instead of this class. Instances are stored inEnsemble.subsamples
. All of the subsamples in a given ensemble must be of the same type.Parameters: - name (str) – A descriptive name for this sample
- num_models (int) – The total number of models in this sample
- model_group (
ModelGroup
) – The set of models in this sample, if applicable. - file (
ihm.location.OutputFileLocation
) – A reference to an external file containing coordinates for the entire sample, for example as a DCD file (seeDCDWriter
).
-
num_models_deposited
¶ Number of models in this subsample that are in the mmCIF file