/** * \file atom/SecondaryStructureResidue.cpp * \brief A decorator for storing secondary structure probabilities. * Copyright 2007-2013 IMP Inventors. All rights reserved. * */ #include #include IMPATOM_BEGIN_NAMESPACE FloatKey SecondaryStructureResidue::get_prob_helix_key(){ static FloatKey k("prob_helix"); return k; } FloatKey SecondaryStructureResidue::get_prob_strand_key(){ static FloatKey k("prob_strand"); return k; } FloatKey SecondaryStructureResidue::get_prob_coil_key(){ static FloatKey k("prob_coil"); return k; } void SecondaryStructureResidue::show(std::ostream &out) const { out << "SecondaryStructureResidue with:\n" <<"prob helix: "<max){ max=tmp_scores[i]; max_i=i; } if (!winner_takes_all_per_res) scores[i]+=tmp_scores[i]; } if (winner_takes_all_per_res) scores[max_i]+=1.0; count++; } IMP_NEW(Particle,coarse_p,(mdl)); SecondaryStructureResidue ssres= SecondaryStructureResidue::setup_particle(coarse_p, scores[0]/count, scores[1]/count, scores[2]/count); return ssres; } SecondaryStructureResidues setup_coarse_secondary_structure_residues( const Particles &ssr_ps, Model *mdl, int coarse_factor, int start_res_num, bool winner_takes_all_per_res){ /* We're presuming that the coarsening starts from 0. So if start_res_num%coarse_factor=coarse_factor/2, this set starts with the minority of a node, so we ignore the first few particles. Same thing for the end! If has a little tail, ignore last few residues. */ SecondaryStructureResidues ssrs; int start_idx=0,stop_idx=(int)ssr_ps.size(); if (start_res_num%coarse_factor>=float(coarse_factor)/2){ start_idx=coarse_factor-start_res_num%coarse_factor; } if ((stop_idx+start_res_num)%coarse_factor0) { ssrs.push_back(setup_coarse_secondary_structure_residue( tmp_ps,mdl,winner_takes_all_per_res)); } return ssrs; } Float get_secondary_structure_match_score(SecondaryStructureResidue ssr1, SecondaryStructureResidue ssr2){ Floats f1=ssr1.get_all_probabilities(); Floats f2=ssr2.get_all_probabilities(); Float rmsd=0.0; for (int i=0;i<3;i++){ rmsd+=(f1[i]-f2[i])*(f1[i]-f2[i]); } return std::sqrt(rmsd); } IMPATOM_END_NAMESPACE