Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VallLibrarian.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/VallLibrarian.cc
11 /// @brief Librarian that picks fragments from the Vall
12 /// @author Yih-En Andrew Ban (yab@u.washington.edu)
13 
14 // unit headers
16 
18 
19 #include <basic/options/option.hh>
20 #include <basic/options/keys/frags.OptionKeys.gen.hh>
21 
22 #include <utility/vector1.hh>
23 
24 
25 
26 namespace core {
27 namespace fragment {
28 namespace picking_old {
29 namespace vall {
30 
31 
32 // static initialization
33 basic::Tracer VallLibrarian::TR_( "core.fragment.picking_old.vall.VallLibrarian" );
34 
35 
36 /// @brief default constructor
38  Super(),
39  preallocate_( true )
40 {}
41 
42 
43 /// @brief default destructor
45 {}
46 
47 
48 /// @brief get top 'N' fragments from prior catalog()
50  Size const n,
51  BBTorsionSRFD const & srfd_type
52 ) const {
53  return fragments( 1, n, srfd_type );
54 }
55 
56 
57 /// @brief get fragments from prior catalog() [from, to]
58 /// @param from index of the first fragment in the list, indexing starts from '1'
59 /// @param to index of the last fragment in the list (inclusive)
60 /// @return filled FragDataList if sort() was called successfully, otherwise empty FragDataList
62  Size from,
63  Size to,
64  BBTorsionSRFD const & srfd_type
65 ) const
66 {
67  FragDataList fdl;
68 
69  if ( scores().size() == 0 ) {
70  return fdl;
71  }
72 
73  // auto correct range in case of error
74  if ( from < 1 ) {
75  from = 1;
76  }
77  if ( to > scores().size() ) {
78  to = scores().size();
79  }
80 
81  Scores::const_iterator begin = scores().begin() + ( from - 1 );
82  Scores::const_iterator end = scores().begin() + to;
83 
84  TR_ << "best fragment: " << ( *begin ) << std::endl;
85  TR_ << "worst fragment: " << ( *( end - 1) ) << std::endl;
86 
87  core::Real max_allowed_score( basic::options::option[ basic::options::OptionKeys::frags::picking_old_max_score ].value() );
88  //flo debug
89  //TR_ << "allscores: ";
90  core::Size num_frags_picked(1);
91  //for( Scores::const_iterator tmp_it( scores().begin() + ( from - 1 ) ); tmp_it != scores().begin() + to -1; ++tmp_it, ++hack ){
92  // TR_ << "(" << hack << "/" << *tmp_it << "),";
93  //}
94  //TR_ << std::endl;
95  //debug over
96 
97  for ( Scores::const_iterator i = begin; i != end; ++i, ++num_frags_picked ) {
98  core::Real this_score(i->score);
99  if( this_score < max_allowed_score ){
100  fdl.push_back( extent_to_fragdata( i->extent_begin, i->extent_end, srfd_type ) );
101  }
102  else {
103  if( fdl.size() == 0 ){ //in case every fragment was too bad we only take the first to prevent crash
104  TR_ << "no fragments had good score, only picking 1. this is probably a bad sign..." << std::endl;
105  fdl.push_back( extent_to_fragdata( begin->extent_begin, begin->extent_end, srfd_type ) );
106  }
107  else TR_ << "fragments with bad score (" << this_score << ") observed after fragment " << num_frags_picked << ", skipping everything afterwards." << std::endl;
108  break;
109  }
110  }
111 
112  return fdl;
113 }
114 
115 
116 /// @brief this function runs before main routine in catalog() starts
118  // do any Evaluator pre-catalog operations
119  for ( VallFragmentEvalOPs::iterator i = Super::extent_eval().begin(), ie = Super::extent_eval().end(); i != ie; ++i ) {
120  (**i).pre_catalog_op( library );
121  }
122 
123  // preallocate heuristic
124  if ( preallocate_ ) {
125  scores().reserve( library.size() );
126  }
127 }
128 
129 
130 /// @brief this function runs after main routine catalog() finishes
132  // do any Evaluator post-catalog operations
133  for ( VallFragmentEvalOPs::iterator i = Super::extent_eval().begin(), ie = Super::extent_eval().end(); i != ie; ++i ) {
134  (**i).post_catalog_op( library );
135  }
136 }
137 
138 
139 } // namespace vall
140 } // namespace picking_old
141 } // namespace fragment
142 } // namespace core