Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IdentityEval.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/eval/IdentityEval.cc
11 /// @brief scores a fragment based on secondary structure identity and sequence identity
12 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
13 
14 // unit headers
16 
17 // project headers
18 #include <basic/Tracer.hh>
19 
20 // Utility headers
21 #include <utility/exit.hh>
22 
23 // numeric headers
24 #include <numeric/random/random.hh>
25 
27 #include <utility/vector1.hh>
28 
29 
30 
31 namespace core {
32 namespace fragment {
33 namespace picking_old {
34 namespace vall {
35 namespace eval {
36 
37 
38 // static initialization
39 static numeric::random::RandomGenerator RG( 107572 ); // magic number, don't change
40 
41 static basic::Tracer TR( "core.fragment.picking_old.vall.eval.IdentityEval" );
42 
43 
44 /// @brief default constructor
46  Super(),
47  ss_penalty_( 1.0 ),
48  aa_penalty_( 1.0 ),
49  randomize_( true )
50 {}
51 
52 
53 /// @brief full values constructor
54 /// @param ss secondary structure string to match against
55 /// @param aa amino acid structure string to match against
57  String const & ss,
58  String const & aa,
59  Real const ss_penalty,
60  Real const aa_penalty,
61  bool const randomize
62 ) :
63  Super(),
64  ss_( ss ),
65  aa_( aa ),
66  ss_penalty_( ss_penalty ),
67  aa_penalty_( aa_penalty ),
68  randomize_( randomize )
69 {
70  runtime_assert( ss_.length() == aa_.length() );
71 }
72 
73 
74 /// @brief secondary structure constructor
76  String const & ss,
77  Real const ss_penalty,
78  bool const randomize
79 ) :
80  Super(),
81  ss_( ss ),
82  aa_( ss.length(), '.' ),
83  ss_penalty_( ss_penalty ),
84  aa_penalty_( 0.0 ),
85  randomize_( randomize )
86 {
87  runtime_assert( ss_.length() == aa_.length() );
88 }
89 
90 
91 /// @brief default copy constructor
93  Super( rval ),
94  ss_( rval.ss_ ),
95  aa_( rval.aa_ ),
96  ss_penalty_( rval.ss_penalty_ ),
97  aa_penalty_( rval.aa_penalty_ ),
98  randomize_( rval.randomize_ )
99 {}
100 
101 
102 /// @brief default destructor
104 
105 
106 /// @brief copy assignment
108  if ( this != &rval ) {
109  Super::operator =( rval );
110  ss_ = rval.ss_;
111  aa_ = rval.aa_;
112  ss_penalty_ = rval.ss_penalty_;
113  aa_penalty_ = rval.aa_penalty_;
114  randomize_ = rval.randomize_;
115  }
116  return *this;
117 }
118 
119 
120 /// @brief clone this object
122  return new IdentityEval( *this );
123 }
124 
125 
126 /// @brief for a fragment extent, evaluate and store results in a VallFragmentScore
127 /// @return true, so score is always stored during VallLibrarian::catalog()
129  Extent const & extent,
130  VallFragmentScore & fs
131 )
132 {
133  // no runtime_asserts here, will slow down Librarian operation
134  assert( extent.distance() == ss_.length() );
135  assert( ss_.length() == aa_.length() );
136 
137  Size str_idx = 0;
138  for ( VallResidueConstIterator i = extent.begin; i != extent.end; ++i, ++str_idx ) {
139  assert( str_idx != ss_.length() );
140  assert( str_idx != aa_.length() );
141 
142  switch ( ss_.at( str_idx ) ) {
143  case 'D': {
144  break; // degenerate sec.struct do nothing
145  }
146  default: {
147  if ( i->ss() != ss_.at( str_idx ) ) {
148  fs.score += ss_penalty_;
149  }
150  break;
151  }
152  }
153 
154  switch ( aa_.at( str_idx ) ) {
155  case '.': {
156  break; // char for degenerate a.a., do nothing
157  }
158  default: {
159  if ( i->aa() != aa_.at( str_idx ) ) {
160  fs.score += aa_penalty_;
161  }
162  break;
163  }
164  }
165 
166  } // foreach residue in extent
167 
168  // finalize scores
169  if ( randomize_ ) {
170  fs.score += ( RG.uniform() * 0.001 );
171  }
172 
173  return true;
174 }
175 
176 
177 /// @brief operation to be perform before catalog() starts
179  TR << "ss = " << ss_ << " | " << "aa = " << aa_ << std::endl;
180 }
181 
182 
183 } // namespace eval
184 } // namespace vall
185 } // namespace picking_old
186 } // namespace fragment
187 } // namespace core