Scaffolding  0.1
This program can assemble genome scaffolds using the pairing information in paired-end reads.
solution.hpp
Go to the documentation of this file.
1 
2 
7 #ifndef SOLUTION_HPP
8 #define SOLUTION_HPP
9 
10 #include <list>
11 #include "utils/graph_typedefs.hpp"
12 
13 namespace scaffold{
14 
16  template<class Compare = std::less<size_t> >
17  class Solution {
18  public:
19  typedef std::pair<EdgeName, unsigned> value_type;
20  protected:
21  std::list<value_type> entries;
22  unsigned global_weight = 0;
23  public:
24 
26  bool no_solutions() const
27  {
28  return entries.empty();
29  }
30 
32  unsigned total_weight() const
33  {
34  return global_weight;
35  }
36 
38  void invalidate()
39  {
40  entries.clear();
41  global_weight = 0;
42  }
43 
46  {
47  entries.insert(entries.end(), S.entries.begin(), S.entries.end());
48  global_weight += S.global_weight;
49  }
50 
52  void add_edge_global(const EdgeName& e, const unsigned weight)
53  {
54  DEBUG4(std::cout << "registering edge ("<<e.first<<","<<e.second<<") globally"<<std::endl);
55  entries.emplace_back(e, weight);
56  global_weight += weight;
57  }
58  void add_edge_global(const VertexName& u, const VertexName& v, const unsigned weight)
59  {
60  add_edge_global(EdgeName(u,v), weight);
61  }
62 
63  friend std::ostream& operator<<(std::ostream& os, const Solution<Compare>& S)
64  {
65  return os << S.entries;
66  } // function
67  };
68 
69 
70 } // namespace
71 
72 
73 #endif
void combine_disjoint_union(const Solution< Compare > &S)
combine two solutions for the graphs g & h to form a solution for the disjoint union g + h ...
Definition: solution.hpp:45
Definition: read_adj_list.hpp:22
std::list< value_type > entries
edges of the solution paired with their weights at the time of addition
Definition: solution.hpp:21
unsigned global_weight
keeps track of the global weight for O(1) checks
Definition: solution.hpp:22
unsigned total_weight() const
return the total weight of this solution
Definition: solution.hpp:32
bool no_solutions() const
return whether there are no solutions stored in the object
Definition: solution.hpp:26
void invalidate()
invalidate this solution by removing all edges
Definition: solution.hpp:38
a solution is a list of edge names with weights; it keeps track of the overall weight for O(1) access...
Definition: solution.hpp:17
void add_edge_global(const EdgeName &e, const unsigned weight)
add an edge to the list
Definition: solution.hpp:52