IMP  2.2.1
The Integrative Modeling Platform
add_fit_rmsd.py
1 #!/usr/bin/env python
2 
3 __doc__ = "Add RMSD to reference to each fitting file."
4 
5 import IMP.multifit
6 from IMP import OptionParser
7 
8 
9 def parse_args():
10  usage = """%prog [options] <asmb.input> <proteomics> <mapping> <align param>
11 
12 Given a set of local fits (e.g. generated by fit_fft), the RMSD between each
13 subunit and a reference orientation is calculated and added to each fitting
14 file, in the final "RMSD to reference" column. (The original fitting file is
15 not modified; a new fitting file is created with a '.RMSD' extension.)
16 
17 Note that the assembly input file must contain a reference PDB filename for
18 each subunit (in the rightmost column).
19 """
20  parser = OptionParser(usage)
21  parser.add_option("-d", action="store_true", dest="use_dock",
22  help="if set the docking transformation is used (and not the fitting transformation)")
23  (options, args) = parser.parse_args()
24  if len(args) != 4:
25  parser.error("incorrect number of arguments")
26  return [options, args]
27 
28 
29 def run(asmb_fn, proteomics_fn, mapping_fn, params_fn, dock_trans):
30  asmb = IMP.multifit.read_settings(asmb_fn)
31 
32  prot_data = IMP.multifit.read_proteomics_data(proteomics_fn)
33  print "=========3"
35  prot_data, mapping_fn)
36  alignment_params = IMP.multifit.AlignmentParams(params_fn)
38  mapping_data, asmb, alignment_params)
39  ensmb = IMP.multifit.Ensemble(asmb, mapping_data)
40  print "=========6"
41  # load all proteomics restraints
42  mdl = align.get_model()
43  mhs = align.get_molecules()
44  gs = []
45  for i, mh in enumerate(mhs):
46  fits_fn = asmb.get_component_header(i).get_transformations_fn()
48  print "calculating rmsd for", len(fits), "fits of protein", mh.get_name()
50  mh_ref = IMP.atom.read_pdb(
51  asmb.get_component_header(i).get_reference_fn(),
52  mdl)
53  rb = IMP.atom.setup_as_rigid_body(mh_ref)
54  xyz_ref = IMP.core.XYZs(IMP.core.get_leaves(mh_ref))
55  new_fits = []
56  for i, rec in enumerate(fits):
57  fit_t = rec.get_fit_transformation()
58  if dock_trans:
59  fit_t = rec.get_dock_transformation()
60  IMP.core.transform(rb, fit_t)
61  rmsd = IMP.atom.get_rmsd(xyz, xyz_ref)
62  rec.set_rmsd_to_reference(rmsd)
63  new_fits.append(rec)
64  IMP.core.transform(rb, fit_t.get_inverse())
65  IMP.multifit.write_fitting_solutions(fits_fn + ".RMSD", new_fits)
66 
67 
68 def main():
69  options, args = parse_args()
70  run(args[0], args[1], args[2], args[3], options.use_dock)
71 
72 if __name__ == "__main__":
73  main()
An ensemble of fitting solutions.
double get_rmsd(const core::XYZs &s0, const core::XYZs &s1, const IMP::algebra::Transformation3D &tr_for_second)
SettingsData * read_settings(const char *filename)
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
ProteinsAnchorsSamplingSpace read_protein_anchors_mapping(multifit::ProteomicsData *prots, const std::string &anchors_prot_map_fn, int max_paths=INT_MAX)
Align proteomics graph to EM density map.
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
See IMP.multifit for more information.
void write_fitting_solutions(const char *fitting_fn, const FittingSolutionRecords &fit_sols, int num_sols=-1)
Write fitting solutions to a file.
ProteomicsData * read_proteomics_data(const char *proteomics_fn)
Proteomics reader.
IMP::kernel::OptionParser OptionParser
FittingSolutionRecords read_fitting_solutions(const char *fitting_fn)
Fitting solutions reader.
void read_pdb(base::TextInput input, int model, Hierarchy h)