Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IndependentBBTorsionSRFD.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file core/fragment/IndependentBBTorsionSRFD.cc
12 /// @brief A version of BBTorsionSRFD that considers each torsion independently
13 /// during is_applicable() and apply() calls when passed a MoveMap (vs
14 /// the all-torsions-must-be-moveable-or-nothing-is behavior in the
15 /// original BBTorsionSRFD).
16 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
17 
18 
19 // unit headers
22 #include <core/pose/Pose.hh>
23 
24 #include <utility/vector1.hh>
25 
26 
27 
28 namespace core {
29 namespace fragment {
30 
31 
32 // internal 'using' for this file
34 
35 
36 /// @brief default constructor
38  Super()
39 {}
40 
41 
42 /// @brief constructor
43 /// @param[in] n_bbtorsions Number of backbone torsions.
44 /// @param[in] secstruct The single character secondary structure type.
45 /// @param[in] sequence The single character sequence type.
47  Size const n_bbtorsions,
48  char const secstruct,
49  char const sequence
50 ) :
51  Super( n_bbtorsions, secstruct, sequence )
52 {}
53 
54 
55 /// @brief copy constructor
57  Super( rval )
58 {}
59 
60 
61 /// @brief default destructor
63 
64 
65 /// @brief copy assignment
67  if ( this != &rval ) {
68  Super::operator =( rval );
69  }
70  return *this;
71 }
72 
73 
74 /// @brief clone this object
76  return new IndependentBBTorsionSRFD( *this );
77 }
78 
79 
80 /// @brief create a new instance of this object
82  return new IndependentBBTorsionSRFD();
83 }
84 
85 
86 /// @brief apply only torsions in this fragment marked as moveable in the given
87 /// MoveMap
88 /// @param[in] movemap Check for moveable torsions in this MoveMap.
89 /// @param[in,out] pose The Pose to modify.
90 /// @param[in] seqpos Insert at this sequence position.
91 /// @return True if at least one torsion inserted and second level superclass
92 /// <tt>SecstructSRFD::apply()</tt> succeeded, otherwise false.
93 /// @details Skips the initial call to primary superclass <tt>BBTorsionSRFD::apply()</tt>
94 /// because it contains all-or-nothing behavior we want to override. Instead
95 /// will go directly to second level <tt>SecstructSRFD::apply()</tt>, and afterwards
96 /// execute the rest of the procedure.
98  MoveMap const & movemap,
99  Pose & pose,
100  Size const seqpos
101 ) const
102 {
103  // Call SecstructSRFD::apply(). Can't call direct superclass
104  // BBTorsionSRFD::apply() because it directly inserts the fragment with
105  // no checks, which is something we want to override.
106  if ( !Super2::apply( movemap, pose, seqpos ) ) {
107  return false; // punt
108  }
109 
110  // only insert torsions that are allowed to move in the MoveMap
111  bool success = false; // at least one torsion inserted?
112  for ( Size j = 1, je = nbb(); j <= je; ++j ) {
113  id::TorsionID const torsion_id( seqpos, id::BB, j );
114  if ( movemap.get( torsion_id ) ) {
115  pose.set_torsion( torsion_id, Super::torsion( j ) );
116  success = true;
117  }
118  }
119 
120  return success;
121 }
122 
123 
124 /// @brief is at least one torsion marked as moveable in the given MoveMap?
125 /// @param[in] movemap Check for moveable torsions in this MoveMap.
126 /// @param[in] seqpos Check at this sequence position.
127 /// @return True if at least one torsion moveable and second level superclass
128 /// <tt>SecstructSRFD::is_applicable()</tt>, otherwise False.
129 /// @details Skips the initial call to primary superclass <tt>BBTorsionSRFD::is_applicable()</tt>
130 /// because it contains all-or-nothing behavior we want to override. Instead
131 /// will go directly to second level <tt>SecstructSRFD::is_applicable()</tt>, and afterwards
132 /// execute the rest of the procedure.
134  MoveMap const & movemap,
135  Size seqpos
136 ) const
137 {
138  // Call SecstructSRFD::is_applicable(). Can't call direct superclass
139  // BBTorsionSRFD::is_applicable() because it checks an all-or-nothing
140  // condition we want to override.
141  // Only move forward if prior ops successful, otherwise punt.
142  if ( !Super2::is_applicable( movemap, seqpos ) ) {
143  return false;
144  }
145 
146  // if any backbone torsion is allowed to move, then this IndependentBBTorsionSRFD
147  // is applicable for the given seqpos
148  bool applicable = false;
149  for ( Size j = 1, je = nbb(); ( !applicable ) && j <= je; ++j ) {
150  applicable |= movemap.get( id::TorsionID( seqpos, id::BB, j ) );
151  }
152 
153  return applicable;
154 }
155 
156 
157 } // namespace fragment
158 } // namespace core