IMP logo
IMP Reference Guide  2.8.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 OptionParser
9 
10 
11 def parse_args():
12  usage = """%prog [options] <subunit> <symmetry degree>
13  <transformations file> <number of models> <output models>
14 
15 This script, given the structure of a single subunit and the Chimera
16 transformations file, applies the transformations to generate a number of
17 complete models.
18 
19  <subunit> subunit PDB, the same given to MultiFit.
20  <symmetry degree> Cn degree.
21  <transformations file> MultiFit output in chimera output format.
22  <number of models> number of models to print.
23  <output models> Solutions are written as output.i.pdb."""
24  parser = OptionParser(usage)
25  opts, args = parser.parse_args()
26  if len(args) != 5:
27  parser.error("incorrect number of arguments")
28  return args
29 
30 
31 def get_transformations(sol):
32  [ind, dock_rot_s, dock_trans_s, fit_rot_s,
33  fit_trans_s, cc_s] = sol.split("|")
34  s = dock_rot_s.split(" ")
35  s1 = dock_trans_s.split(" ")
38  float(s[0]), float(s[1]), float(s[2]),
39  float(s[3]), float(s[4]), float(s[5]),
40  float(s[6]), float(s[7]), float(s[8])),
41  IMP.algebra.Vector3D(float(s1[0]), float(s1[1]), float(s1[2])))
42  s = fit_rot_s.split(" ")
43  s1 = fit_trans_s.split(" ")
46  float(s[0]), float(s[1]), float(s[2]),
47  float(s[3]), float(s[4]), float(s[5]),
48  float(s[6]), float(s[7]), float(s[8])),
49  IMP.algebra.Vector3D(float(s1[0]), float(s1[1]), float(s1[2])))
50  return dock_t, fit_t
51 
52 
53 def run(subunit_fn, symm_deg, sol_fn, num, output_fn):
54  mdl = IMP.Model()
55  mhs = []
56  rbs = []
57  for i in range(symm_deg):
58  mh = IMP.atom.read_pdb(subunit_fn, mdl)
59  mhs.append(mh)
60  rbs.append(IMP.atom.create_rigid_body(mh))
61  lines = open(sol_fn).readlines()
62  for j, sol in enumerate(lines[:num]):
63  dock_t, fit_t = get_transformations(sol)
64  curr_t = dock_t
65  for i in range(symm_deg):
66  IMP.core.transform(rbs[i], curr_t)
67  curr_t = dock_t * curr_t
68  for i in range(symm_deg):
69  IMP.core.transform(rbs[i], fit_t)
70  IMP.atom.write_pdb(mhs, output_fn + ".%03d.pdb" % j)
71 
72 
73 def main():
74  args = parse_args()
75  run(args[0], int(args[1]), args[2], int(args[3]), args[4])
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.
Rotation3D get_rotation_from_matrix(IMP_Eigen::Matrix3d m)
Generate a Rotation3D object from a rotation matrix.
VectorD< 3 > Vector3D
Definition: VectorD.h:395
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Functionality for loading, creating, manipulating and scoring atomic structures.