2 #ifndef JUMP_PREPROCESS_HPP
3 #define JUMP_PREPROCESS_HPP
5 #include "utils/graph_typedefs.hpp"
6 #include "utils/scaffolding_typedefs.hpp"
26 void support_jump_directional(
const ScafVertexPair& xy,
28 const int contig_multi,
30 std::queue<ScafEdge>& interesting_contigs,
31 ScafJumpMap& jump_map,
32 ScafVPairDependencyMap& dependencies)
34 const RawScaffoldGraph& g = sg.get_graph();
35 const ScafVertex& x = xy.first;
36 const ScafVertex& y = xy.second;
37 const ScafVertexPair yx(y, x);
38 assert(contig_multi > 0);
41 TargetContainedPredicate<RawScaffoldGraph> nor_x_nor_y_nor_match({x, y}, g,
true,
false);
43 DEBUG5(std::cout <<
"checking small 3-paths involving "<< sg[x].name <<
"->"<< sg[y].name <<
" (len = "<<xy_length<<
")"<<std::endl);
46 for(
auto x_incident = sg.get_incident(x, nor_x_nor_y_nor_match); x_incident.is_valid(); ++x_incident){
47 const ScafEdge& xu_e = *x_incident;
48 const ScafVertex& u = boost::target(xu_e, g);
49 const ScafVertexPair ux(u, x);
50 const ScafVertexPair xu(x, u);
51 const int xu_length = sg[xu_e].length;
52 if(xu_length != NO_LENGTH){
53 for(
auto u_incident = sg.get_incident(u, nor_x_nor_y_nor_match); u_incident.is_valid(); ++u_incident){
54 const ScafEdge& uv = *u_incident;
55 const ScafVertex& v = boost::target(uv, g);
56 const int uv_length = sg[uv].length;
57 if(uv_length != NO_LENGTH){
58 int vy_length = uv_length - xy_length - xu_length;
59 DEBUG5(std::cout <<
"next 3-path: "<< sg[x].name <<
"->"<<sg[u].name <<
"->"<< sg[v].name <<
" -- len: "<<xu_length+uv_length<<std::endl);
62 std::pair<ScafEdge, bool> vy_in_sg(uv,
false);
64 vy_in_sg = sg.add_edge(v, y, ScafEdgeProperty(0, vy_length, contig_multi));
67 DEBUG5(std::cout <<
"inserted "<<sg[v].name<<
"->"<<sg[y].name<<
" of length "<<vy_length<<
" = "<<uv_length<<
" (len of "<<sg[u].name<<
"->"<<sg[v].name<<
") - "<<xy_length<<
" (len of "<<sg[x].name<<
"->"<<sg[y].name<<
") - "<<xu_length<<
" (len of "<<sg[x].name<<
"->"<<sg[u].name<<
")"<<std::endl);
69 dependencies[ScafVertexPair(y,v)].emplace_back(ux);
70 dependencies[ScafVertexPair(v,y)].emplace_back(xu);
72 interesting_contigs.push(sg.incident_matching_edge(v));
73 interesting_contigs.push(sg.incident_matching_edge(y));
74 }
else vy_in_sg.second =
true;
75 }
else vy_in_sg = sg.find_edge(v, y);
78 vy_length = sg[vy_in_sg.first].length;
79 if((vy_length != NO_LENGTH) && xu_length + uv_length + vy_length >= xy_length){
80 jump_map.DEEP_EMPLACE(ScafVertexPair(u,v),).first->second.insert(xy);
81 jump_map.DEEP_EMPLACE(ScafVertexPair(v,u),).first->second.insert(yx);
90 void support_jump(
const ScafEdge& small_contig,
92 std::queue<ScafEdge>& interesting_contigs,
93 ScafJumpMap& jump_map,
94 ScafVPairDependencyMap& dependencies)
96 const RawScaffoldGraph& g = sg.get_graph();
97 const int contig_length = sg[small_contig].length;
98 const unsigned contig_multi = sg[small_contig].multiplicity;
100 const ScafVertex left = boost::source(small_contig, g);
101 const ScafVertex right = boost::target(small_contig, g);
102 const ScafVertexPair lr(left,right);
103 const ScafVertexPair rl(right,left);
105 support_jump_directional(lr, contig_length, contig_multi, sg, interesting_contigs, jump_map, dependencies);
106 support_jump_directional(rl, contig_length, contig_multi, sg, interesting_contigs, jump_map, dependencies);
109 void preprocess_jumps(ScaffoldGraph& sg, ScafJumpMap& jump_map, ScafVPairDependencyMap& dependencies)
111 const RawScaffoldGraph& g = sg.get_graph();
113 std::queue<ScafEdge> interesting_contigs;
114 for(
auto e_it = sg.get_matching_edges(); e_it.is_valid(); ++e_it)
115 interesting_contigs.push(*e_it);
118 DEBUG5(std::cout <<
"edges of g: "<<std::endl);
119 DEBUG5(
for(
auto r = boost::edges(g); r.first != r.second; ++r.first) std::cout << sg.get_edge_name(*r.first)<<
"\t["<<sg[*r.first].length<<
"]" <<std::endl);
120 while(!interesting_contigs.empty()){
121 support_jump(interesting_contigs.front(), sg, interesting_contigs, jump_map, dependencies);
122 interesting_contigs.pop();
Definition: read_adj_list.hpp:22