Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
QuotaCollector.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/QuotaCollector.hh
11 /// @brief Pure virtual base class for a container holding fragment candidates
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
14 #ifndef INCLUDED_protocols_frag_picker_quota_QuotaCollector_hh
15 #define INCLUDED_protocols_frag_picker_quota_QuotaCollector_hh
16 
17 // type headers
18 #include <utility/pointer/ReferenceCount.hh>
19 
20 // package headers
27 
29 
30 #include <utility/vector1.hh>
31 
32 namespace protocols {
33 namespace frag_picker {
34 namespace quota {
35 
36 /// @brief A base class for collecting fragments.
37 /// @detailed The purpose of a collector is to keep fragment candidates to the end
38 /// of vall processing. Then a selector will go through all the candidates stored
39 /// in a collector and select the final fragments
40 /// @see GrabAll collector for a possible implementation
42 public:
43 
44  QuotaCollector(Size query_size, Size frag_size) { storage_.resize(query_size-frag_size+1); frag_size_ = frag_size; }
45 
46  /// @brief Insert a fragment candidate to the container
47  bool add(std::pair<FragmentCandidateOP, scores::FragmentScoreMapOP>);
48 
49  /// @brief removes all candidates from the container
50  void clear();
51 
52  /// @brief Check how many candidates have been already collected for a given position
53  Size count_candidates(Size) const;
54 
55  /// @brief Check how many candidates have been already collected for all positions
56  Size count_candidates() const;
57 
58  /// @brief Check the size of query sequence that this object knows.
59  /// This is mainly to be ale to check if it is the same as in the other parts of
60  /// fragment picking machinery.
61  Size query_length() const { return storage_.size(); }
62 
63  //Undefined, commenting out to fix PyRosetta build ScoredCandidatesVector1 const & get_candidates(Size position_in_query) const;
64  ScoredCandidatesVector1 & get_candidates(Size position_in_query);
65 
66  /// @brief Describes what has been collected
67  void print_report(std::ostream & output,
69  ) const;
70 
71  /// @brief Inserts candidates from another QuotaCollector for a give position in the query
72  /// Candidates may or may not get inserted depending on the candidate
73  void insert(Size pos, CandidatesCollectorOP collector) {
74  QuotaCollectorOP c = dynamic_cast<QuotaCollector*> (collector());
75  if (c == 0)
76  utility_exit_with_message("Cant' cast candidates' collector to QuotaCollector. Is quota set up correctly?");
77  for(Size j=1;j<=storage_[pos].size();++j) {
78  ScoredCandidatesVector1 & content = c->get_pool(pos, j)->get_candidates(0);
79  for(Size l=1;l<=content.size();l++) storage_[pos][j]->push( content[l] );
80  }
81  }
82 
83  /// @brief list all registered pools with their capacity
84  void list_pools(std::ostream & where) const;
85 
86  /// @brief prints the number of quota pools for a given positio in query
87  Size count_pools(Size position) const {
88  return storage_[position].size();
89  }
90 
91  QuotaPoolCOP get_pool( Size position, Size pool_id ) const {
92  return storage_[position][pool_id];
93  }
94 
95  QuotaPoolOP get_pool( Size position, Size pool_id ) {
96  return storage_[position][pool_id];
97  }
98 
99  void add_pool(Size position,QuotaPoolOP the_pool) {
100  if(position <= storage_.size())
101  storage_[position].push_back(the_pool);
102  }
103 
105 
108 private:
112 };
113 
114 } // quota
115 } // frag_picker
116 } // protocols
117 
118 #endif /* INCLUDED_protocols_frag_picker_quota_QuotaCollector_HH */