3 from __future__
import print_function
8 from IMP
import ArgumentParser
12 __doc__ =
"Fit subunits into a density map with FFT."
14 multiproc_exception =
None
16 from multiprocessing
import Pool
20 if sys.platform ==
'win32' and 'WINELOADERNOEXEC' in os.environ:
21 multiproc_exception =
"Wine does not currently support multiprocessing"
22 except ImportError
as detail:
23 multiproc_exception = str(detail)
42 self.spacing = spacing
43 self.resolution = resolution
44 self.threshold = density_threshold
45 self.originx = origin[0]
46 self.originy = origin[1]
47 self.originz = origin[2]
49 self.fits_fn = fits_fn
51 self.num_fits = num_fits
52 self.angles_per_voxel = angles_per_voxel
53 self.ref_pdb = ref_pdb
56 print(
"resolution is:", self.resolution)
57 dmap = IMP.em.read_map(self.em_map)
58 dmap.get_header().set_resolution(self.resolution)
59 dmap.update_voxel_size(self.spacing)
63 dmap.set_was_used(
True)
64 dmap.get_header().
show()
71 fits = ff.do_global_fitting(dmap, self.threshold, mol2fit,
72 self.angle / 180.0 * math.pi,
73 self.num_fits, self.spacing, 0.5,
74 True, self.angles_per_voxel)
75 fits.set_was_used(
True)
76 final_fits = fits.best_fits_
77 if self.ref_pdb !=
'':
81 for i, fit
in enumerate(final_fits):
83 if self.ref_pdb !=
'':
84 trans = fit.get_fit_transformation()
90 fit.set_rmsd_to_reference(rmsd)
92 if self.ref_pdb !=
'':
93 print(
'from all fits, lowest rmsd to ref:', cur_low)
102 desc =
"""Fit subunits into a density map with FFT."""
103 p = ArgumentParser(description=desc)
104 p.add_argument(
"-c",
"--cpu", dest=
"cpus", type=int, default=1,
105 help=
"number of cpus to use (default 1)")
106 p.add_argument(
"-a",
"--angle", dest=
"angle", type=float, default=30,
107 help=
"angle delta (degrees) for FFT rotational "
108 "search (default 30)")
110 p.add_argument(
"-n",
"--num", dest=
"num", type=int,
111 default=100, help=
"Number of fits to report (default 100)")
113 p.add_argument(
"-v",
"--angle_voxel", dest=
"angle_voxel", type=int,
115 help=
"Number of angles to keep per voxel (default 10)")
117 p.add_argument(
"assembly_file", help=
"assembly file name")
124 return p.parse_args()
127 def run(asmb_fn, options):
128 if multiproc_exception
is None and options.cpus > 1:
131 asmb_input.set_was_used(
True)
132 em_map = asmb_input.get_assembly_header().get_dens_fn()
134 spacing = asmb_input.get_assembly_header().get_spacing()
135 origin = asmb_input.get_assembly_header().get_origin()
136 for i
in range(asmb_input.get_number_of_component_headers()):
137 fits_fn = asmb_input.get_component_header(i).get_transformations_fn()
138 pdb_fn = asmb_input.get_component_header(i).get_filename()
144 asmb_input.get_assembly_header().get_threshold(),
150 if multiproc_exception
is None and options.cpus > 1:
156 The Python 'multiprocessing' module (available in Python 2.6 and later) is
157 needed to run on multiple CPUs, and could not be found
158 (Python error: '%s').
159 Running on a single processor.""" % multiproc_exception, file=sys.stderr)
161 if multiproc_exception
is None and options.cpus > 1:
163 nproc = min(options.cpus, asmb_input.get_number_of_component_headers())
164 p = Pool(processes=nproc)
165 out = list(p.imap_unordered(do_work, work_units))
170 run(args.assembly_file, args)
172 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.
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.
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.
std::ostream & show(Hierarchy h, std::ostream &out=std::cout)
Print the hierarchy using a given decorator to display each node.
IMP::core::RigidBody create_rigid_body(Hierarchy h)
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.