Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SequenceCoupling1BDConstraint.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 core/scoring/constraints/SequenceCoupling1BDConstraint.cc
11 /// @brief This is a constraint that refers to a core::sequence::SequenceProfile? in order to influence the scoring of amino acid types based on multiple sequence alignments (i.e. for biasing amino acid choices during design). A note about the SequenceProfile::read_from_checkpoint function that is used to read in scores for amino acid types: the first line of the file will be ignored.
12 /// @author ashworth
13 
15 
18 #include <core/pose/Pose.hh>
19 
21 
22 #include <basic/Tracer.hh>
23 
24 #include <utility/file/file_sys_util.hh> // file_exists, create_directory
25 
26 // AUTO-REMOVED #include <basic/options/option.hh>
27 // option key includes
28 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
29 
30 //Auto Headers
34 #include <utility/vector1.hh>
35 #include <basic/options/keys/OptionKeys.hh>
36 
37 
38 namespace protocols {
39 namespace constraints_additional {
40 
41 using namespace core;
42 using namespace chemical;
43 using namespace conformation;
44 using namespace basic::options;
45 using namespace scoring;
46 using namespace constraints;
47 using namespace sequence;
48 
49 using basic::t_warning;
50 using basic::t_info;
51 using basic::t_debug;
52 using basic::t_trace;
53 static basic::Tracer TR("protocols.constraints_additional.SequenceCoupling1BDConstraint");
54 
56  :core::scoring::constraints::SequenceProfileConstraint( )
57 {}
58 
60  Pose const & pose,
61  core::Size numpos,
62  SequenceProfileCOP profile
63  ):core::scoring::constraints::SequenceProfileConstraint(pose, numpos,profile)
64 {}
65 
67  core::Size numpos,
68  SequenceProfileCOP profile
69  ):core::scoring::constraints::SequenceProfileConstraint(numpos, profile)
70 {}
72 
75  return new SequenceCoupling1BDConstraint( *this );
76 }
77 
78 ///@details one line definition "SequenceProfile resindex profilefilename" (profilefilename can also be set to "none" in the constraints file, and specified by -in::file::pssm)
79 void
81  std::istream & is,
82  Pose const & pose,
83  FuncFactory const &
84 )
85 {
86  Size residue_index(0);
87  std::string profile_filename;
88 
89 // note: is >> "SequenceProfile" has already occured
90  is >> residue_index >> profile_filename;
91 
92  TR(t_debug) << "reading: " << residue_index << " " << profile_filename << std::endl;
93  if ( residue_index < 1 || residue_index > pose.total_residue() ) {
94  std::cerr << "no such residue index " << residue_index << " in pose!)" << std::endl;
95  utility_exit();
96  }
97 
98  seqpos(residue_index);
99 
100  // figure out sequence profile filename
101  using namespace utility::file;
102  // if specified, verify file exists
103  if ( profile_filename != "none" ) {
104  if ( ! file_exists( profile_filename ) ) {
105  utility_exit_with_message( "no such file " + profile_filename );
106  }
107  // if filename not specified, load from commandline option -pssm only if sequence_profile_ is NULL
108  } else {
109  utility_exit_with_message("\"none\" is not a valid value for -pssm in this context!");
110  }
111 
112  // if filename is not "none" by this point, read it even if sequence_profile_ is not currently NULL
113  if ( profile_filename != "none" ) {
115  c->read_from_file( FileName(profile_filename) );
117  }
118 
119  // if sequence_profile_ is still NULL by this point, it is assumed that the user intended so
120 
121 } // read_def
122 
123 void
124 SequenceCoupling1BDConstraint::show( std::ostream & os ) const {
125  os << "SequenceCoupling1BD Constraint at seqpos " << seqpos() << ": ";
126  if ( ! sequence_profile() ) os << "(uninitialized sequence profile)";
127  os << '\n';
128 }
129 
130 // Calculates a score for this constraint using XYZ_Func, and puts the UNWEIGHTED score into
131 // emap. Although the current set of weights currently is provided, Constraint objects
132 // should put unweighted scores into emap.
133 void
135  XYZ_Func const & xyz_func,
136  EnergyMap const & weights,
137  EnergyMap & emap
138 ) const
139 {
140  if ( weights[ this->score_type() ] == 0 ) return; // what's the point?
141  runtime_assert( sequence_profile() );
142 
143  chemical::AA aa( xyz_func.residue( seqpos()).type().aa() );
144  utility::vector1< utility::vector1< Real > > const & profile( sequence_profile()->profile() );
145 
146  if ( seqpos() > profile.size() ) return; // safety/relevance check
147  utility::vector1< Real > const & position_profile( profile[ seqpos() ] );
148  if ( size_t(aa) > position_profile.size() ) return; // safety/relevance check
149  Real const score( profile[seqpos()][aa] );
150  TR(t_trace) << "seqpos " << seqpos() << " aa " << aa << " " << score << std::endl;
151  emap[ this->score_type() ] += score;
152 }
153 
154 void
156  AtomID const & ,//atom,
157  XYZ_Func const & ,//conformation,
158  Vector & ,//f1,
159  Vector & ,//f2,
160  EnergyMap const & //weights
161 ) const
162 {
163  // Do nothing, as the value of this function doesn't change with respect to
164  // the torsions.
165 }
166 
167 } // namespace constraints_additional
168 } // namespace protocols