Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ABEGOEval.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/ABEGOEval.cc
11 /// @brief scores a fragment based on abego identity
12 /// @author Nobuyasu Koga ( nobuyasu@uw.edu )
13 
14 // unit headers
17 
18 // project headers
19 #include <basic/Tracer.hh>
20 
21 // Utility headers
22 #include <utility/exit.hh>
23 
24 // numeric headers
25 #include <numeric/random/random.hh>
26 
28 #include <utility/vector1.hh>
29 
30 
31 
32 namespace core {
33 namespace fragment {
34 namespace picking_old {
35 namespace vall {
36 namespace eval {
37 
38 
39 // static initialization
40 static numeric::random::RandomGenerator RG( 131572 ); // magic number, don't change
41 
42 static basic::Tracer TR( "core.fragment.picking_old.vall.eval.ABEGOEval" );
43 
44 
45 /// @brief default constructor
47  Super(),
48  penalty_( 1.0 ),
49  randomize_( true )
50 {
51  abego_.clear();
52  am_ = new ABEGOManager;
53 }
54 
55 
56 /// @brief full values constructor
57 /// @param abego abego string to match against
60  Real const penalty,
61  bool const randomize
62 ) :
63  Super(),
64  abego_( abego ),
65  penalty_( penalty ),
66  randomize_( randomize )
67 {
68  am_ = new ABEGOManager;
69 }
70 
71 
72 /// @brief default copy constructor
74  Super( rval ),
75  abego_( rval.abego_ ),
76  penalty_( rval.penalty_ ),
77  randomize_( rval.randomize_ ),
78  am_( rval.am_ )
79 {}
80 
81 
82 /// @brief default destructor
84 
85 
86 /// @brief copy assignment
88  if ( this != &rval ) {
89  Super::operator =( rval );
90  abego_ = rval.abego_;
91  penalty_ = rval.penalty_;
92  randomize_ = rval.randomize_;
93  am_ = rval.am_;
94  }
95  return *this;
96 }
97 
98 
99 /// @brief clone this object
101  return new ABEGOEval( *this );
102 }
103 
104 
105 /// @brief for a fragment extent, evaluate and store results in a VallFragmentScore
106 /// @return true, so score is always stored during VallLibrarian::catalog()
108  Extent const & extent,
109  VallFragmentScore & fs
110 )
111 {
112  // no runtime_asserts here, will slow down Librarian operation
113  assert( extent.distance() == abego_.size() );
114 
115  Size pos = 0;
116  for ( VallResidueConstIterator i = extent.begin; i != extent.end; ++i, ++pos ) {
117  String::size_type index = abego_[ pos+1 ].find( "X" );
118  if( index == String::npos ) {
119  bool flag( false );
120  for( Size ii=0; ii<abego_[ pos+1 ].length(); ++ii ) {
121  if ( am_->check_rama( abego_[ pos+1 ].at( ii ), i->phi(), i->psi(), i->omega() ) ){
122  flag = true;
123  break;
124  }
125  }
126  if( !flag ) fs.score += penalty_;
127  }
128  } // foreach residue in extent
129 
130  // finalize scores
131  if ( randomize_ ) {
132  fs.score += ( RG.uniform() * 0.001 );
133  }
134 
135  return true;
136 }
137 
138 
139 /// @brief operation to be perform before catalog() starts
141 
142  std::ostringstream abego;
143  for( Size ii=1; ii<=abego_.size(); ++ii ) {
144  Size length = abego_[ ii ].length();
145  if( length > 1 ) {
146  std::ostringstream multi;
147  multi << "[";
148  for( Size jj=0; jj<abego_[ ii ].length(); ++jj ) {
149  multi << abego_[ ii ].at( jj );
150  }
151  multi << "]";
152  abego << multi.str();
153  } else {
154  abego << abego_[ ii ].at( 0 );
155  }
156  }
157  TR << "abego = " << abego.str() << std::endl;
158 }
159 
160 
161 } // namespace eval
162 } // namespace vall
163 } // namespace picking_old
164 } // namespace fragment
165 } // namespace core