Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BBTorsionSRFD.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/fragments/BBTorsionSRFD.cc
12 /// @author Oliver Lange (olange@u.washington.edu)
13 
14 // Unit Headers
16 
17 // Project Headers
19 #include <core/pose/Pose.hh>
20 
21 // ObjexxFCL Headers
22 #include <ObjexxFCL/format.hh>
23 
24 // Utility headers
25 #include <utility/vector1.fwd.hh>
26 #include <basic/Tracer.hh>
27 
28 #include <utility/vector1.hh>
29 
30 
31 namespace core {
32 namespace fragment {
33 
34 static basic::Tracer tr("core.fragment");
35 
36 /// @brief copy assignment
38  if ( this != &rval ) {
39  Parent::operator =( rval );
40 
41  // copy local data
42  torsions_ = rval.torsions_;
43  coords_ = rval.coords_;
44  has_coords_ = rval.has_coords_;
45  }
46  return *this;
47 }
48 
49 /// @brief insert all backbone torsions into pose at position seq_pos
50 bool BBTorsionSRFD::apply( pose::Pose& pose, Size seqpos ) const {
51  bool const success ( Parent::apply( pose, seqpos ) );
52 
53  // only move forward with changes if prior ops successful
54  if ( success ) {
55  for ( Size j = 1, je = nbb(); j <= je; ++j ) {
56  pose.set_torsion( id::TorsionID( seqpos, id::BB, j ), torsions_[j] );
57  }
58  }
59  return success; //can something go wrong ? check has_torsion() ?
60 }
61 
62 /// @brief insert all backbone torsions into pose at position seq_pos
63 /// @param[in] movemap This MoveMap will be *ignored* at the BBTorsionSRFD level,
64 /// but will be passed to any superclass <tt>apply()</tt>.
65 /// @param[in,out] pose The pose to modify.
66 /// @param[in] seqpos Sequence position to modify.
67 /// @return True if <tt>apply()</tt> successful, False otherwise.
68 /// @warning MoveMap settings at the BBTorsionSRFD level are *ignored*.
69 /// For speed, does not check to see whether or not all backbone torsions
70 /// are moveable in MoveMap -- use <tt>is_applicable()</tt> for this
71 /// purpose prior to calling <tt>apply()</tt>.
72 bool BBTorsionSRFD::apply( kinematics::MoveMap const & movemap, pose::Pose & pose, Size const seqpos ) const {
73  // parent apply() successful?
74  bool const success = Parent::apply( movemap, pose, seqpos );
75 
76  // only move forward with changes if prior ops successful
77  if ( success ) {
78  for ( Size j = 1, je = nbb(); j <= je; ++j ) {
79  pose.set_torsion( id::TorsionID( seqpos, id::BB, j ), torsions_[ j ] );
80  }
81  }
82  return success;
83 }
84 
85 bool BBTorsionSRFD::steal( pose::Pose const& pose, Size seqpos ) {
86  runtime_assert( nbb() > 0 );
87  bool success ( Parent::steal( pose, seqpos ) );
88  for ( Size j=1; j<= nbb() && success; ++j ) {
89  torsions_[j] = pose.torsion( id::TorsionID( seqpos, id::BB, j ));
90  }
91  return success; //can something go wrong ? check has_torsion() ?
92 }
93 
95  if ( dynamic_cast< BBTorsionSRFD const* > ( & aSRFD ) ) {
96  BBTorsionSRFD const & bbtsrfd = static_cast< BBTorsionSRFD const & > ( aSRFD );
97  return bbtsrfd.nbb() == nbb();
98  };
99  return false; //wrong SRFD-type (cast not successfull)
100 }
101 
102 /// @brief check if all backbone torsions at the sequence position moveable
103 /// in the MoveMap
104 /// @return True if all backbone torsions moveable and <tt>is_applicable()</tt>
105 /// succeeded for superclass, otherwise False.
106 bool BBTorsionSRFD::is_applicable( kinematics::MoveMap const& move_map, Size seqpos) const {
107  if ( ! Parent::is_applicable( move_map, seqpos ) ) return false;
108 
109  for ( Size j=1; j<= nbb(); ++j ) {
110  // catch a user-error that is otherwise difficult to find:
111  if ( j == 3 ) { //omega
112  if ( !( move_map.get( id::TorsionID( seqpos, id::BB, j )) )) {
113  tr.Warning << "MoveMap allows phi/psi motion but not omega motion --> "
114  << "Fragment cannot be applied --> is this intended ?"
115  << std::endl;
116  }
117  }
118  if ( !( move_map.get( id::TorsionID( seqpos, id::BB, j )) )) return false;
119  }
120  return true;
121 }
122 
123 void BBTorsionSRFD::show( std::ostream &out ) const {
124  using namespace ObjexxFCL::fmt;
125  Parent::show( out );
126  runtime_assert( nbb() == torsions_.size() );
127 
128  // print torsions
129  for ( Size j=1; j<= nbb() ; ++j ) {
130  out << F( 10, 3, torsions_[ j ] );
131  }
132 
133  // print cartesian coordinates
134  if (has_coordinates()) {
135  out << F(10, 3, x())
136  << F(10, 3, y())
137  << F(10, 3, z());
138  }
139 }
140 
141 void BBTorsionSRFD::read_data( std::istream &in ) {
142  Parent::read_data( in );
143  Real t;
144  torsions_.clear();
145  while ( in >> t ) {
146  torsions_.push_back( t );
147  }
148  if ( in.eof() && in.fail() && !in.bad() ) {
149  if ( nbb() ) {
150  in.clear( std::ios_base::eofbit );
151  }
152  }
153 }
154 
155 } //fragment
156 } //core