3 from __future__
import print_function
8 from IMP
import ArgumentParser
10 __doc__ =
"Refine fitting subunits into a density map with FFT."
31 self.spacing = spacing
32 self.resolution = resolution
33 self.threshold = density_threshold
34 self.originx = origin[0]
35 self.originy = origin[1]
36 self.originz = origin[2]
38 self.fits_fn = fits_fn
40 self.num_fits = num_fits
41 self.angles_per_voxel = angles_per_voxel
42 self.max_trans = max_trans
43 self.max_angle = max_angle
44 self.ref_pdb = ref_pdb
47 def run_local_fitting(self, mol2fit, rb, initial_transformation):
48 print(
"resolution is:", self.resolution)
49 dmap = IMP.em.read_map(self.em_map)
50 dmap.get_header().set_resolution(self.resolution)
51 dmap.update_voxel_size(self.spacing)
55 dmap.set_was_used(
True)
56 dmap.get_header().show()
61 do_cluster_fits =
True
62 max_clustering_translation = 3
63 max_clustering_rotation = 5
64 num_fits_to_report = 100
66 fits = ff.do_local_fitting(dmap, self.threshold, mol2fit,
67 self.angle / 180.0 * math.pi,
68 self.max_angle / 180.0 * math.pi,
69 self.max_trans, num_fits_to_report,
70 do_cluster_fits, self.angles_per_voxel,
71 max_clustering_translation,
72 max_clustering_rotation)
73 fits.set_was_used(
True)
74 final_fits = fits.best_fits_
75 if self.ref_pdb !=
'':
79 for i, fit
in enumerate(final_fits):
81 if self.ref_pdb !=
'':
82 trans = fit.get_fit_transformation()
88 fit.set_rmsd_to_reference(rmsd)
90 fit.set_fit_transformation(trans * initial_transformation)
91 if self.ref_pdb !=
'':
92 print(
'from all fits, lowest rmsd to ref:', cur_low)
102 Fit subunits locally around a combination solution with FFT."""
103 p = ArgumentParser(description=desc)
104 p.add_argument(
"-a",
"--angle", dest=
"angle", type=float, default=5,
105 help=
"angle delta (degrees) for FFT rotational "
106 "search (default 5)")
108 p.add_argument(
"-n",
"--num", dest=
"num", type=int, default=100,
109 help=
"Number of fits to report (default 100)")
111 p.add_argument(
"-v",
"--angle_voxel", dest=
"angle_voxel", type=int,
113 help=
"Number of angles to keep per voxel (default 10)")
115 p.add_argument(
"-t",
"--max_trans", dest=
"max_trans", type=float,
117 help=
"maximum translational search in A (default 10)")
119 p.add_argument(
"-m",
"--max_angle", dest=
"max_angle", type=float,
121 help=
"maximum angular search in degrees (default 50)")
122 p.add_argument(
"assembly_file", help=
"assembly file name")
123 p.add_argument(
"ref_assembly_file", help=
"refined assembly file name")
124 p.add_argument(
"proteomics_file", help=
"proteomics file name")
125 p.add_argument(
"mapping_file", help=
"mapping file name")
126 p.add_argument(
"combinations_file", help=
"combinations file name")
127 p.add_argument(
"combination_index", type=int,
128 help=
"number of the combination to read from the "
130 return p.parse_args()
146 asmb_input.set_was_used(
True)
148 asmb_refined_input.set_was_used(
True)
153 ensmb.set_was_used(
True)
154 mhs = ensmb.get_molecules()
157 ensmb_ref.set_was_used(
True)
158 _ = ensmb_ref.get_molecules()
160 ensmb.load_combination(combs[comb_ind])
162 em_map = asmb_input.get_assembly_header().get_dens_fn()
164 spacing = asmb_input.get_assembly_header().get_spacing()
165 origin = asmb_input.get_assembly_header().get_origin()
167 rbs_ref = ensmb_ref.get_rigid_bodies()
168 rbs = ensmb.get_rigid_bodies()
170 for i, mh
in enumerate(mhs):
171 fits_fn = asmb_refined_input.get_component_header(
172 i).get_transformations_fn()
178 initial_transformation = \
180 rb_ref.get_reference_frame(), rb.get_reference_frame())
182 pdb_fn = asmb_input.get_component_header(i).get_filename()
184 f = Fitter(em_map, spacing, resolution, origin,
185 asmb_input.get_assembly_header().get_threshold(), pdb_fn,
186 fits_fn, options.angle, options.num, options.angle_voxel,
187 options.max_trans, options.max_angle)
188 f.run_local_fitting(mh, rb, initial_transformation)
193 run(args.assembly_file, args.ref_assembly_file, args.proteomics_file,
194 args.mapping_file, args.combinations_file, args.combination_index,
198 if __name__ ==
"__main__":
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)
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
double get_rmsd(const Selection &s0, const Selection &s1)
void transform(Hierarchy h, const algebra::Transformation3D &tr)
Transform a hierarchy. This is aware of rigid bodies.
Ensemble * load_ensemble(multifit::SettingsData *sd, Model *mdl, const ProteinsAnchorsSamplingSpace &mapping_data)
Fitting atomic structures into a cryo-electron microscopy density map.
Basic utilities for handling cryo-electron microscopy 3D density maps.
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.
def __init__
input a list of particles, the slope and theta of the sigmoid potential theta is the cutoff distance ...
IntsList read_paths(const char *txt_filename, int max_paths=INT_MAX)
Read paths.
double get_resolution(Model *m, ParticleIndex pi)
Estimate the resolution of the hierarchy as used by Representation.
Functionality for loading, creating, manipulating and scoring atomic structures.