Scaffolding  0.1
This program can assemble genome scaffolds using the pairing information in paired-end reads.
rp_contig_jumps.hpp
1 /*
2  * preprocess a given graph:
3  * 1. delete reads jumping over short contigs
4  * 2.
5 */
6 
7 /* ----------------------------------------------------------------- */
8 
9 #ifndef RP_CONTIG_JUMPS_HPP
10 #define RP_CONTIG_JUMPS_HPP
11 
12 #include "utils/graph_typedefs.hpp"
13 #include "utils/instance.hpp"
14 #include "utils/scaffolding_utils.hpp"
15 
16 using namespace boost;
17 
18 namespace scaffold{
19  namespace preprocess {
20 
21  template <class Graph>
22  bool rp_contig_jumps(Instance<Graph>& I){
23  const Graph& g = *I.g;
24  bool change = false;
25 
26  for(const typename Matching<Graph>::value_type& contig : I.matched){
27  const Vertex<Graph> u = contig.first;
28  const Vertex<Graph> v = contig.second;
29  const size_t u_deg = boost::degree(u, g);
30  const size_t v_deg = boost::degree(v, g);
31  const Edge<Graph>& uv = boost::edge(u, v, g).first;
32  const size_t contig_length = boost::get(boost::edge_length, g, uv);
33 
34  // for a jump, we have to have a short contig...
35  if(contig_length < I.insert_size){
36  #warning TODO: implement detection of jumps over more than one contig
37  #warning TODO: for any given short contig, only keep the most supported jump
38  if( ( u_deg > 1) && (v_deg > 1) ){
39  // that is spanned by a 3-path
40  for(OEdgeIterRange<Graph> u_r = boost::out_edges(u, g); u_r.first != u_r.second; ++u_r.first){
41  const Edge<Graph>& ux = *u_r.first;
42  const Vertex<Graph>& x = boost::target(ux, g);
43  if(x != v){// only consider non-contigs
44  for(OEdgeIterRange<Graph> v_r = boost::out_edges(v, g); v_r.first != v_r.second; ++v_r.first){
45  const Edge<Graph>& vy = *v_r.first;
46  const Vertex<Graph>& y = boost::target(vy, g);
47  if( (y != u) && !I.is_matching_edge(x, y)){
48  const std::pair<Edge<Graph>, bool> xy_pair = boost::edge(x, y, g);
49  if(xy_pair.second){
50  const Edge<Graph>& xy = xy_pair.first;
51  // here, we have a contig-jump using ux -> xy -> vy
52  // so delete xy and distribute its weight to ux & vy
53 
54  // NOTE: distributing the weight makes experiments irreproducible
55  // since the final weight depends on which jump is treated first
56  //const size_t weight = boost::get(edge_weight, *I.g, xy);
57  //boost::put(edge_weight, *I.g, ux, (weight >> 1) + boost::get(edge_weight, *I.g, ux));
58  //boost::put(edge_weight, *I.g, vy, (weight >> 1) + boost::get(edge_weight, *I.g, vy));
59 
60 
61  DEBUG3(std::cout << "deleting jump-edge "<<EdgeAndGraph<Graph>(xy, *I.g)<<std::endl);
62  I.delete_edge(xy);
63  change = true;
64 
65  }// if
66  }// if
67  }// for
68  }// if
69  }// for
70  }// if
71  }// if
72  }// for
73  return change;
74  } // function
75 
76  } // namespace
77 } // namespace
78 
79 #endif
Definition: graph_utils.hpp:18
Definition: read_adj_list.hpp:22
bool preprocess
bool indicating whether to run preprocessing or not (currently defunct)
Definition: command_line.hpp:41