19 #ifndef AMBIGOUS_PATHS_HPP
20 #define AMBIGOUS_PATHS_HPP
22 #include "utils/scaffolding_typedefs.hpp"
29 bool maybe_ambigous_path_extremity_local(
const ScafVertex& u,
const ScaffoldGraph& sg)
31 const unsigned deg = sg.degree(u);
32 if(deg > 2)
return true;
33 if(deg == 1)
return false;
35 auto inc_iter = sg.get_incident(u);
36 assert(inc_iter.is_valid());
37 const unsigned mult = sg[*inc_iter].multiplicity;
39 assert(inc_iter.is_valid());
40 return (mult != sg[*inc_iter].multiplicity);
44 std::pair<ScafVertex,bool> is_ambigous_path_extremity(
const ScafVertex& _u,
const ScaffoldGraph& sg)
47 DEBUG5(std::cout <<
"checking "<<sg[u].name<<
" for being endpoint of an ambigous path"<<std::endl);
48 if(maybe_ambigous_path_extremity_local(u, sg)){
49 const RawScaffoldGraph& g = sg.get_graph();
52 DEBUG5(std::cout <<
"mark1"<<std::endl);
53 const ScafEdge uv = sg.incident_matching_edge(u);
54 const ScafVertex& v = boost::target(uv, g);
55 const unsigned multi = sg[uv].multiplicity;
56 DEBUG5(std::cout <<
"mark2"<<std::endl);
60 if(sg.degree(v) > 2)
return std::pair<ScafVertex, bool>(v,
true);
61 if(sg.degree(v) == 1)
return std::pair<ScafVertex, bool>(v,
false);
64 auto inc_iter = sg.get_incident(v);
65 if(sg[*inc_iter].is_matching_edge()) ++inc_iter;
66 DEBUG5(std::cout <<
"mark3"<<std::endl);
68 if(sg[*inc_iter].multiplicity != multi)
return std::pair<ScafVertex, bool>(v,
true);
70 u = boost::target(*inc_iter, g);
72 }
else return std::pair<ScafVertex, bool>(u,
false);
77 void kill_ambigous_paths_brutal(ScaffoldGraph& sg)
79 const RawScaffoldGraph& g = sg.get_graph();
80 for(
auto v_range = boost::vertices(g); v_range.first != v_range.second; ++v_range.first){
81 const ScafVertex& u = *v_range.first;
83 const std::pair<ScafVertex,bool> result = is_ambigous_path_extremity(u, sg);
85 DEBUG5(std::cout <<
"found ambigous path "<<g[u].name<<
"-->"<<g[result.first].name<<std::endl;)
87 auto inc_iter = sg.get_incident(u, MatchingPredicate<RawScaffoldGraph>(g, true));
88 while(inc_iter.is_valid()) sg.delete_edge(*(inc_iter++));
Definition: read_adj_list.hpp:22