IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
multistate.py
1## \example multistate.py
2# This example shows how to represent multiple states of a system. Two copies
3# of the same protein are added to a single hierarchy, and each is decorated
4# as an IMP::atom::State with a different index. IMP::atom::Selection is then
5# used to find an atom in just one of the states.
6
7import IMP.atom
8import sys
9
10IMP.setup_from_argv(sys.argv, "multistate")
11
12m = IMP.Model()
13
14rt = IMP.atom.Hierarchy.setup_particle(m, m.add_particle("root"))
15
16
17def create_one():
18 h = IMP.atom.read_pdb(IMP.atom.get_example_path("1d3d-protein.pdb"), m)
19 return h
20
21
22h0 = create_one()
23rt.add_child(h0)
25h1 = create_one()
26rt.add_child(h1)
28
29
31 rt,
32 state_index=1,
33 residue_index=8,
34 atom_type=IMP.atom.AT_CA)
35
36# we get the 8th CA from state 1
37for p in r8.get_selected_particles():
38 print(IMP.atom.get_state_index(p), p)
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
Select hierarchy particles identified by the biological name.
Definition Selection.h:76
static State setup_particle(Model *m, ParticleIndex pi, unsigned int index)
Definition State.h:39
Functionality for loading, creating, manipulating and scoring atomic structures.
int get_state_index(Hierarchy h)
Walk up the hierarchy to find the current state.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Hierarchy read_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB file.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.