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, detail:
22 multiproc_exception = str(detail)
25 def __init__(self, em_map, spacing, resolution, origin, density_threshold,pdb, fits_fn, angle,num_fits,angles_per_voxel,ref_pdb=''):
27 self.spacing = spacing
28 self.resolution = resolution
29 self.threshold=density_threshold
30 self.originx = origin[0]
31 self.originy = origin[1]
32 self.originz = origin[2]
34 self.fits_fn = fits_fn
36 self.num_fits=num_fits
37 self.angles_per_voxel=angles_per_voxel
40 print "resolution is:",self.resolution
42 dmap.get_header().set_resolution(self.resolution)
43 dmap.update_voxel_size(self.spacing)
47 dmap.set_was_used(
True)
48 dmap.get_header().
show()
55 fits = ff.do_global_fitting(dmap, self.threshold,mol2fit,
56 self.angle / 180.0 * math.pi,
57 self.num_fits, self.spacing, 0.5,
58 True, self.angles_per_voxel)
59 fits.set_was_used(
True)
60 final_fits = fits.best_fits_
65 for i, fit
in enumerate(final_fits):
68 trans=fit.get_fit_transformation()
74 fit.set_rmsd_to_reference(rmsd)
77 print 'from all fits, lowest rmsd to ref:',cur_low
84 usage =
"""%prog [options] <assembly input>
86 Fit subunits into a density map with FFT."""
88 parser.add_option(
"-c",
"--cpu", dest=
"cpus", type=
"int", default=1,
89 help=
"number of cpus to use (default 1)")
90 parser.add_option(
"-a",
"--angle", dest=
"angle", type=
"float",
92 help=
"angle delta (degrees) for FFT rotational "
93 "search (default 30)")
95 parser.add_option(
"-n",
"--num", dest=
"num", type=
"int",
97 help=
"Number of fits to report"
100 parser.add_option(
"-v",
"--angle_voxel", dest=
"angle_voxel", type=
"int",
102 help=
"Number of angles to keep per voxel"
110 options, args = parser.parse_args()
112 parser.error(
"incorrect number of arguments")
115 def run(asmb_fn, options):
116 if multiproc_exception
is None and options.cpus > 1:
119 asmb_input.set_was_used(
True)
120 em_map=asmb_input.get_assembly_header().get_dens_fn()
121 resolution=asmb_input.get_assembly_header().get_resolution()
122 spacing=asmb_input.get_assembly_header().get_spacing()
123 origin=asmb_input.get_assembly_header().get_origin()
124 for i
in range(asmb_input.get_number_of_component_headers()):
125 fits_fn=asmb_input.get_component_header(i).get_transformations_fn()
126 pdb_fn=asmb_input.get_component_header(i).get_filename()
127 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)
128 if multiproc_exception
is None and options.cpus > 1:
133 print >> sys.stderr,
"""
134 The Python 'multiprocessing' module (available in Python 2.6 and later) is
135 needed to run on multiple CPUs, and could not be found
136 (Python error: '%s').
137 Running on a single processor.""" % multiproc_exception
139 if multiproc_exception
is None and options.cpus > 1:
141 nproc = min(options.cpus, asmb_input.get_number_of_component_headers())
142 p = Pool(processes=nproc)
143 out = list(p.imap_unordered(do_work, work_units))
146 options,args = parse_args()
148 run(asmb_input, options)
150 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.
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)
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)
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)
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.