Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HSSTriplet.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 // This file is part of the Rosetta software suite and is made available under license.
5 // The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6 // Copyright in the Rosetta software belongs to the developers and their institutions.
7 // For more information, see www.rosettacommons.org.
8 
9 /// @file ./src/protocols/src/fldsgn/topology/HSSTriplet.cc
10 /// @brief
11 /// @author Nobuyasu Koga ( nobuyasu@u.washington.edu )
12 
13 // unit headers
16 
17 #include <basic/Tracer.hh>
18 #include <utility/exit.hh>
19 #include <ostream>
20 #include <utility/string_util.hh>
21 #include <boost/lexical_cast.hpp>
22 #include <numeric/xyzVector.hh>
23 #include <numeric/conversions.hh>
24 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
25 
26 #include <utility/vector1.hh>
27 
28 
29 static basic::Tracer TR( "protocols.topology.HSSTriplet" );
30 
31 namespace protocols {
32 namespace fldsgn {
33 namespace topology {
34 
35 // @brief Auto-generated virtual destructor
37 
38 
39 /// @value constructor
41 {
42  utility::vector1< String > parts( utility::string_split( hss, ',' ) );
43  runtime_assert( parts.size() == 2 );
44  helix_ = boost::lexical_cast<Size>( parts[1] );
45 
46  utility::vector1< String > st( utility::string_split( parts[2], '-' ) );
47  runtime_assert( st.size() == 2 );
48  strand1_ = boost::lexical_cast<Size>( st[1] );
49  strand2_ = boost::lexical_cast<Size>( st[2] );
50 }
51 
52 
53 /// @copy constructor
55  ReferenceCount(),
56  helix_( hss.helix_ ),
57  strand1_( hss.strand1_ ),
58  strand2_( hss.strand2_ )
59 {}
60 
61 /// @brief IO Operator
62 std::ostream & operator<<(std::ostream & out, const HSSTriplet & s )
63 {
64  out << "Helix:" << s.helix() << " Strand1:" << s.strand1() << " Strand2:" << s.strand2();
65  return out;
66 }
67 
68 /// @brief
71 {
72  return hs1_dist_;
73 }
74 
75 /// @brief
78 {
79  return hs2_dist_;
80 }
81 
82 /// @brief
85 {
86  return ss_dist_;
87 }
88 
89 /// @brief reutrn distance between sheet ( defined by the 2 strands ) and helix
92 {
93  return hsheet_dist_;
94 }
95 
96 /// @brief return distance between sheet ( defined by the 2 strands ) and helix
99 {
100  return hs_angle_;
101 }
102 
103 /// @brief orientation between strands
106 {
107  return ss_orient_;
108 }
109 
110 /// @brief orientation between helix and 1st strand
113 {
114  return hs1_orient_;
115 }
116 
117 /// @brief orientation between helix and 2nd strand
120 {
121  return hs2_orient_;
122 }
123 
124 /// @brief orientation between helix and 2nd strand
125 bool
127 {
128  return left_handed_;
129 }
130 
131 /// @brief calc geometry
132 void
134 {
135 
138 
139  Helix const & hx ( *ssinfo->helices()[ helix() ] );
140  Strand const & s1 ( *ssinfo->strands()[ strand1() ] );
141  Strand const & s2 ( *ssinfo->strands()[ strand2() ] );
142 
143  runtime_assert( s1.length() >= 2 );
144  runtime_assert( s2.length() >= 2 );
145 
146  Real dot_ss = s1.orient().dot( s2.orient() );
147  Real dot_hs1 = hx.orient().dot( s1.orient() );
148  Real dot_hs2 = hx.orient().dot( s2.orient() );
149 
150  Real sign_ss/*, sign_hs1, sign_hs2*/;
151 
152  if( dot_ss < 0 ) {
153  sign_ss = -1.0;
154  ss_orient_ = "A";
155  } else {
156  sign_ss = 1.0;
157  ss_orient_ = "P";
158  }
159 
160  if( dot_hs1 < 0 ) {
161  //sign_hs1 = -1.0; // set but never used ~Labonte
162  hs1_orient_ = "A";
163  } else {
164  //sign_hs1 = 1.0; // set but never used ~Labonte
165  hs1_orient_ = "P";
166  }
167 
168  if( dot_hs2 < 0 ) {
169  //sign_hs2 = -1.0; // set but never used ~Labonte
170  hs2_orient_ = "A";
171  } else {
172  //sign_hs2 = 1.0; // set but never used ~Labonte
173  hs2_orient_ = "P";
174  }
175 
176  // get mid point of helix and strands
177  Vector const hmid = hx.mid_pos();
178  Vector const s1_mid = s1.mid_pos();
179  Vector const s2_mid = s2.mid_pos();
180 
181  // calc_handness
182  Vector const s12_vec = ( s2_mid - s1_mid ).normalized();
183  Vector const hs1_vec = ( hmid - s1_mid ).normalized();
184  Real d = hs1_vec.cross( s12_vec ).dot( s1.orient() );
185  if( d < 0 ) left_handed_ = true;
186 
187  // define beta sheet plane
188  Vector const s1_chalf_mid = ( s1.mid_pos() + s1.Cend_pos() )/2.0;
189  Vector const s2_nhalf_mid = ( s2.mid_pos() + s2.Nend_pos() )/2.0;
190  Vector const v1 = ( s2_nhalf_mid - s1_chalf_mid ).normalized();
191 
192  // Vector const v2 = ( s1.orient() + sign*s2.orient() ).normalized();
193  Vector const v2 = ( s1.Cend_orient() + sign_ss*s2.Nend_orient() ).normalized();
194 
195  Vector sheet_plane = v1.cross( v2 );
196 
197  // distance between helix and sheet
198  hsheet_dist_ = sheet_plane.normalized().dot( hmid - s1_chalf_mid );
199 
200  // distance between helix and strand1
201  hs1_dist_ = ( s1.mid_pos() - hmid ).length();
202 
203  // distance between helix and strand2
204  hs2_dist_ = ( s2.mid_pos() - hmid ).length();
205 
206  // distance between strand1 and strand2
207  ss_dist_ = ( s2.mid_pos() - s1.mid_pos() ).length();
208 
209  // calc angles between strands and helix
210  Vector const h1 = hx.Nend_pos() - sheet_plane.dot( hx.Nend_pos() - s2_nhalf_mid )*sheet_plane;
211  Vector const h2 = hx.Cend_pos() - sheet_plane.dot( hx.Cend_pos() - s2_nhalf_mid )*sheet_plane;
212  Vector const hx_on_sheet = ( h1 - h2 ).normalized();
213  Real ori = cross( hx_on_sheet, v2 ).dot( sheet_plane );
214  hs_angle_ = numeric::conversions::degrees( angle_of( v2, hx_on_sheet ) );
215  if( ori < 0 ) hs_angle_ = -1*hs_angle_;
216 
217  // std::cout << ss_orient_ << " " << hs1_orient_ << " " << hs2_orient_ << " "
218  // << hsheet_dist_ << " " << hs1_dist_ << " " << hs2_dist_ << " " << ss_dist_ << " "
219  // << hs_angle_ << std::endl;
220 
222 
223 // using namespace ObjexxFCL::fmt;
224 // Size number( 0 );
225 // for( int ii=1; ii<=25; ii++ ) {
226 // for( int jj=1; jj<=25; jj++ ) {
227 // ++number;
228 // Vector pos = v1*( ii - 12 ) + v2*( jj - 12 ) + s1_chalf_mid;
229 // std::cout << "ATOM " << I(5,number) << ' ' << " CA " << ' ' << "ALA" << ' '
230 // << "B" << I(4,number) << " "
231 // << F(8,3,pos.x()) << F(8,3,pos.y()) << F(8,3,pos.z())
232 // << F(6,2,1.0) << F(6,2,10.0) << std::endl;
233 // }
234 // }
235 // std::cout << "ATOM " << I(5,1) << ' ' << " CA " << ' ' << "ALA" << ' '
236 // << "C" << I(4,1) << " "
237 // << F(8,3,hmid.x()) << F(8,3,hmid.y()) << F(8,3,hmid.z())
238 // << F(6,2,1.0) << F(6,2,10.0) << std::endl;
239 
240 }
241 
242 
243 /// @brief default constructor
245 {
246  clear();
247 }
248 
249 
250 /// @brief value constructor
252 {
253  clear();
254 
255  if( s == "" ) {
256  return;
257  }
258 
259  utility::vector1< String > hsss( utility::string_split( s, ';' ) );
260  for( utility::vector1< String >::const_iterator iter = hsss.begin(); iter != hsss.end() ; ++iter) {
261  push_back( new HSSTriplet( *iter ) );
262  }
263 }
264 
265 
266 /// @brief value constructor
268 {
269  for( HSSTriplets::const_iterator it=s.begin(), ite=s.end(); it!= ite; ++it ) {
270  HSSTripletOP const hss( *it );
271  push_back( hss );
272  }
273 }
274 
275 
276 /// @brief copy constructor
278  ReferenceCount(),
279  hss_triplets_( s.hss_triplets_ ),
280  helix2hss_( s.helix2hss_ )
281 {}
282 
283 
284 /// @brief destructor
286 
287 
288 /// @brief IO Operator
289 std::ostream & operator<<(std::ostream & out, const HSSTripletSet & s )
290 {
291  out << "#### HSSTriplet Info " << std::endl;
292  for( HSSTriplets::const_iterator iter = s.hss_triplets().begin(),
293  iter_end = s.hss_triplets().end(); iter != iter_end; ++iter ) {
294  HSSTriplet const & hss( **iter );
295  out << hss << std::endl;
296  }
297  return out;
298 }
299 
300 
301 /// @brief value constructor
302 void
304 {
305  for( HSSTriplets::const_iterator it=s.begin(), ite=s.end(); it!= ite; ++it ) {
306  HSSTripletOP const hss( *it );
307  push_back( hss );
308  }
309 }
310 
311 /// @brief puch back data
312 void
314 {
315  for ( std::map< Size, HSSTripletOP >::const_iterator it=helix2hss_.begin(),
316  ite=helix2hss_.end(); it!=ite ; ++it ) {
317  if ( it->first == hsop->helix() ) {
318  TR << "Helix " << it->first << " is already defined in HSSTriplet. " << std::endl;
319  assert( false );
320  }
321  }
322 
323  hss_triplets_.push_back( hsop );
324  helix2hss_[ hsop->helix() ] = hsop;
325 }
326 
327 /// @brief clear data
328 void
330 {
331  hss_triplets_.clear();
332  helix2hss_.clear();
333 }
334 
335 
336 /// @brief
339 {
340  return helix2hss_[ helix ];
341 }
342 
343 
344 /// @brief return all data
345 HSSTriplets const &
347 {
348  return hss_triplets_;
349 }
350 
351 
352 } // namespace topology
353 } // namespace fldsgn
354 } // namespace protocols