Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VallResidue.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/fragment/picking_old/vall/VallResidue.cc
11 /// @brief class for managing a line of the Vall fragment library
12 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
13 
14 // unit headers
16 
17 // project headers
18 #include <core/chemical/AA.hh>
20 
21 // boost headers
22 #include <boost/type_traits.hpp>
23 
24 // utility headers
25 #include <utility/pointer/owning_ptr.hh>
26 
27 // C++ headers
28 // AUTO-REMOVED
29 #include <cstdio>
30 #include <iostream>
31 // AUTO-REMOVED #include <sstream>
32 
33 #include <utility/vector1.hh>
34 
35 
36 
37 
38 namespace core {
39 namespace fragment {
40 namespace picking_old {
41 namespace vall {
42 
43 
44 // static initialization
47 
48 
49 /// @brief default constructor
51  aa_( 0 ),
52  ss_( 0 ),
53  resi_( 0 ),
54  x_( 0.0 ),
55  y_( 0.0 ),
56  z_( 0.0 ),
57  phi_( 0.0 ),
58  psi_( 0.0 ),
59  omega_( 0.0 ),
60  profile_( 20 ),
61  position_index_( 0 ),
62  section_index_( 0 )
63 {}
64 
65 
66 /// @brief string constructor
68  fill_from_string( line );
69 }
70 
71 
72 /// @brief copy constructor
74  id_( rval.id_ ),
75  aa_( rval.aa_ ),
76  ss_( rval.ss_ ),
77  resi_( rval.resi_ ),
78  x_( rval.x_ ),
79  y_( rval.y_ ),
80  z_( rval.z_ ),
81  phi_( rval.phi_ ),
82  psi_( rval.psi_ ),
83  omega_( rval.omega_ ),
84  profile_( rval.profile_ ),
85  position_index_( rval.position_index_ ),
86  section_index_( rval.section_index_ )
87 {}
88 
89 
90 /// @brief default destructor
92 
93 
94 /// @brief copy assignment
96  if ( this != &rval ) {
97  id_ = rval.id_;
98  aa_ = rval.aa_;
99  ss_ = rval.ss_;
100  resi_ = rval.resi_;
101  x_ = rval.x_;
102  y_ = rval.y_;
103  z_ = rval.z_;
104  phi_ = rval.phi_;
105  psi_ = rval.psi_;
106  omega_ = rval.omega_;
107  profile_ = rval.profile_;
110  }
111  return *this;
112 }
113 
114 
115 /// @brief build a BBTorsionSRFD of the given type from this page
116 /// @param[in] srfd_type BBTorsionSRFD::create() will be called from this object.
117 /// @return A BBTorsionSRFD of the given type initialized with the backbone
118 /// torsion information from this page.
120  BBTorsionSRFDOP srfd = static_cast< BBTorsionSRFD * >( srfd_type.create().get() );
121 
122  srfd->set_sequence( aa_ );
123  srfd->set_secstruct( ss_ );
124 
125  // currently, phi = 1, psi = 2, omega = 3
126  // see BBTorsionSRFD and Pose implemenations for details
127  srfd->set_torsion( 1, phi_ );
128  srfd->set_torsion( 2, psi_ );
129  srfd->set_torsion( 3, omega_ );
130 
131  return srfd;
132 }
133 
134 
135 /// @brief fill internal data from string
136 /// @details Values are delimited by whitespace. Ordering is:
137 /// <tt> id aa ss resi dummy dummy x y z phi psi omega dummy dummy dummy dummy (aa profile_info, 20 columns) </tt>
138 void VallResidue::fill_from_string( String const & line ) {
139 
140  char id[] = { '\0', '\0', '\0', '\0', '\0', '\0' }; // 5 char + 1 null termination
141 
142  // Use sscanf here; Vall is huge and istringstream is way too slow.
143  // *One* sscanf call per line, multiple calls decreases performance!
144  std::sscanf(
145  line.c_str(),
146  format_.c_str(),
147  &id, &aa_, &ss_, &resi_,
148  &x_, &y_, &z_,
149  &phi_, &psi_, &omega_,
150  &profile_[ order_[ 1 ] ],
151  &profile_[ order_[ 2 ] ],
152  &profile_[ order_[ 3 ] ],
153  &profile_[ order_[ 4 ] ],
154  &profile_[ order_[ 5 ] ],
155  &profile_[ order_[ 6 ] ],
156  &profile_[ order_[ 7 ] ],
157  &profile_[ order_[ 8 ] ],
158  &profile_[ order_[ 9 ] ],
159  &profile_[ order_[ 10 ] ],
160  &profile_[ order_[ 11 ] ],
161  &profile_[ order_[ 12 ] ],
162  &profile_[ order_[ 13 ] ],
163  &profile_[ order_[ 14 ] ],
164  &profile_[ order_[ 15 ] ],
165  &profile_[ order_[ 16 ] ],
166  &profile_[ order_[ 17 ] ],
167  &profile_[ order_[ 18 ] ],
168  &profile_[ order_[ 19 ] ],
169  &profile_[ order_[ 20 ] ]
170  );
171 
172  id_ = id;
173 
174 }
175 
176 
177 /// @brief return a vector specifying the order of profile data in Vall
180 
181  order[ 1] = core::chemical::aa_from_oneletter_code( 'A' );
182  order[ 2] = core::chemical::aa_from_oneletter_code( 'C' );
183  order[ 3] = core::chemical::aa_from_oneletter_code( 'D' );
184  order[ 4] = core::chemical::aa_from_oneletter_code( 'E' );
185  order[ 5] = core::chemical::aa_from_oneletter_code( 'F' );
186  order[ 6] = core::chemical::aa_from_oneletter_code( 'G' );
187  order[ 7] = core::chemical::aa_from_oneletter_code( 'H' );
188  order[ 8] = core::chemical::aa_from_oneletter_code( 'I' );
189  order[ 9] = core::chemical::aa_from_oneletter_code( 'K' );
190  order[10] = core::chemical::aa_from_oneletter_code( 'L' );
191  order[11] = core::chemical::aa_from_oneletter_code( 'M' );
192  order[12] = core::chemical::aa_from_oneletter_code( 'N' );
193  order[13] = core::chemical::aa_from_oneletter_code( 'P' );
194  order[14] = core::chemical::aa_from_oneletter_code( 'Q' );
195  order[15] = core::chemical::aa_from_oneletter_code( 'R' );
196  order[16] = core::chemical::aa_from_oneletter_code( 'S' );
197  order[17] = core::chemical::aa_from_oneletter_code( 'T' );
198  order[18] = core::chemical::aa_from_oneletter_code( 'V' );
199  order[19] = core::chemical::aa_from_oneletter_code( 'W' );
200  order[20] = core::chemical::aa_from_oneletter_code( 'Y' );
201 
202  return order;
203 }
204 
205 
206 /// @brief return a formatting string for fill_from_string() dependent
207 /// upon actual type of core::Real and core::Size
208 /// @remarks This is necessary for sscanf; wrong type can give wrong
209 /// input.
211  using boost::is_same;
212 
213  // resolve types
214  bool const is_ulong = is_same< Size, unsigned long >::value;
215  bool const is_double = is_same< Real, double >::value;
216 
217  // format w/ the following order:
218  std::ostringstream s;
219  s << "%s" << " "; // (string) id
220  s << "%c" << " "; // (char) aa
221  s << "%c" << " "; // (char) ss
222  s << ( is_ulong ? "%lu" : "%u" ) << " "; // (int) resi
223  s << "%*s" << " "; // (string) dummy
224  s << "%*s" << " ";// (string) dummy
225  s << ( is_double ? "%lf" : "%f" ) << " "; // (real) x
226  s << ( is_double ? "%lf" : "%f" ) << " "; // (real) y
227  s << ( is_double ? "%lf" : "%f" ) << " "; // (real) z
228  s << ( is_double ? "%lf" : "%f" ) << " "; // (real) phi
229  s << ( is_double ? "%lf" : "%f" ) << " "; // (real) psi
230  s << ( is_double ? "%lf" : "%f" ) << " "; // (real) omega
231  s << "%*s" << " "; // (string) dummy
232  s << "%*s" << " "; // (string) dummy
233  s << "%*s" << " "; // (string) dummy
234  s << "%*s"; // (string) dummy
235 
236  // (real) (aa profile_info, 20 columns)
237  for ( Size i = 0; i < 20; ++i ) {
238  s << " " << ( is_double ? "%lf" : "%f" );
239  }
240 
241  return s.str();
242 }
243 
244 
245 } // vall
246 } // picking_old
247 } // fragment
248 } // core