/** * \file m_rigid_fitting.cpp * \brief Fast Rigid fitting functionalities * * Copyright 2007-2010 IMP Inventors. All rights reserved. * */ #include #include #include #include #include #include #include #include #include #include IMPMULTIFIT_BEGIN_NAMESPACE /* em::FittingSolutions refine_fits( core::RigidBody &rb, Refiner *rb_refiner, em::DensityMap *em_map, const em::FittingSolutions &fits FloatKey rad_key = core::XYZR::get_default_radius_key(), `FloatKey wei_key = atom::Mass::get_mass_key()); */ em::FittingSolutions pca_based_rigid_fitting( core::RigidBody &rb, Refiner *rb_refiner, em::DensityMap *em_map, Float threshold, FloatKey rad_key, FloatKey wei_key, algebra::PrincipalComponentAnalysis dens_pca_input) { //find the pca of the density algebra::PrincipalComponentAnalysis dens_pca; if (dens_pca_input.is_initialized()){ dens_pca=dens_pca_input; } else{ algebra::Vector3Ds dens_vecs = em::density2vectors(*em_map,threshold); dens_pca = algebra::get_principal_components(dens_vecs); } //move the rigid body to the center of the map core::XYZsTemp ps_xyz = core::XYZsTemp(rb_refiner->get_refined(rb)); algebra::Transformation3D move2center_trans = algebra::Transformation3D( algebra::get_identity_rotation_3d(), dens_pca.get_centroid()-core::get_centroid(ps_xyz)); core::transform(rb,move2center_trans); //find the pca of the protein algebra::Vector3Ds ps_vecs; for (core::XYZsTemp::iterator it = ps_xyz.begin(); it != ps_xyz.end(); it++) { ps_vecs.push_back(it->get_coordinates()); } algebra::PrincipalComponentAnalysis ps_pca = algebra::get_principal_components(ps_vecs); IMP_IF_LOG(IMP::VERBOSE) { IMP_LOG(IMP::VERBOSE,"in pca_based_rigid_fitting, density PCA:"<