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