Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ABEGO_SS_Pool.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/quota/ABEGO_SS_Pool.hh
11 /// @brief class for a quota pool based on secondary structure prediction and ABEGO torsion bin classification
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
14 #ifndef INCLUDED_protocols_frag_picker_quota_ABEGO_SS_Pool_hh
15 #define INCLUDED_protocols_frag_picker_quota_ABEGO_SS_Pool_hh
16 
20 
21 // package headers
23 // AUTO-REMOVED #include <protocols/frag_picker/BoundedPriorityQueue.hh>
27 // AUTO-REMOVED #include <core/fragment/SecondaryStructure.hh>
28 
29 // utility headers
30 #include <core/types.hh>
31 #include <utility/vector1.hh>
32 #include <utility/pointer/owning_ptr.hh>
33 
34 // C++ headers
35 #include <string>
36 
37 //Auto Headers
38 namespace protocols {
39 namespace frag_picker {
40 namespace quota {
41 
42 typedef LazySortedVector1<std::pair<FragmentCandidateOP,
46 
47 /// @brief represents a single pool used by quota selector
48 class ABEGO_SS_Pool : public QuotaPool {
49 public:
50  /// @brief Creates a pool of a given size and name
51  /// @param size - total number of fragments from all the pools at a given position
52  /// @param name - name assigned to this pool. This in general may be any string that
53  /// later allows one control pool's behavior from a flag file
54  /// @param abego_ss_pairs - what types of secondary structure and ABEGO this pool is accepting
55  /// @param score_components_id - which scores will be used to sort this pool
56  /// @param weights - weights for the scores that in general may be different than these used for fragment picking
57  /// @param fraction - fraction of this pool in the entire population
58  ABEGO_SS_Pool(Size,std::string,utility::vector1<std::pair<Size,Size> >,
60 
61  bool accepts(char ss_type,char abego_type) { return ss_abego_types_->check_status(ss_type,abego_type); }
62 
63  virtual ~ABEGO_SS_Pool();
64 
65  /// @brief Says how many fragments (in total) may fit into this pool
66  virtual Size total_size() const { return storage_->size(); }
67 
68  /// @brief Says how many fragments are currently in this pool
69  virtual Size current_size() const { return storage_->count_inserted();}
70 
71  /// @brief Says how many fragments can still be inserted into this pool
72  virtual Size size_left() const { return total_size() - current_size(); }
73 
74  virtual bool could_be_accepted(ScoredCandidate candidate) const;
75 
76  void resize(Size new_size) {
77  storage_->resize(new_size,new_size*buffer_factor_);
78  }
79 
80  virtual void set_fraction(Real new_fraction) {
81 
82  QuotaPool::set_fraction(new_fraction);
83  this_size_ = (Size)(total_size_*new_fraction);
84  if(this_size_<20) {
85  this_size_ = 20;
86  }
88  }
89 
90  /// @brief Push a fragment candidate into the container
91  virtual void push(ScoredCandidate candidate) {
92  storage_->push(candidate);
93  }
94 
95  // Stuff inherited from CandidatesCollector base
96 
97  /// @brief Insert a fragment candidate to the container
98  virtual bool add(ScoredCandidate);
99 
100  /// @brief removes all candidates from the container
101  void clear() { storage_->clear(); }
102 
103  /// @brief Check how many candidates have been already collected for a given position
104  /// @detailed This is a very special case - collector will be used only for a given position.
105  /// Thus it returns the total number of inserted candidates, as count_candidates() does
106  Size count_candidates(Size) const { return current_size(); }
107 
108  /// @brief Check how many candidates have been already collected for all positions
109  Size count_candidates() const { return current_size(); }
110 
111  /// @brief Check the size of query sequence that this object knows.
112  /// @detailed This is a very special case - collector will be used only for a given position and it does NOT
113  /// know the tolal size. Thus it returns always 0
114  Size query_length() const { return 0; }
115 
116  /// @brief Inserts candidates from another Collector for a give position in the query
117  /// Candidates may or may not get inserted depending on the candidate
118  void insert(Size, CandidatesCollectorOP collector) {
119  ABEGO_SS_PoolOP c = dynamic_cast<ABEGO_SS_Pool*> (collector());
120  if (c == 0)
121  utility_exit_with_message("Cant' cast candidates' collector to ABEGO_SS_Pool.");
122  ScoredCandidatesVector1 & content = c->get_candidates(0);
123  for(Size l=1;l<=content.size();l++) storage_->push( content[l] );
124  }
125 
126  /// @brief Returns all the candidate in this pool
127  ScoredCandidatesVector1 & get_candidates( Size /*position_in_query*/ ) {
128  return storage_->expose_data();
129  }
130 
131  /// @brief Describes what has been collected
132  void print_report(std::ostream &, scores::FragmentScoreManagerOP) const;
133 
134  virtual Real quota_score(ScoredCandidate candidate) const {
135 
136  Real t2(0);
137  for(Size i=1;i<=components_.size();i++)
138  t2 += candidate.second->at( components_[i] ) * weights_[i];
139 
140  return t2;
141  }
142 
143 private:
144  static char all_abego_[];
145  static char all_ss_[];
153 };
154 
155 } // quota
156 } // frag_picker
157 } // protocols
158 
159 
160 #endif /* INCLUDED_protocols_frag_picker_quota_ABEGO_SS_Pool_HH */