Scaffolding  0.1
This program can assemble genome scaffolds using the pairing information in paired-end reads.
contig_jump_network.hpp
1 
2 
3 #ifndef CONTIG_JUMP_NETWORK_HPP
4 #define CONTIG_JUMP_NETWORK_HPP
5 
6 namespace scaffold{
7 
8  struct JumpEdgeProperty{
9  ScafEdge original;
10  unsigned index;
11  }
12  typedef boost::adjacency_list<
13  boost::hash_setS, // OutEdgeList
14  boost::hash_setS, // VertexList
15  boost::bidirectedS, // (bi)directed ?
16  boost::no_property,
17  JumpEdgeProperty
18  > JumpGraph;
19 
20  // a contig jump network is a subgraph of contigs whose total length can be fit between two contigs
22  {
23  const ScaffoldGraph& sg;
24  const ScafVertexPair jumped_edge;
25  const unsigned gap_length;
26  JumpGraph jump_graph;
27  VertexPair<JumpGraph> translated_jumped_edge;
28  std::vector<IloNumVar> edge_index_to_variable;
29 
30  // parse g forwards|backwards from u|v
31  void construct_jump_graph_directional(const bool forward, const VTranslateMap<JumpGraph, RawScaffoldGraph>& translate)
32  {
33  typedef set_queue<ScafVertex, unsigned> DistQueue;
34  const ScafMatching& M = sg.get_matching();
35  const RawScaffoldGraph& g = sg.get_graph();
36  const ScafVertex& u = jumped_edge.first;
37  const ScafVertex& v = jumped_edge.second;
38 
39  const ScafVertex& Mu = sg.matched_with(u);
40  const ScafVertex& Mv = sg.matched_with(v);
41 
42  DistQueue Q;
43  Q.insert((forward ? u : v), 0);
44  ScafVertexSet seen({u, v});
45 
46  while(!Q.empty()){
47  // first: get the minimum element of the DistQueue
48  const DistQueue::const_iterator x_pair = Q.get_min_element();
49  const ScafVertex x = x_pair->first;
50  const unsigned x_dist = x_pair->second;
51  const ScafVertex& Mx = sg.matched_with(x);
52  Q.erase(x_pair);
53 
54  for(auto range = boost::out_edges(x, g); range.first != range.second; ++range.first){
55  const ScafEdge& xy = *range.first;
56  const ScafVertex& y = sg.target(xy);
57  // check whether the contig incident with y is small enough
58  // note: the special cases that y in u, v, Mu, Mv are intentionally allowed (but y = Mx is not)
59  if(y != Mx){
60  const ScafVertex& My = sg.matched_with(y);
61  const ScafEdge yMy = boost::edge(y, My, g).first;
62  const int xy_length = sg[xy].length;
63  const int yMy_length = sg[yMy].length;
64  const int My_dist = x_dist + xy_length + yMy_length;
65 
66  assert(xy_length + yMy_length > 0);
67  DEBUG5(std::cout << "found matching edge "<< I.get_edge_name(yMy)<<" with length "<<yMy_length<<" vs gap of "<<gap_length<<std::endl);
68  if(My_dist <= gap_length){
69  // if so, add the path to the network
70 #error continue here
71  construct_contig_jump_expressions(I, x, y, 0, env, uv_map, &In_Bound, &Out_Bound, NULL, forward);
72 
73  // add y-My to the respective expressions (if it's not already there)
74  construct_contig_jump_expressions(I, y, My, yMy_length, env, uv_map, &In_Bound, &Out_Bound, &length_expr, forward);
75  // and add My to the next layer
76  if(!contains(seen, My)) {
77  Q.insert(My, My_dist);
78  seen.insert(My);
79  }
80  }// if length is OK
81  } // y is not matched with x
82  }// for all out_edges of x
83  }// while Q not empty
84  }
85 
86  // parse g to construct the jump graph
87  void construct_jump_graph()
88  {
89  }
90  public:
91 
92  ILPContigJumpNetwork(const ScaffoldGraph _sg, const ScafEdge& _jumped_edge):
93  sg(_sg),
94  jumped_edge(sg.source(_jumped_edge), sg.target(_jumped_edge)),
95  gap_length(std::max<int>(_sg[_jumped_edge].length, 0))
96  {
97  // make sure the edge is not a matching edge
98  assert(!g[jumped_edge].is_matching_edge());
99  construct_jump_graph();
100  }
101  };
102 
103 }// namespace
104 
105 #endif
Definition: contig_jump_network.hpp:8
Definition: read_adj_list.hpp:22
Definition: contig_jump_network.hpp:21
Definition: scaffold_graph.hpp:12
Definition: set_queue.hpp:20