Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ResidueTypeLinkingConstraint.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/ResidueTypeLinkingConstraint.cc
11 ///
12 /// @brief
13 /// @author Sarel Fleishman
14 
15 
17 
20 #include <basic/Tracer.hh>
21 
22 #include <core/kinematics/Jump.hh>
23 #include <core/pose/Pose.hh>
26 #include <utility/vector1.hh>
27 
28 
29 namespace core {
30 namespace scoring {
31 namespace constraints {
32 
33 
34 static basic::Tracer TR("core.scoring.constraints.ResidueTypeLinkingConstraint");
35 
37  Constraint( core::scoring::res_type_linking_constraint )
38 
39 {}
40 
42  core::pose::Pose const & pose,
43  Size seqpos1,
44  Size seqpos2,
45  core::Real bonus
46 ):
47  Constraint( core::scoring::res_type_linking_constraint ),
48 
49  seqpos1_( seqpos1 ),
50  seqpos2_( seqpos2 ),
51  rsd1_type_name3_( pose.residue_type( seqpos1 ).name3() ),
52  rsd2_type_name3_( pose.residue_type( seqpos2 ).name3() ),
53  bonus_( bonus )
54 {}
55 
56 
58  core::pose::Pose const &, //pose,
59  Size seqpos1,
60  Size seqpos2,
61  std::string AA1name,
62  std::string AA2name,
63  core::Real bonus
64 ):
65  Constraint( core::scoring::res_type_linking_constraint ),
66 
67  seqpos1_( seqpos1 ),
68  seqpos2_( seqpos2 ),
69  rsd1_type_name3_( AA1name ),
70  rsd2_type_name3_( AA2name ),
71  bonus_( bonus )
72 {}
73 
75 
78 {
79  return ConstraintOP( new ResidueTypeLinkingConstraint( *this ) );
80 }
81 
85  pos_list.push_back(seqpos1_);
86  pos_list.push_back(seqpos2_);
87  return pos_list;
88 }
89 
90 void
91 ResidueTypeLinkingConstraint::show( std::ostream & out ) const {
92  out << "ResidueTypeLinkingConstraint; ";
93  out << "seqpos1: " << seqpos1_;
94  out << "seqpos2: " << seqpos2_;
95  out << "; AA1name: "<< AA1name;
96  out << "; AA2name: "<< AA2name;
97  out << "; rsd1_type_name3: "<< rsd1_type_name3_;
98  out << "; rsd2_type_name3: "<< rsd2_type_name3_;
99  out << "; favor_native_bonus: "<< bonus_;
100 }
101 
102 /*
103 ConstraintOP
104 ResidueTypeLinkingConstraint::remap_resid( core::id::SequenceMapping const &seqmap ) const
105 {
106  core::Size newseqpos = seqmap[ seqpos_ ];
107  if ( newseqpos != 0 ) {
108 
109  return ConstraintOP( new ResidueTypeLinkingConstraint( newseqpos, AAname, rsd_type_name3_, favor_native_bonus_ ) );
110  } else {
111  return NULL;
112  }
113 }
114 */
115 bool
117 {
118  if( !dynamic_cast< ResidueTypeLinkingConstraint const * > ( &other_cst ) ) return false;
119 
120  ResidueTypeLinkingConstraint const & other( static_cast< ResidueTypeLinkingConstraint const & > (other_cst) );
121 
122  if( seqpos1_ != other.seqpos1_ ) return false;
123  if( seqpos2_ != other.seqpos2_ ) return false;
124  if( AA1name != other.AA1name ) return false;
125  if( AA2name != other.AA2name ) return false;
126  if( rsd1_type_name3_ != other.rsd1_type_name3_ ) return false;
127  if( rsd2_type_name3_ != other.rsd2_type_name3_ ) return false;
128  if( bonus_ != other.bonus_ ) return false;
129  if( this->score_type() != other.score_type() ) return false;
130 
131  return true;
132 }
133 /*
134 ConstraintOP
135 ResidueTypeLinkingConstraint::remapped_clone( pose::Pose const& src, pose::Pose const& dest, id::SequenceMappingCOP smap ) const {
136 
137  core::Size newseqpos = seqpos_;
138  if ( smap ) {
139  newseqpos = (*smap)[ seqpos_ ];
140  if( newseqpos == 0 ) return NULL;
141  }
142 
143  return new ResidueTypeLinkingConstraint(newseqpos, AAname, rsd_type_name3_, favor_native_bonus_);
144 }
145 */
146 
147 // Calculates a score for this constraint using XYZ_Func, and puts the UNWEIGHTED score into
148 // emap. Although the current set of weights currently is provided, Constraint objects
149 // should put unweighted scores into emap.
150 void
151 ResidueTypeLinkingConstraint::score( XYZ_Func const & xyz_func, EnergyMap const & weights, EnergyMap & emap ) const
152 {
153  Real const weight(weights[ this->score_type() ] );
154 // std::cout << "res_type_linking_cst weight " << weight << std::endl;
155 
156  if( weight == 0 ) return; // what's the point?
157 
158  conformation::Residue const & rsd1( xyz_func.residue(seqpos1_) );
159  conformation::Residue const & rsd2( xyz_func.residue(seqpos2_) );
160  if( rsd1.aa() != rsd2.aa() ){
161  emap[ this->score_type() ] += bonus_;
162  //std::cout << "res_type_linking_cst " << seqpos1_ << " " << seqpos2_ << " aa1 " << rsd1.type().name3() << " aa2 " << rsd2.type().name3() << " " << emap[ this->score_type() ] << std::endl;
163  }// no match, don't adjust score
164 }
165 
166 
167 void
169  AtomID const & ,//atom,
170  XYZ_Func const &,
171  Vector & ,//F1,
172  Vector & ,//F2,
173  EnergyMap const & //weights
174 ) const
175 {
176  // Do nothing.
177  // Derivative of this restraint is effectively zero
178  // so we just "add zero" to F1 and F2.
179 }
180 
181 } // namespace constraints
182 } // namespace scoring
183 } // namespace core