/** * \file symmetric_multifit.cpp \brief Build cyclic symmetric complexes. * * Copyright 2007-2013 IMP Inventors. All rights reserved. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include IMPCNMULTIFIT_BEGIN_NAMESPACE namespace { void write_in_symmref_format(const multifit::FittingSolutionRecords &recs, std::string output_filename){ std::ofstream out(output_filename.c_str()); out.setf(std::ios::fixed, std::ios::floatfield); out.setf(std::ios::right, std::ios::adjustfield); out.precision(2); for (unsigned int i=0; i < recs.size(); i++) { out.width(4); algebra::Transformation3D transform = recs[i].get_dock_transformation(); algebra::Rotation3D r = transform.get_rotation(); algebra::Vector3D tr = transform.get_translation(); algebra::FixedXYZ eulers = algebra::get_fixed_xyz_from_rotation(r); out << i << " " << eulers.get_x() << " " << eulers.get_y() << " " << eulers.get_z() << " " << tr[0] << " " << tr[1] << " " << tr[2] << std::endl; } out.close(); } void write_in_chimera_format(const multifit::FittingSolutionRecords &recs, std::string output_filename){ std::ofstream out(output_filename.c_str()); out.setf(std::ios::fixed, std::ios::floatfield); out.setf(std::ios::right, std::ios::adjustfield); out.precision(5); for (unsigned int i=0; i < recs.size(); i++) { out.width(10); out << i << "|"; algebra::Rotation3D rot=recs[i].get_dock_transformation().get_rotation(); algebra::Vector3D trans=recs[i].get_dock_transformation().get_translation(); for(int j=0;j<3;j++) { algebra::Vector3D v = rot.get_rotation_matrix_row(j); out< v = t.get_rotation().get_quaternion(); return (std::abs(v.get_squared_magnitude() - 1.0) < .1); } multifit::FittingSolutionRecords build_symmetric_assemblies( const internal::Parameters ¶meters) { parameters.getAlgParams().densityParams.show(); const TAU::AlgParams& params = parameters.getAlgParams(); TAU::SymmAssembly symm_asmb; symm_asmb.setup(params); // Unfortunately SymmAssembly reads this parameter from the global TAU store, // not from the params instance passed above, so set globally here: TAU::Parameters::addParameter("surfacePruneThreshold", parameters.get_surface_threshold()); std::vector all_results = symm_asmb.run(); multifit::FittingSolutionRecords fit_recs; for(unsigned int i=0;iget_header()->get_resolution()>20) sample_translation=true; em::FittingSolutions asmb_fits = fit_cn_assembly( mhs, dn_symm_deg, dmap, 1., aligner, sample_translation, fine_rotational_sampling); multifit::FittingSolutionRecord r_sol = recs[i]; // std::cout<<"For model "< dmap = em::read_map(density_filename, new em::MRCReaderWriter()); dmap->get_header_writable()->set_resolution(resolution); dmap->update_voxel_size(spacing); algebra::Vector3D v = dmap->get_origin(); dmap->set_origin(origin[0], origin[1], origin[2]); CnSymmAxisDetector symm_map(cn_symm_deg, dmap, dens_threshold, 0.0); params.set_density_non_symm_axis_length( symm_map.get_non_symmetry_axis_length()* symm_map.get_non_symmetry_axis_length()/4); //generate the assemblies std::cout<<"======= Sampling symmetric assemblies"<show(); std::stringstream ss; ss<get_dock_transformation()); for(unsigned int j=0;jget_fit_transformation()); } atom::write_pdb(mhs,ss.str()); for(unsigned int j=0;jget_fit_transformation().get_inverse()); } it->set_solution_filename(ss.str()); transform_cn_assembly(mhs, it->get_dock_transformation().get_inverse()); } multifit::write_fitting_solutions(output_filename.c_str(),fitted_recs); write_in_symmref_format(fitted_recs, symm_ref_output); if (chimera_filename != "") { write_in_chimera_format(fitted_recs, chimera_filename); } } IMPCNMULTIFIT_END_NAMESPACE