IMP logo
IMP Reference Guide  2.11.0
The Integrative Modeling Platform
chimera_models.py
1 #!/usr/bin/env python
2 
3 __doc__ = "Generate complete models from Chimera transformations file."
4 
5 import sys
6 import IMP
7 import IMP.atom
8 from IMP import ArgumentParser
9 
10 
11 def parse_args():
12  desc = """
13 This script, given the structure of a single subunit and the Chimera
14 transformations file, applies the transformations to generate a number of
15 complete models."""
16 
17  p = ArgumentParser(description=desc)
18  p.add_argument('subunit', help="subunit PDB, the same given to MultiFit")
19  p.add_argument('degree', type=int, help="Cn symmetry degree")
20  p.add_argument('transform_file',
21  help="MultiFit output file in Chimera output format")
22  p.add_argument('num_models', type=int,
23  help="number of output models")
24  p.add_argument('output',
25  help="solution filename prefix; solutions are written "
26  "as <output>.i.pdb")
27  return p.parse_args()
28 
29 
30 def get_transformations(sol):
31  [ind, dock_rot_s, dock_trans_s, fit_rot_s,
32  fit_trans_s, cc_s] = sol.split("|")
33  s = dock_rot_s.split(" ")
34  s1 = dock_trans_s.split(" ")
37  float(s[0]), float(s[1]), float(s[2]),
38  float(s[3]), float(s[4]), float(s[5]),
39  float(s[6]), float(s[7]), float(s[8])),
40  IMP.algebra.Vector3D(float(s1[0]), float(s1[1]), float(s1[2])))
41  s = fit_rot_s.split(" ")
42  s1 = fit_trans_s.split(" ")
45  float(s[0]), float(s[1]), float(s[2]),
46  float(s[3]), float(s[4]), float(s[5]),
47  float(s[6]), float(s[7]), float(s[8])),
48  IMP.algebra.Vector3D(float(s1[0]), float(s1[1]), float(s1[2])))
49  return dock_t, fit_t
50 
51 
52 def run(subunit_fn, symm_deg, sol_fn, num, output_fn):
53  mdl = IMP.Model()
54  mhs = []
55  rbs = []
56  for i in range(symm_deg):
57  mh = IMP.atom.read_pdb(subunit_fn, mdl)
58  mhs.append(mh)
59  rbs.append(IMP.atom.create_rigid_body(mh))
60  lines = open(sol_fn).readlines()
61  for j, sol in enumerate(lines[:num]):
62  dock_t, fit_t = get_transformations(sol)
63  curr_t = dock_t
64  for i in range(symm_deg):
65  IMP.core.transform(rbs[i], curr_t)
66  curr_t = dock_t * curr_t
67  for i in range(symm_deg):
68  IMP.core.transform(rbs[i], fit_t)
69  IMP.atom.write_pdb(mhs, output_fn + ".%03d.pdb" % j)
70 
71 
72 def main():
73  args = parse_args()
74  run(args.subunit, args.degree, args.transform_file, args.num_models,
75  args.output)
76 
77 if __name__ == "__main__":
78  main()
Simple 3D transformation class.
void write_pdb(const Selection &mhd, TextOutput out, unsigned int model=1)
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:72
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Functionality for loading, creating, manipulating and scoring atomic structures.
Rotation3D get_rotation_from_matrix(Eigen::Matrix3d m)
Generate a Rotation3D object from a rotation matrix.