IMP logo
IMP Reference Guide  2.11.1
The Integrative Modeling Platform
add_fit_rmsd.py
1 #!/usr/bin/env python
2 
3 from __future__ import print_function
4 import IMP.multifit
5 from IMP import ArgumentParser
6 
7 __doc__ = "Add RMSD to reference to each fitting file."
8 
9 def parse_args():
10  desc = """
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  p = ArgumentParser(description=desc)
20  p.add_argument("-d", action="store_true", dest="use_dock",
21  help="if set the docking transformation is used (and not "
22  "the fitting transformation)")
23  p.add_argument("assembly_file", help="assembly file name")
24  p.add_argument("proteomics_file", help="proteomics file name")
25  p.add_argument("mapping_file", help="mapping file name")
26  p.add_argument("param_file", help="parameter file name")
27  return p.parse_args()
28 
29 
30 def run(asmb_fn, proteomics_fn, mapping_fn, params_fn, dock_trans):
31  asmb = IMP.multifit.read_settings(asmb_fn)
32 
33  prot_data = IMP.multifit.read_proteomics_data(proteomics_fn)
34  print("=========3")
36  prot_data, mapping_fn)
37  alignment_params = IMP.multifit.AlignmentParams(params_fn)
39  mapping_data, asmb, alignment_params)
40  ensmb = IMP.multifit.Ensemble(asmb, mapping_data)
41  print("=========6")
42  # load all proteomics restraints
43  mdl = align.get_model()
44  mhs = align.get_molecules()
45  gs = []
46  for i, mh in enumerate(mhs):
47  fits_fn = asmb.get_component_header(i).get_transformations_fn()
49  print("calculating rmsd for", len(fits), "fits of protein", mh.get_name())
51  mh_ref = IMP.atom.read_pdb(
52  asmb.get_component_header(i).get_reference_fn(),
53  mdl)
54  rb = IMP.atom.create_rigid_body(mh_ref)
55  xyz_ref = IMP.core.XYZs(IMP.core.get_leaves(mh_ref))
56  new_fits = []
57  for i, rec in enumerate(fits):
58  fit_t = rec.get_fit_transformation()
59  if dock_trans:
60  fit_t = rec.get_dock_transformation()
61  IMP.core.transform(rb, fit_t)
62  rmsd = IMP.atom.get_rmsd(xyz, xyz_ref)
63  rec.set_rmsd_to_reference(rmsd)
64  new_fits.append(rec)
65  IMP.core.transform(rb, fit_t.get_inverse())
66  IMP.multifit.write_fitting_solutions(fits_fn + ".RMSD", new_fits)
67 
68 
69 def main():
70  args = parse_args()
71  run(args.assembly_file, args.proteomics_file, args.mapping_file,
72  args.param_file, args.use_dock)
73 
74 if __name__ == "__main__":
75  main()
An ensemble of fitting solutions.
def main
Run a set of tests; similar to unittest.main().
SettingsData * read_settings(const char *filename)
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
void read_pdb(TextInput input, int model, Hierarchy h)
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.
double get_rmsd(const Selection &s0, const Selection &s1)
void transform(XYZ a, const algebra::Transformation3D &tr)
Apply a transformation to the particle.
Fitting atomic structures into a cryo-electron microscopy density map.
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.
FittingSolutionRecords read_fitting_solutions(const char *fitting_fn)
Fitting solutions reader.
IMP::core::RigidBody create_rigid_body(Hierarchy h)