3 __doc__ =
"Fit subunits into a density map with FFT."
9 from IMP
import OptionParser
13 multiproc_exception =
None
15 from multiprocessing
import Pool
19 if sys.platform ==
'win32' and 'WINELOADERNOEXEC' in os.environ:
20 multiproc_exception =
"Wine does not currently support multiprocessing"
21 except ImportError
as detail:
22 multiproc_exception = str(detail)
41 self.spacing = spacing
42 self.resolution = resolution
43 self.threshold = density_threshold
44 self.originx = origin[0]
45 self.originy = origin[1]
46 self.originz = origin[2]
48 self.fits_fn = fits_fn
50 self.num_fits = num_fits
51 self.angles_per_voxel = angles_per_voxel
52 self.ref_pdb = ref_pdb
55 print "resolution is:", self.resolution
57 dmap.get_header().set_resolution(self.resolution)
58 dmap.update_voxel_size(self.spacing)
62 dmap.set_was_used(
True)
63 dmap.get_header().
show()
70 fits = ff.do_global_fitting(dmap, self.threshold, mol2fit,
71 self.angle / 180.0 * math.pi,
72 self.num_fits, self.spacing, 0.5,
73 True, self.angles_per_voxel)
74 fits.set_was_used(
True)
75 final_fits = fits.best_fits_
76 if self.ref_pdb !=
'':
80 for i, fit
in enumerate(final_fits):
82 if self.ref_pdb !=
'':
83 trans = fit.get_fit_transformation()
89 fit.set_rmsd_to_reference(rmsd)
91 if self.ref_pdb !=
'':
92 print 'from all fits, lowest rmsd to ref:', cur_low
101 usage =
"""%prog [options] <assembly input>
103 Fit subunits into a density map with FFT."""
105 parser.add_option(
"-c",
"--cpu", dest=
"cpus", type=
"int", default=1,
106 help=
"number of cpus to use (default 1)")
107 parser.add_option(
"-a",
"--angle", dest=
"angle", type=
"float",
109 help=
"angle delta (degrees) for FFT rotational "
110 "search (default 30)")
112 parser.add_option(
"-n",
"--num", dest=
"num", type=
"int",
114 help=
"Number of fits to report"
117 parser.add_option(
"-v",
"--angle_voxel", dest=
"angle_voxel", type=
"int",
119 help=
"Number of angles to keep per voxel"
127 options, args = parser.parse_args()
129 parser.error(
"incorrect number of arguments")
133 def run(asmb_fn, options):
134 if multiproc_exception
is None and options.cpus > 1:
137 asmb_input.set_was_used(
True)
138 em_map = asmb_input.get_assembly_header().get_dens_fn()
140 spacing = asmb_input.get_assembly_header().get_spacing()
141 origin = asmb_input.get_assembly_header().get_origin()
142 for i
in range(asmb_input.get_number_of_component_headers()):
143 fits_fn = asmb_input.get_component_header(i).get_transformations_fn()
144 pdb_fn = asmb_input.get_component_header(i).get_filename()
150 asmb_input.get_assembly_header().get_threshold(),
156 if multiproc_exception
is None and options.cpus > 1:
161 print >> sys.stderr,
"""
162 The Python 'multiprocessing' module (available in Python 2.6 and later) is
163 needed to run on multiple CPUs, and could not be found
164 (Python error: '%s').
165 Running on a single processor.""" % multiproc_exception
167 if multiproc_exception
is None and options.cpus > 1:
169 nproc = min(options.cpus, asmb_input.get_number_of_component_headers())
170 p = Pool(processes=nproc)
171 out = list(p.imap_unordered(do_work, work_units))
175 options, args = parse_args()
177 run(asmb_input, options)
179 if __name__ ==
"__main__":
double get_resolution(kernel::Model *m, kernel::ParticleIndex pi)
Fit a molecule inside its density by local or global FFT.
double get_rmsd(const core::XYZs &s0, const core::XYZs &s1, const IMP::algebra::Transformation3D &tr_for_second)
SettingsData * read_settings(const char *filename)
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
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.
DensityMap * read_map(std::string filename)
Read a density map from a file and return it.
IMP::kernel::OptionParser OptionParser
void show(Hierarchy h, std::ostream &out=std::cout)
Print out a molecular hierarchy.
IMP::core::RigidBody create_rigid_body(Hierarchy h)
Functionality for loading, creating, manipulating and scoring atomic structures.
void read_pdb(base::TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.