Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConservedPosMutationFilter.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/filters/ConservedPosMutationFilter.cc
11 /// @author Florian Richter (floric@u.washington.edu), may 2011
12 
13 // Unit Headers
16 
17 // Package Headers
19 
20 // Project Headers
21 #include <basic/Tracer.hh>
22 
23 #include <core/chemical/AA.hh>
25 #include <core/pose/Pose.hh>
27 #include <core/types.hh>
28 
29 // AUTO-REMOVED #include <protocols/moves/DataMap.hh>
30 
31 // Utility headers
32 #include <utility/string_util.hh>
33 #include <utility/tag/Tag.hh>
34 
35 #include <utility/vector0.hh>
36 #include <utility/vector1.hh>
37 
38 
39 //// C++ headers
40 static basic::Tracer tr("protocols.simple_filters.ConservedPosMutationFilter");
41 
42 namespace protocols {
43 namespace simple_filters {
44 
45 
47  parent("ConservedPosMutationFilter"),
48  conserved_pos_taskop_(new toolbox::task_operations::RestrictConservedLowDdgOperation()),
49  max_allowed_conserved_pos_mutations_(0)
50 {
51 }
52 
54 
57  return new ConservedPosMutationFilter( *this ); }
58 
61  return new ConservedPosMutationFilter(); }
62 
63 
64 bool
66 
67  core::Size conserved_pos_mutations(0);
68  bool verbose( conserved_pos_taskop_->verbose() );
69  std::string mutstring;
70 
71  for( core::Size i(1); i <= pose.total_residue(); ++i){
72  if( !pose.residue_type(i).is_protein() ) continue;
73 
74  core::chemical::AA wt_aa( conserved_pos_taskop_->seqprof_wt_aa(i) );
75  if( conserved_pos_taskop_->position_untouchable(i, wt_aa) && (wt_aa != pose.residue_type(i).aa() ) ){
76  conserved_pos_mutations++;
77  if( !verbose && (conserved_pos_mutations > max_allowed_conserved_pos_mutations_)){
78  tr << "Pose has at least " << conserved_pos_mutations << " mutations at conserved positions, but only " << max_allowed_conserved_pos_mutations_ << " are allowed, returnig false..." << std::endl;
79  return false;
80  }
81  else if (verbose ){
82  using namespace core::chemical;
83  mutstring = mutstring + oneletter_code_from_aa( wt_aa ) + utility::to_string( i ) + oneletter_code_from_aa( pose.residue_type(i).aa() ) + ", ";
84  }
85  }
86  //if the user is interested, we'll write out the conservation and ddg info for every mutation
87  if( verbose && (wt_aa != pose.residue_type(i).aa() ) ){
88  tr << "Mutation at pos " << i << " with ala_ddg of " << conserved_pos_taskop_->position_ala_ddG( i ) << " and wt conservation " << conserved_pos_taskop_->seqprof()->profile()[ i ][ conserved_pos_taskop_->seqprof_wt_aa(i) ] << std::endl;
89  }
90  }
91  if( verbose ) tr << "Forbidden mutations detected: " << mutstring << std::endl;
92  if( conserved_pos_mutations > max_allowed_conserved_pos_mutations_){
93  tr << "Pose has " << conserved_pos_mutations << " mutations at conserved positions, but only " << max_allowed_conserved_pos_mutations_ << " are allowed, returnig false..." << std::endl;
94  return false;
95  }
96 
97  tr << "Pose has " << conserved_pos_mutations << " mutations at conserved positions, <= than the allowed value of " << max_allowed_conserved_pos_mutations_ << ", returnig true..." << std::endl;
98  return true;
99 } // apply
100 
101 
102 void
104 {
105  conserved_pos_taskop_->parse_tag( tag );
106 
107  if (tag->hasOption("max_conserved_pos_mutations")) {
108  max_allowed_conserved_pos_mutations_ = tag->getOption<core::Size>("max_conserved_pos_mutations");
109  }
110 }
111 
112 
115 
117 ConservedPosMutationFilterCreator::keyname() const { return "ConservedPosMutationFilter"; }
118 
119 
120 
121 } // filters
122 } // protocols