Skip to content

Commit

Permalink
Test conjugate links
Browse files Browse the repository at this point in the history
  • Loading branch information
Itolstoganov committed Dec 12, 2024
1 parent a1c95de commit e7571d5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/common/assembly_graph/core/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ class DeBruijnGraph: public omnigraph::ObservableGraph<DeBruijnDataMaster> {
auto links() { return adt::make_range(link_begin(), link_end()); }
auto links() const { return adt::make_range(link_begin(), link_end()); }

size_t link_size() const {return link_storage_.size(); }

using base::AddVertex;
using base::AddEdge;

Expand Down
35 changes: 24 additions & 11 deletions src/test/debruijn/v_overlaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,42 @@ std::unordered_map<VertexId, std::string> CheckStructure(std::ifstream &graph_st
void CheckLinks(std::ifstream &graph_stream, const Graph &graph, const IdMapper &id_mapper) {
int num_links;
graph_stream >> num_links;
size_t checked_links = 0;
bool is_complex = false;
for (int i = 0; i < num_links; ++i) {
std::string first_edge_name, second_edge_name;
int overlap;
graph_stream >> first_edge_name >> second_edge_name >> overlap;
EdgeId first_edge = id_mapper[first_edge_name];
EdgeId second_edge = id_mapper[second_edge_name];
VertexId vertex = graph.EdgeEnd(first_edge);
EXPECT_EQ(vertex, graph.EdgeStart(second_edge));
EdgeId in_edge = id_mapper[first_edge_name];
EdgeId out_edge = id_mapper[second_edge_name];
EdgeId in_conjugate = graph.conjugate(in_edge);
EdgeId out_conjugate = graph.conjugate(out_edge);
VertexId vertex = graph.EdgeEnd(in_edge);
EXPECT_EQ(vertex, graph.EdgeStart(out_edge));
EXPECT_EQ(graph.conjugate(vertex), graph.EdgeEnd(out_conjugate));
if (graph.is_complex(vertex)) {
bool link_found = false;
bool conj_link_found = false;
for (const auto &link: graph.links(vertex)) {
if (graph.link(link).link.first == first_edge and graph.link(link).link.second == second_edge) {
auto link_in_edge = graph.link(link).link.first;
auto link_out_edge = graph.link(link).link.second;
if (link_in_edge == in_edge and link_out_edge == out_edge) {
link_found = true;
}
}
EXPECT_TRUE(link_found);
++checked_links;
} else {
checked_links++;
for (const auto &link: graph.links(graph.conjugate(vertex))) {
auto link_in_edge = graph.link(link).link.first;
auto link_out_edge = graph.link(link).link.second;
if (link_in_edge == out_conjugate and link_out_edge == in_conjugate) {
conj_link_found = true;
}
}
EXPECT_TRUE(link_found && conj_link_found);
is_complex = true;
}
}
EXPECT_EQ(num_links, checked_links);
if (is_complex) {
EXPECT_EQ(num_links * 2, graph.link_size());
}
}

void PerformSplits(debruijn_graph::Graph &graph, std::ifstream &ops_stream, const IdMapper &id_mapper) {
Expand Down

0 comments on commit e7571d5

Please sign in to comment.