Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NMerPSSMEnergyFilter.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/simple_filters/NMerPSSMEnergyFilter.cc
11 /// @brief
12 /// @author Chris King (chrisk1@uw.edu)
13 
14 
15 //Unit Headers
18 
19 //Project Headers
20 #include <basic/Tracer.hh>
26 #include <core/scoring/Energies.hh>
28 #include <core/pose/Pose.hh>
29 #include <utility/tag/Tag.hh>
31 #include <utility/exit.hh>
32 #include <ObjexxFCL/FArray1D.hh>
33 #include <ObjexxFCL/FArray1D.fwd.hh>
34 #include <ObjexxFCL/format.hh>
40 #include <utility/excn/Exceptions.hh>
41 #include <core/pose/selection.hh>
42 
43 namespace protocols{
44 namespace simple_filters {
45 
46 using namespace core;
47 using namespace core::scoring;
48 using namespace ObjexxFCL::fmt;
49 
50 static basic::Tracer TR( "protocols.simple_filters.NMerPSSMEnergyFilter" );
51 
54 
56 NMerPSSMEnergyFilterCreator::keyname() const { return "NMerPSSMEnergy"; }
57 
58 //default ctor
60 protocols::filters::Filter( "NMerPSSMEnergy" )
61 {}
62 
63 //full ctor, default ctor defined in header file
64 //TODO: allow setting energy_method_ funxns w/ input params (like in parse ctor)
66  core::Real const score_type_threshold,
67  std::string const string_resnums
68 ) :
69 protocols::filters::Filter( "NMerPSSMEnergy" )
70 {
71  score_type_threshold_ = score_type_threshold;
72  string_resnums_ = string_resnums;
73 }
74 
76 
77 void
79 {
80  if( ! tag->hasOption( "threshold" ) ) throw utility::excn::EXCN_RosettaScriptsOption("Must specify 'threshold' for NMerPSSMEnergyFilter.");
81  score_type_threshold_ = tag->getOption< core::Real >( "threshold" );
82 
83  if( tag->hasOption( "pssm_fname" ) ) energy_method_.read_nmer_pssm( tag->getOption< std::string >( "pssm_fname" ) );
84  if( tag->hasOption( "pssm_list_fname" ) ) energy_method_.read_nmer_pssm_list( tag->getOption< std::string >( "pssm_list_fname" ) );
85  //default blank string --> empty res_set_vec --> incl all residues
86  string_resnums_ = tag->getOption< std::string >( "resnums", "" );// these are kept in memory until the pose is available (at apply time)
87  energy_method_.nmer_length( tag->getOption< core::Size >( "nmer_length", 9 ) );
88  energy_method_.nmer_pssm_scorecut( tag->getOption< core::Real >( "nmer_pssm_scorecut", 0.0 ) );
89  energy_method_.gate_pssm_scores( tag->getOption< bool >( "gate_pssm_scores", false ) );
90 }
91 
92 bool
94  core::Real const score( compute( pose ) );
95  TR << "NMerPSSM score is " << score << ". ";
96  if( score <= score_type_threshold_ ) {
97  TR<<"passing." << std::endl;
98  return true;
99  }
100  else {
101  TR<<"failing."<<std::endl;
102  return false;
103  }
104 }
105 
106 void
107 NMerPSSMEnergyFilter::report( std::ostream & out, core::pose::Pose const & pose ) const {
108  out<<"NMerPSSM score of " << compute( pose )<<'\n';
109 }
110 
113  return( compute( pose ) );
114 }
115 
118  core::pose::Pose const & pose,
119  core::Size const seqpos
120 ) const {
121  assert( seqpos <= pose.total_residue() );
122  //TR<< "Calculating nmer_pssm energies at seqpos: " << seqpos << std::endl;
123  using namespace core::scoring;
124  EnergyMap emap; //we need to zero out the emap each time!
125  energy_method_.residue_energy( pose.residue( seqpos ), pose, emap );
126  return( emap[ nmer_pssm ] );
127 }
128 
131  core::pose::Pose const & pose
132 ) const {
133 
135 
136  // sum over all res pos
137  core::Real score( 0. );
138  if( res_set_vec.size() > 0 ){
139  for( core::Size i_res_vec = 1; i_res_vec <= res_set_vec.size(); ++i_res_vec ){
140  Size const seqpos( res_set_vec[ i_res_vec ] );
141  score += NMerPSSMEnergyFilter::compute_residue( pose, seqpos );
142  }
143  } else{
144  for( Size seqpos = 1; seqpos <= pose.total_residue(); ++seqpos ){
145  score += NMerPSSMEnergyFilter::compute_residue( pose, seqpos );
146  }
147  }
148  return( score );
149 }
150 
151 }
152 }