/** * \file single_prot_fft_fit.cpp * \brief Fit a single protein to a density map * * Copyright 2007-2013 IMP Inventors. All rights reserved. **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace IMP; namespace po = boost::program_options; bool parse_input(int argc, char *argv[], std::string &density_filename, float &spacing, float &x_origin,float &y_origin,float &z_origin, float &resolution, double &delta_angle, double &max_angle, double &max_trans, float &threshold, std::string &protein_filename, std::string &ref_filename, std::string &sol_filename, std::string &log_filename, std::string &pdb_fit_filename, std::string &angles_filename, int &num_top_fits_to_report, int &num_top_fits_to_store_for_each_rotation, bool &cluster_on, int &num_angle_per_voxel, double &max_clustering_translation, double &max_clustering_angle, bool &local_fitting); namespace { em::DensityMap* set_map(const std::string &density_filename, float resolution, float spacing, float &x_origin, float &y_origin, float &z_origin) { em::DensityMap* rmap=nullptr; try{ rmap = em::read_map(density_filename.c_str()); } catch (const Exception &err){ std::cerr<<"Problem reading density map:"<get_header_writable()->set_resolution(resolution); rmap->update_voxel_size(spacing); algebra::Vector3D v = rmap->get_origin(); if (x_origin == INT_MAX) { x_origin = v[0]; } if (y_origin == INT_MAX) { y_origin = v[1]; } if (z_origin == INT_MAX) { z_origin = v[2]; } rmap->set_origin(x_origin, y_origin, z_origin); return rmap; } } int main(int argc, char **argv) { std::string density_filename,protein_filename; std::string ref_filename,sol_filename,log_filename; std::string pdb_fit_filename,angles_filename; float spacing, x_origin,y_origin,z_origin,resolution,threshold; double delta_angle,max_angle,max_trans; int num_top_fits_to_report; int num_top_fits_to_store_for_each_rotation; bool cluster_on; int num_angle_per_voxel; double max_clustering_translation, max_clustering_angle; bool local_fitting; if (!parse_input(argc, argv,density_filename, spacing, x_origin,y_origin,z_origin, resolution, delta_angle, max_angle,max_trans,threshold,protein_filename, ref_filename, sol_filename, log_filename, pdb_fit_filename, angles_filename, num_top_fits_to_report, num_top_fits_to_store_for_each_rotation,cluster_on, num_angle_per_voxel, max_clustering_translation, max_clustering_angle, local_fitting)) { std::cerr<<"Wrong input data"< dmap = set_map(density_filename,resolution,spacing,x_origin,y_origin,z_origin); // Pointer dmap = em::read_map(density_filename.c_str()); //dmap->get_header_writable()->set_resolution(resolution); dmap->set_was_used(true); //write parameters std::cout<<"============= parameters ============"<show(); std::cout<<"====================================="< fits; if (!local_fitting) { std::cout<<"running global fitting"<do_global_fitting(dmap,threshold,mol2fit,1.*delta_angle/180*PI, num_top_fits_to_report, max_clustering_translation, max_clustering_angle, cluster_on, num_angle_per_voxel,angles_filename); } else { std::cout<<"running local fitting"<do_local_fitting(dmap,threshold,mol2fit,1.*delta_angle/180*PI, 1.*max_angle/180*PI,max_trans, num_top_fits_to_report, cluster_on, num_angle_per_voxel, max_clustering_translation, max_clustering_angle, angles_filename); } //read the reference if provided (for debugging) atom::Hierarchy ref_mh; core::XYZs ref_mh_xyz; if (ref_filename != "") { ref_mh = atom::read_pdb(ref_filename,mdl); ref_mh_xyz = core::XYZs(core::get_leaves(ref_mh)); } //write out all solutions multifit::FittingSolutionRecords final_fits=fits->best_fits_; //if required write the fits as individual pdbs if (pdb_fit_filename != "") { for(unsigned int i=0;ibest_trans_per_rot_); std::cout<<"all done!"<(&density_filename), "complex density filename") ("apix",po::value(&spacing), "the a/pix of the density map") ("res",po::value(&resolution), "the resolution of the density map") ("threshold",po::value(&threshold), "do not consider voxles with value below this value") ("protein",po::value(&protein_filename), "a PDB file of the first protein"); std::stringstream help_message; help_message << "single_prot_fft_fit is a program for fitting a protein"; help_message<<" into a density map based on a FFT search."; help_message<<" The fitting solutions are scored based"; help_message<<" on cross-correlation between the protein and the map."; help_message<<"\n\nUsage: single_prot_fft_fit"; help_message<< " "; help_message<<" \n\n"; optional_params.add_options() ("help",help_message.str().c_str()) ("x",po::value(&x_origin), "the X origin of the density map") ("y",po::value(&y_origin), "the Y origin of the density map") ("z",po::value(&z_origin), "the Z origin of the density map") ("ref",po::value(&ref_filename), "a PDB file of the protein fitted to the density map (for testing)") ("output",po::value(&sol_filename), " The default file is multifit.solutions.txt") ("sol",po::value(&pdb_fit_filename), "Solutions will be printed in PDB format and named _i.pdb") ("n-hits",po::value(&num_top_fits_to_report), "Number of best fits to report (default is 100)") ("n-angle-hits",po::value (&num_top_fits_to_store_for_each_rotation), "Number of best fits to store for each angle (default is 50)") ("angle",po::value(&delta_angle), "angle step to sample") ("max-angle",po::value(&max_angle), "max angle to sample") ("max-translation",po::value(&max_trans), "max translation to sample") ("cluster-max-translation",po::value(&max_clustering_translation), "max translation within a cluster (default is 5A)") ("cluster-max-angle",po::value(&max_clustering_angle), "max rotational angle within a cluster (default is 20)") ("log-filename",po::value(&log_filename), "write log messages here") ("cluster-off",po::value(&cluster_off_ind), "if set the clustering is off") ("num-angle-voxel",po::value(&num_angle_per_voxel), "number of angles per voxel") ("angles-filename",po::value(&angles_filename), "phi|theta|psi angles to sample in degrees"); po::positional_options_description p; p.add("density", 1); p.add("apix", 1); p.add("res", 1); p.add("threshold",1); p.add("protein", 1); po::options_description all; all.add(optional_params).add(required_params); po::variables_map vm; po::store( po::command_line_parser(argc, argv).options(all).positional(p).run(),vm); po::notify(vm); if (vm.count("help")) { std::cout << optional_params << "\n"; return false; } if (! ( vm.count("density")+vm.count("apix")+ vm.count("res")+vm.count("threshold")+vm.count("protein") == 5)){ std::cout<