IMP logo
IMP Reference Guide  2.22.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 IMP
6 import IMP.atom
7 from IMP import ArgumentParser
8 
9 
10 def parse_args():
11  desc = """
12 This script, given the structure of a single subunit and the Chimera
13 transformations file, applies the transformations to generate a number of
14 complete models."""
15 
16  p = ArgumentParser(description=desc)
17  p.add_argument('subunit', help="subunit PDB, the same given to MultiFit")
18  p.add_argument('degree', type=int, help="Cn symmetry degree")
19  p.add_argument('transform_file',
20  help="MultiFit output file in Chimera output format")
21  p.add_argument('num_models', type=int,
22  help="number of output models")
23  p.add_argument('output',
24  help="solution filename prefix; solutions are written "
25  "as <output>.i.pdb")
26  return p.parse_args()
27 
28 
29 def get_transformations(sol):
30  [ind, dock_rot_s, dock_trans_s, fit_rot_s,
31  fit_trans_s, cc_s] = sol.split("|")
32  s = dock_rot_s.split(" ")
33  s1 = dock_trans_s.split(" ")
36  float(s[0]), float(s[1]), float(s[2]),
37  float(s[3]), float(s[4]), float(s[5]),
38  float(s[6]), float(s[7]), float(s[8])),
39  IMP.algebra.Vector3D(float(s1[0]), float(s1[1]), float(s1[2])))
40  s = fit_rot_s.split(" ")
41  s1 = fit_trans_s.split(" ")
44  float(s[0]), float(s[1]), float(s[2]),
45  float(s[3]), float(s[4]), float(s[5]),
46  float(s[6]), float(s[7]), float(s[8])),
47  IMP.algebra.Vector3D(float(s1[0]), float(s1[1]), float(s1[2])))
48  return dock_t, fit_t
49 
50 
51 def run(subunit_fn, symm_deg, sol_fn, num, output_fn):
52  mdl = IMP.Model()
53  mhs = []
54  rbs = []
55  for i in range(symm_deg):
56  mh = IMP.atom.read_pdb(subunit_fn, mdl)
57  mhs.append(mh)
58  rbs.append(IMP.atom.create_rigid_body(mh))
59  lines = open(sol_fn).readlines()
60  for j, sol in enumerate(lines[:num]):
61  dock_t, fit_t = get_transformations(sol)
62  curr_t = dock_t
63  for i in range(symm_deg):
64  IMP.core.transform(rbs[i], curr_t)
65  curr_t = dock_t * curr_t
66  for i in range(symm_deg):
67  IMP.core.transform(rbs[i], fit_t)
68  IMP.atom.write_pdb(mhs, output_fn + ".%03d.pdb" % j)
69 
70 
71 def main():
72  args = parse_args()
73  run(args.subunit, args.degree, args.transform_file, args.num_models,
74  args.output)
75 
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:86
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
VectorD< 3 > Vector3D
Definition: VectorD.h:408
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.