Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DNAParameters.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 // (C) 199x-2009 Rosetta Commons participating institutions and developers.
7 // For more information, see http://www.rosettacommons.org/.
8 
9 /// @file src/protocols/dna/DNAParameters.cc
10 /// @brief A class to query for base-paired partners as well as base pair and base step parameters
11 /// @author Jim Havranek
12 
14 
16 
17 #include <core/pose/Pose.hh>
18 #include <core/pose/PDBInfo.hh>
19 
20 #include <basic/basic.hh>
21 
23 
26 
27 //#include <ObjexxFCL/fmt/formatted.o.hh> // I()
28 
29 #include <utility/vector1.hh>
30 
31 #include <numeric/random/random.hh>
32 
33 static numeric::random::RandomGenerator RG( 10662001 );
34 
35 using utility::vector1;
36 
37 namespace protocols {
38 namespace dna {
39 
40 using namespace core;
41 
42 // Note that the DNABasepair and DNABasestep classes are meant to managed by the DNAParameters
43 // class, and not used directly. The main reason for this is that they have little in the way
44 // of error-checking - most of this is done by the DNAParameters class, which creates them as
45 // needed. Even the DNAParameters class is not meant to be created by user code. The intent
46 // is that it will be created and updated as necessary by the DNAParameterCalculator PoseMetric,
47 // which does all the instantiation and recalculation work and logic.
48 
49 // This is the case where we pass in the residue
50 // and call out to a function in core/scoring/dna/base_geometry.hh
52 {
53  assert( rsd.is_DNA() );
54 
55  alpha_ = rsd.mainchain_torsion(1);
56  beta_ = basic::unsigned_periodic_range( rsd.mainchain_torsion(2), 360.0 );
57  gamma_ = rsd.mainchain_torsion(3);
58  delta_ = rsd.mainchain_torsion(4);
59  epsilon_ = basic::unsigned_periodic_range( rsd.mainchain_torsion(5), 360.0 );
60  zeta_ = basic::unsigned_periodic_range( rsd.mainchain_torsion(6), 360.0 );
61  chi_ = rsd.chi(1);
62 
63 
64  Real pseudorotation( 0.0 );
65  Real amplitude( 0.0 );
66  std::pair< std::string, int > pucker;
67 
68  //scoring::dna::get_base_pucker( rsd, pucker, pseudorotation, amplitude );
69 
70  pseudorotation_ = pseudorotation;
71  amplitude_ = amplitude;
72 }
73 
74 // This is the case where we pass in the parameters in a vector,
75 // with the ordering as defined in core/scoring/dna/base_geometry.hh
77  stretch_( values[ 5 ] ), stagger_( values[ 6 ] ), shear_( values[ 4 ] ),
78  propeller_( values[ 1 ] ), opening_( values[ 3 ] ), buckle_( values[ 2 ] ) {}
79 
80 // This is the case where we pass in the residues that form the base pair
81 // and call out to a function in core/scoring/dna/base_geometry.hh
83 {
84  assert( rsd1.is_DNA() );
85  assert( rsd2.is_DNA() );
86 
88 
89  scoring::dna::get_base_pair_params( rsd1, rsd2, values );
90 
91  stretch_ = values[ 5 ];
92  stagger_ = values[ 6 ];
93  shear_ = values[ 4 ];
94  propeller_ = values[ 1 ];
95  opening_ = values[ 3 ];
96  buckle_ = values[ 2 ];
97 }
98 
99 // This is the case where we pass in the parameters in a vector,
100 // with the ordering as defined in core/scoring/dna/base_geometry.hh
102  slide_( values[ 4 ] ), shift_( values[ 6 ] ), rise_( values[ 5 ] ),
103  roll_( values[ 2 ] ), twist_( values[ 1 ] ), tilt_( values[ 3 ] ) {}
104 
105 // This is the case where we pass in the residues that form the base pair
106 // and call out to a function in core/scoring/dna/base_geometry.hh
108  conformation::Residue const & rsd1_next, conformation::Residue const & rsd2_prev )
109 {
110  assert( rsd1.is_DNA() );
111  assert( rsd2.is_DNA() );
112  assert( rsd1_next.is_DNA() );
113  assert( rsd2_prev.is_DNA() );
114 
115  utility::vector1< Real > values( 6, 0.0 );
116 
117  scoring::dna::get_base_step_params( rsd1, rsd2, rsd1_next, rsd2_prev, values );
118 
119  slide_ = values[ 4 ];
120  shift_ = values[ 6 ];
121  rise_ = values[ 5 ];
122  roll_ = values[ 2 ];
123  twist_ = values[ 1 ];
124  tilt_ = values[ 3 ];
125 }
126 
127 
128 // End of the bs/bp data holders
129 //
130 //
131 // Begin DNAParameters class methods
132 
133 // Return the torsions for this residue, if it's a base
134 DNABase const &
136 {
137  std::map< core::Size, DNABase >::const_iterator find_itr( bases_.find( resid ) );
138  assert( find_itr != bases_.end() );
139 
140  return find_itr->second;
141 }
142 
143 // Return the parameters for a base pair including this residue
144 DNABasepair const &
146 {
147  std::map< core::Size, DNABasepair >::const_iterator find_itr( basepairs_.find( resid ) );
148  assert( find_itr != basepairs_.end() );
149 
150  return find_itr->second;
151 }
152 
153 // Return the parameters for the base step consisting of this residue, the next residue,
154 // and their two base paired partners
155 DNABasestep const &
157 {
158  std::map< core::Size, DNABasestep >::const_iterator find_itr( basesteps_.find( resid ) );
159  assert( find_itr != basesteps_.end() );
160 
161  return find_itr->second;
162 }
163 
164 // Check to see if this residue is in base pair where "in a base pair" is defined as
165 // "in my map of base pairs"
166 bool
168 {
169  return( basepairs_.find( resid) != basepairs_.end() );
170 }
171 
172 // Check to see if this residue is a valid starting point for a base step - that is, do
173 // this residue, its base paired partner, the residue at resid+1, and its base paired partner
174 // form a base step
175 bool
177 {
178  return( basesteps_.find( resid) != basesteps_.end() );
179 }
180 
181 // Find the base paired partner for a residue. If none exists, you get the constructor
182 // default value in the vector1, which is at the time of this typing 0.
185 {
186  return partners_[ resid ];
187 }
188 
191 {
192  return unique_basepairs_[ RG.random_range(1, unique_basepairs_.size() ) ];
193 }
194 
197 {
198  return unique_basestep_starts_[ RG.random_range(1, unique_basestep_starts_.size() ) ];
199 }
200 
201 // More or less trying to mimic the functionality of Phil's code in scoring::dna with as
202 // little code duplication as necessary. One difference is that I am double storing
203 // base pair information, once for each of the bases. I think certain parameters change
204 // sign upon this kind of inversion, but I didn't want to leave any missing pieces in case
205 // they get queried by someone later.
206 void
208 {
209  basepairs_.clear();
210  basesteps_.clear();
211  bases_.clear();
212  partners_.clear();
213  dna_base_positions_.clear();
214  unique_basepairs_.clear();
215  unique_basestep_starts_.clear();
216 
217  // This function gets just what we want, including the desired value of zero
218  // for unpartnered bases/non-DNA
220 
221  // Fill in the single base torsions
222  for( core::Size resid( 1 ), endid( pose.total_residue() ) ; resid <= endid ; ++resid ) {
223  if( pose.residue( resid ).is_DNA() ) {
224  dna_base_positions_.push_back( resid );
225  bases_[ resid ] = DNABase( pose.residue( resid ) ) ;
226  }
227  }
228 
229  // Now get the base pairs
230  for( core::Size resid( 1 ), endid( pose.total_residue() ) ; resid <= endid ; ++resid ) {
231  core::Size partner_check( partners_[ resid ] );
232  if( partner_check > resid ) {
233  basepairs_[ resid ] = DNABasepair( pose.residue( resid ), pose.residue( partner_check ) ) ;
234  basepairs_[ partner_check] = DNABasepair( pose.residue( partner_check ), pose.residue( resid ) ) ;
235  unique_basepairs_.push_back( resid );
236  }
237  }
238 
239  // And the base steps - note the range of the loop is foreshortened, since a base step
240  // can't start on the last residue
241  for( core::Size resid( 1 ), endid( pose.total_residue() - 1 ) ; resid <= endid ; ++resid ) {
242 
243  core::Size partner_check( partners_[ resid ] );
244  core::Size next_residue( resid + 1 );
245  core::Size next_residue_partner( partners_[ next_residue ] );
246 
247  // To form a base step, both resid and next_residue must be base paired.
248  // Note that I do one insertion max in the inner loop. I let the same base step be
249  // found twice, once in each direction. This is different from the base pairs above.
250  if( partner_check != 0 &&
251  next_residue_partner != 0 &&
252  !pose.residue( resid ).is_upper_terminus() ) {
253  basesteps_[ resid ] = DNABasestep( pose.residue( resid ), pose.residue( partner_check ),
254  pose.residue( next_residue ), pose.residue( next_residue_partner ) ) ;
255  if( resid < partner_check ) {
256  unique_basestep_starts_.push_back( resid );
257  }
258  }
259  }
260 
261 
262  return;
263 }
264 
265 } // namespace dna
266 } // namespace protocols