3 __doc__ =
"Refine fitting subunits into a density map with FFT."
9 from IMP
import OptionParser
14 def __init__(self, em_map, spacing, resolution, origin, density_threshold,pdb, fits_fn, angle,num_fits,angles_per_voxel,max_trans,max_angle,ref_pdb=''):
16 self.spacing = spacing
17 self.resolution = resolution
18 self.threshold=density_threshold
19 self.originx = origin[0]
20 self.originy = origin[1]
21 self.originz = origin[2]
23 self.fits_fn = fits_fn
25 self.num_fits=num_fits
26 self.angles_per_voxel=angles_per_voxel
27 self.max_trans=max_trans
28 self.max_angle=max_angle
32 def run_local_fitting(self,mol2fit,rb,initial_transformation):
33 print "resolution is:",self.resolution
35 dmap.get_header().set_resolution(self.resolution)
36 dmap.update_voxel_size(self.spacing)
40 dmap.set_was_used(
True)
41 dmap.get_header().
show()
47 max_clustering_translation=3
48 max_clustering_rotation=5
49 num_fits_to_report=100
51 fits = ff.do_local_fitting(dmap, self.threshold,mol2fit,
52 self.angle / 180.0 * math.pi,
53 self.max_angle / 180.0 * math.pi, self.max_trans, num_fits_to_report,
54 do_cluster_fits, self.angles_per_voxel,
55 max_clustering_translation,max_clustering_rotation)
56 fits.set_was_used(
True)
57 final_fits = fits.best_fits_
62 for i, fit
in enumerate(final_fits):
65 trans=fit.get_fit_transformation()
71 fit.set_rmsd_to_reference(rmsd)
73 fit.set_fit_transformation(trans*initial_transformation)
75 print 'from all fits, lowest rmsd to ref:',cur_low
84 usage =
"""%prog [options] <assembly input> <refined assembly input> <proteomics.input> <mapping.input> <combinations file> <combination index>
86 Fit subunits locally around a combination solution with FFT."""
88 parser.add_option(
"-a",
"--angle", dest=
"angle", type=
"float",
90 help=
"angle delta (degrees) for FFT rotational "
93 parser.add_option(
"-n",
"--num", dest=
"num", type=
"int",
95 help=
"Number of fits to report"
98 parser.add_option(
"-v",
"--angle_voxel", dest=
"angle_voxel", type=
"int",
100 help=
"Number of angles to keep per voxel"
103 parser.add_option(
"-t",
"--max_trans", dest=
"max_trans", type=
"float",
105 help=
"maximum translational search in A"
108 parser.add_option(
"-m",
"--max_angle", dest=
"max_angle", type=
"float",
110 help=
"maximum angular search in degrees"
113 options, args = parser.parse_args()
115 parser.error(
"incorrect number of arguments")
118 def run(asmb_fn, asmb_refined_fn, proteomics_fn,mapping_fn,combs_fn,comb_ind,options):
124 asmb_input.set_was_used(
True)
126 asmb_refined_input.set_was_used(
True)
131 ensmb.set_was_used(
True)
132 mhs=ensmb.get_molecules()
135 ensmb_ref.set_was_used(
True)
136 mhs_ref=ensmb_ref.get_molecules()
138 ensmb.load_combination(combs[comb_ind])
140 em_map=asmb_input.get_assembly_header().get_dens_fn()
141 resolution=asmb_input.get_assembly_header().get_resolution()
142 spacing=asmb_input.get_assembly_header().get_spacing()
143 origin=asmb_input.get_assembly_header().get_origin()
145 rbs_ref=ensmb_ref.get_rigid_bodies()
146 rbs=ensmb.get_rigid_bodies()
148 for i,mh
in enumerate(mhs):
149 fits_fn=asmb_refined_input.get_component_header(i).get_transformations_fn()
156 rb_ref.get_reference_frame(),
157 rb.get_reference_frame())
159 pdb_fn=asmb_input.get_component_header(i).get_filename()
161 f = Fitter(em_map, spacing, resolution, origin, asmb_input.get_assembly_header().get_threshold(),pdb_fn, fits_fn, options.angle,options.num,options.angle_voxel,
162 options.max_trans,options.max_angle)
163 f.run_local_fitting(mh,rb,initial_transformation)
166 options,args = parse_args()
168 asmb_refined_input = args[1]
169 proteomics_fn=args[2]
171 combinations_fn = args[4]
172 combination_ind = int(args[5])
173 run(asmb_input, asmb_refined_input, proteomics_fn,mapping_fn,combinations_fn, combination_ind, options)
175 if __name__==
"__main__":
void show(const cv::Mat &m, std::ostream &out=std::cout)
Prints a OpenCV matrix.
Fit a molecule inside its density by local or global FFT.
SettingsData * read_settings(const char *filename)
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
Transformation3D get_transformation_from_first_to_second(const ReferenceFrame3D &a, const ReferenceFrame3D &b)
ProteinsAnchorsSamplingSpace read_protein_anchors_mapping(multifit::ProteomicsData *prots, const std::string &anchors_prot_map_fn, int max_paths=INT_MAX)
double get_rmsd(const Selection &s0, const Selection &s1, const IMP::algebra::Transformation3D &tr_for_second=IMP::algebra::get_identity_transformation_3d())
void transform(Hierarchy h, const algebra::Transformation3D &tr)
Ensemble * load_ensemble(multifit::SettingsData *sd, Model *mdl, const ProteinsAnchorsSamplingSpace &mapping_data)
See IMP.multifit for more information.
See IMP.em 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.
DensityMap * read_map(std::string filename)
ProteomicsData * read_proteomics_data(const char *proteomics_fn)
Proteomics reader.
IMP::kernel::OptionParser OptionParser
IntsList read_paths(const char *txt_filename, int max_paths=INT_MAX)
Read paths.
See IMP.atom for more information.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.