/** * \file CnSymmAxisDetector.cpp * \brief Detect cn symmetry in proteins and density maps. * * Copyright 2007-2013 IMP Inventors. All rights reserved. * */ #include #include #include #include #include #include #include IMPCNMULTIFIT_BEGIN_NAMESPACE CnSymmAxisDetector::CnSymmAxisDetector(int symm_deg, em::DensityMap *dmap, float density_threshold, float top_p) : dmap_(dmap), symm_deg_(symm_deg) { statistics::Histogram hist = my_get_density_histogram(dmap_,density_threshold,100); double top_p_den_val = hist.get_top(top_p); vecs_ = em::density2vectors(dmap_,top_p_den_val); // std::cout<<"Taking "<resample(); sampled_dmap->calcRMS(); dmap_=new em::DensityMap(*(sampled_dmap->get_header())); dmap_->copy_map(sampled_dmap); statistics::Histogram hist = my_get_density_histogram(dmap_,dmap_->get_header()->dmin,100); double top_20_den_val = hist.get_top(0.8); vecs_ = em::density2vectors(dmap_,top_20_den_val); //calculate pca pca_= algebra::get_principal_components(vecs_); //calculate transformation from the native axes system to the one //defined by the pca from_native_ = algebra::get_rotation_from_x_y_axes( pca_.get_principal_component(0), pca_.get_principal_component(1)); to_native_ = from_native_.get_inverse(); sampled_dmap=nullptr; } int CnSymmAxisDetector::get_symmetry_axis_index() const { int symm_ind=0; float symm_s,tmp_s; symm_s=calc_symm_score(0); tmp_s=calc_symm_score(1); if(tmp_s dens_vals; for(int symm=0;symmis_part_of_volume(location)) { dens_vals.push_back(dmap_->get_value(location)); } } if (((int)dens_vals.size()) != symm_deg_) { continue; } //average float avg_density = std::accumulate(dens_vals.begin(),dens_vals.end(),0.)/ dens_vals.size(); //variance float var=0.0; for(unsigned int i=0; i sqrt(var))? sqrt(var) : min_std; max_std=(max_std < sqrt(var))? sqrt(var) : max_std; }//finish going over the particles avg_std/=avg_std_count; IMP_LOG_TERSE("In symmetry axis voting:"<get_value(p); p = symm_op.get_transformed(p); } return val/symm_deg_; } IMPCNMULTIFIT_END_NAMESPACE