Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CustomScoreSelector.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 protocols/frag_picker/CustomScoreSelector.hh
11 /// @brief provides a selector that picks best fragments based on their total score
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
15 
17 
18 // package headers
22 #include <utility/vector1.hh>
23 // utility headers
24 #include <core/types.hh>
25 #include <basic/Tracer.hh>
26 
27 namespace protocols {
28 namespace frag_picker {
29 
30 static basic::Tracer trCustomScoreSelector("protocols.frag_picker.CustomScoreSelector");
31 
33 
34 bool sort_function( ExtraScoreVector::value_type p1, ExtraScoreVector::value_type p2 ) {
35  return ( p1.second < p2.second );
36 }
37 
39  ScoredCandidatesVector1 const& input_canditates,
40  ScoredCandidatesVector1& output_selection )
41 {
42  Size n = frags_per_pos();
43  if (n > input_canditates.size())
44  n = input_canditates.size();
45  trCustomScoreSelector.Debug << "Selecting " << n << "fragments from "
46  << input_canditates.size() << " candidates" << std::endl;
47  ExtraScoreVector tmp;
48  scores::FragmentScoreMapOP map = scoring_scheme_->create_empty_map();
49  for (Size i=1; i<=input_canditates.size(); i++) {
50  scoring_scheme_->do_caching(input_canditates[i].first->get_chunk());
51  scoring_scheme_->score_fragment( input_canditates[i].first, map );
52  core::Real v = scoring_scheme_->total_score( map );
53  scoring_scheme_->clean_up();
54  ExtraScoreVector::value_type p(input_canditates[i], v);
55  tmp.push_back( p );
56  }
57 
58  std::sort(tmp.begin(), tmp.end(), sort_function);
59  for (Size i = 1; i <= n; i++) {
60  output_selection.push_back( tmp[i].first );
61  }
62 }
63 
64 
65 } // frag_picker
66 } // protocols
67