Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CommonFragmentComparators.hh
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/CommonFragmentComparators.hh
11 /// @brief provides a few ways to compare fragment candidates
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
14 #ifndef INCLUDED_protocols_frag_picker_CommonFragmentComparators_hh
15 #define INCLUDED_protocols_frag_picker_CommonFragmentComparators_hh
16 
17 // package headers
23 
24 #include <utility/vector1.hh>
25 
26 
27 namespace protocols {
28 namespace frag_picker {
29 
30 
31 /// @brief comparator based on a sequence position in a query
33 
34 public:
35 
36  /// @brief compares two fragment candidates
37  /// @detailed returns true if second_candidate starts on the later residue than first_candidate
38  /// Using this comparator to sort fragment candidates orders them ascending by their sequence position
39  bool operator()(
40  ScoredCandidate first_candidate,
41  ScoredCandidate second_candidate) {
42  return (first_candidate.first->get_first_index_in_query()
43  < second_candidate.first->get_first_index_in_query());
44  }
45 
46 };
47 
48 /// @brief comparator based on the total score of fragments
49 /// @detailed returns true if first pair has lower total score than the second one
51 
52 public:
53  /// @brief Sets up the comparator for a given FragmentScoreManager.
54  /// @detailed Only the scoring manager knows how to calculate the total score
55  /// from a vector of small scores (those gathered in a FragmentScoreMap object)
57  scoring_ = scoring;
58  }
59 
60  /// @brief compares two fragment candidates
61  /// @detailed returns true if second pair has greater total score than the first one.
62  /// Using this comparator to sort fragment candidates order them descending according
63  /// to their total score
64  bool operator()(
65  ScoredCandidate first_candidate,
66  ScoredCandidate second_candidate) {
67  return (scoring_->total_score(first_candidate.second)
68  < scoring_->total_score(second_candidate.second));
69  }
70 
72 private:
74 };
75 
76 /// @brief comparator based on the linear combination of some score components
77 /// @detailed returns true if first pair has lower weighted score than the second one
79 
80 public:
81  /// @brief Sets up the comparator for a given FragmentScoreManager.
82  /// @detailed Only the scoring manager knows how to calculate the total score
83  /// from a vector of small scores (those gathered in a FragmentScoreMap object)
85 
86  assert ( which_components.size() == weights.size() );
87  for(Size i=1;i<=which_components.size();i++) {
88  components_.push_back( which_components[i] );
89  weights_.push_back( weights[i] );
90  }
91  }
92 
93  /// @brief compares two fragment candidates
94  /// @detailed returns true if second pair has greater total score than the first one.
95  /// Using this comparator to sort fragment candidates order them descending according
96  /// to their total score
97  bool operator()(
98  ScoredCandidate first_candidate,
99  ScoredCandidate second_candidate) {
100 
101  Real t1(0);
102  Real t2(0);
103  for(Size i=1;i<=components_.size();i++) {
104  t1 += first_candidate.second->at( components_[i] ) * weights_[i];
105  t2 += second_candidate.second->at( components_[i] ) * weights_[i];
106  }
107  return (t1 < t2);
108  }
109 
111 private:
114 };
115 
116 
117 /// @brief comparator based on one of the score components calculated for fragments
118 /// @detailed returns true if first pair has lower score component than the second one
120 
121 public:
122  /// @brief Sets up the comparator based on a given score component
123  CompareScoreComponent(Size component_id) {
124  component_id_ = component_id;
125  }
126 
127  /// @brief compares two fragment candidates
128  /// @detailed returns true if second pair has greater total score than the first one.
129  /// Using this comparator to sort fragment candidates order them ascending according
130  /// to their total score
132  ScoredCandidate first_candidate,
133  ScoredCandidate second_candidate) {
134  return (first_candidate.second->get_score_components()[component_id_]
135  < second_candidate.second->get_score_components()[component_id_]);
136  }
137 
138 private:
140 };
141 
142 } // frag_picker
143 } // protocols
144 
145 #endif /* INCLUDED_protocols_frag_picker_CommonFragmentComparators_HH */