IMP  2.0.0
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 optparse import OptionParser
7 
8 def parse_args():
9  usage = """%prog [options] <asmb.input> <proteomics> <mapping> <align param>
10 
11 Given a set of local fits (e.g. generated by fit_fft), the RMSD between each
12 subunit and a reference orientation is calculated and added to each fitting
13 file, in the final "RMSD to reference" column. (The original fitting file is
14 not modified; a new fitting file is created with a '.RMSD' extension.)
15 
16 Note that the assembly input file must contain a reference PDB filename for
17 each subunit (in the rightmost column).
18 """
19  parser = OptionParser(usage)
20  parser.add_option("-d", action="store_true", dest="use_dock",
21  help="if set the docking transformation is used (and not the fitting transformation)")
22  (options, args) = parser.parse_args()
23  if len(args) != 4:
24  parser.error("incorrect number of arguments")
25  return [options,args]
26 
27 def run(asmb_fn,proteomics_fn,mapping_fn,params_fn,dock_trans):
28  asmb=IMP.multifit.read_settings(asmb_fn)
29 
30  prot_data=IMP.multifit.read_proteomics_data(proteomics_fn)
31  print "=========3"
32  mapping_data=IMP.multifit.read_protein_anchors_mapping(prot_data,mapping_fn)
33  alignment_params = IMP.multifit.AlignmentParams(params_fn)
34  align=IMP.multifit.ProteomicsEMAlignmentAtomic(mapping_data,asmb,alignment_params)
35  ensmb=IMP.multifit.Ensemble(asmb,mapping_data)
36  print "=========6"
37  #load all proteomics restraints
38  mdl=align.get_model()
39  mhs=align.get_molecules()
40  gs=[]
41  for i,mh in enumerate(mhs):
42  fits_fn=asmb.get_component_header(i).get_transformations_fn()
44  print "calculating rmsd for",len(fits),"fits of protein",mh.get_name()
45  xyz=IMP.core.XYZs(IMP.core.get_leaves(mh))
46  mh_ref=IMP.atom.read_pdb(asmb.get_component_header(i).get_reference_fn(),mdl)
47  rb=IMP.atom.setup_as_rigid_body(mh_ref)
48  xyz_ref=IMP.core.XYZs(IMP.core.get_leaves(mh_ref))
49  new_fits=[]
50  for i,rec in enumerate(fits):
51  fit_t=rec.get_fit_transformation()
52  if dock_trans:
53  fit_t=rec.get_dock_transformation()
54  IMP.core.transform(rb,fit_t)
55  rmsd=IMP.atom.get_rmsd(xyz,xyz_ref)
56  rec.set_rmsd_to_reference(rmsd)
57  new_fits.append(rec)
58  IMP.core.transform(rb,fit_t.get_inverse())
59  IMP.multifit.write_fitting_solutions(fits_fn+".RMSD",new_fits)
60 
61 def main():
62  options,args = parse_args()
63  run(args[0],args[1],args[2],args[3],options.use_dock)
64 
65 if __name__=="__main__":
66  main()