Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GrabAllCollector.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/GrabAllCollector.hh
11 /// @brief
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
14 #ifndef INCLUDED_protocols_frag_picker_GrabAllCollector_hh
15 #define INCLUDED_protocols_frag_picker_GrabAllCollector_hh
16 
17 // package headers
21 // AUTO-REMOVED #include <protocols/frag_picker/scores/FragmentScoreManager.hh>
23 
24 // utility headers
25 // AUTO-REMOVED #include <utility/vector1.hh>
26 #include <core/types.hh>
27 
28 #include <utility/vector1.hh>
29 
30 
31 
32 namespace protocols {
33 namespace frag_picker {
34 
35 // Always always declare your OP typedefs if you're defining a polymorphic class.
36 // I shouldn't have to do this for you.
40 
41 
42 /// @brief Keeps all fragments candidates for the final selection
43 /// @detailed The purpose of a collector is to keep fragment candidates to the end
44 /// of vall processing. This simple implementation keeps all candidates which might
45 /// use huge memory
47 public:
48 
49  /// @brief create a collector for a given size of a query sequence
50  GrabAllCollector(Size query_size)
51  {
52  storage_.resize(query_size);
53  for (Size i = 1; i <= query_size; i++) {
56  storage_[i] = vec;
57  }
58  }
59 
60  /// @brief Insert a fragment candidate to the container
61  inline bool add( ScoredCandidate new_canditate )
62  {
63  storage_[new_canditate.first->get_first_index_in_query()].push_back(
64  new_canditate);
65  return true;
66  }
67 
68  inline void clear()
69  {
70  for(Size i=1;i<storage_.size();++i)
71  storage_[i].clear();
72  }
73 
74  /// @brief prints how many fragments have been collected for each position
76  std::ostream & output,
78  ) const {
79  output << "\n pos | count | pos | count | pos | count |\n";
80  for (Size i = 1; i <= storage_.size(); ++i) {
81  output << I(5, i) << " |" << I(6, storage_[i].size()) << " |";
82  if (i % 3 == 0)
83  output << '\n';
84  }
85  }
86 
87  /// @brief Check how many candidates have been already collected for a given position
88  inline Size count_candidates(Size seq_pos) const {
89  return storage_[seq_pos].size();
90  }
91 
92  /// @brief Check how many candidates have been already collected for all positions
93  inline Size count_candidates() const {
94 
95  Size response = 0;
96  for(Size i=1;i<=storage_.size();++i)
97  response += storage_[i].size();
98  return response;
99  }
100 
101  /// @brief Check the size of query sequence that this object knows.
102  /// This is mainly to be able to check if it is the same as in the other parts of
103  /// fragment picking machinery.
104  inline Size query_length() const {
105  return storage_.size();
106  }
107 
108  /// @brief Inserts candidates from another Collector for a give position in the query
109  inline void insert(Size pos, CandidatesCollectorOP collector) {
110  GrabAllCollectorOP c = dynamic_cast<GrabAllCollector*> (collector());
111  if (c == 0)
112  utility_exit_with_message("Cant' cast candidates' collector to GrabAllCollector.");
113  for(Size j=1;j<=storage_[pos].size();++j) {
114  ScoredCandidatesVector1 & content = c->get_candidates(pos);
115  for(Size l=1;l<=content.size();l++) storage_[pos].push_back( content[l] );
116  }
117  }
118 
119  /// @brief returns all stored fragment candidates that begins at a given position in a query
120  inline virtual ScoredCandidatesVector1 & get_candidates(Size position_in_query) {
121  return storage_.at(position_in_query);
122  }
123 
124 private:
126 };
127 
128 } // frag_picker
129 } // protocols
130 
131 
132 #endif /* INCLUDED_protocols_frag_picker_GrabAllCollector_HH */