Scaffolding  0.1
This program can assemble genome scaffolds using the pairing information in paired-end reads.
filters.hpp
Go to the documentation of this file.
1 
2 
7 #ifndef FILTERS_HPP
8 #define FILTERS_HPP
9 
10 #include "utils/utils.hpp"
11 
12 namespace scaffold{ namespace filters {
13 
15  template<class Object>
16  struct yes_filter{
17  bool operator()(const Object& x) const { return true; }
18  };
19 
21 
22  template<class Set>
24  const Set& filter_set;
25  const bool invert;
26 
28  contained_filter(const Set& _filter_set, const bool _invert = false):
29  filter_set(_filter_set), invert(_invert) {}
30 
31  // operator() comparing two keys
32  bool operator()(const typename Set::key_type& e) const {
33  return contains(filter_set, e) != invert;
34  }
35  };
36 
38 
39  template<class Graph, class Set>
41  const Set& filter_set;
42  const Graph& g;
43  bool invert;
44 
46  VP_contained_filter(const Set& _filter_set, const Graph& _g, const bool _invert = false):
47  filter_set(_filter_set), g(_g), invert(_invert) {}
48 
49  bool operator()(const Edge<Graph>& e) const {
50  return contains(filter_set, Set::value_type(boost::source(e, g), boost::target(e, g))) != invert;
51  }
52  };
53 
54 
56 
57  template<class Map>
58  struct map_filter{
59  const Map& filter_map;
60  const typename Map::mapped_type& mapped_to;
61  bool invert;
62 
64  map_filter(const Map& _filter_map, const typename Map::mapped_type& _mapped_to, const bool _invert = false):
65  filter_map(_filter_map), mapped_to(_mapped_to), invert(_invert) {}
66 
67  bool operator()(const typename Map::key_type& e) const {
68  return (filter_map.at(e) == mapped_to) != invert;
69  }
70  };
71 
72 
73 }}
74 
75 #endif
contained_filter(const Set &_filter_set, const bool _invert=false)
constructor
Definition: filters.hpp:28
Definition: read_adj_list.hpp:22
dummy filter to always say YES
Definition: filters.hpp:16
map_filter(const Map &_filter_map, const typename Map::mapped_type &_mapped_to, const bool _invert=false)
constructor initializing the map, the element and inversion flag
Definition: filters.hpp:64
VP_contained_filter(const Set &_filter_set, const Graph &_g, const bool _invert=false)
constructor initalizing filter_set and invert
Definition: filters.hpp:46
filter to work with filtered graphs that is based on a set of vertices, passed to the constructor ...
Definition: filters.hpp:23
filter to work with filtered graphs that is based on a a mapping of vertices: filter all vertices map...
Definition: filters.hpp:58
filter to work with filtered graphs that is based on a set of VertexPairs, passed to the constructor ...
Definition: filters.hpp:40
bool contains(const Set &s, const Element &el)
a more readable containment check
Definition: utils.hpp:171