Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
adamant-pwn committed Oct 16, 2024
1 parent 7535d81 commit f4e3648
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 25 deletions.
8 changes: 5 additions & 3 deletions metagraph/integration_tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

script_path = os.path.dirname(os.path.realpath(__file__))

USE_GDB = False
METAGRAPH_EXE = f'{os.getcwd()}/metagraph'
GDB_PREFIX = 'gdb -ex run -ex quit --args ' if USE_GDB else ''
METAGRAPH = GDB_PREFIX + METAGRAPH_EXE
DNA_MODE = os.readlink(METAGRAPH_EXE).endswith("_DNA")
PROTEIN_MODE = os.readlink(METAGRAPH_EXE).endswith("_Protein")
METAGRAPH = METAGRAPH_EXE

def update_prefix(PREFIX):
global METAGRAPH
METAGRAPH = PREFIX + METAGRAPH_EXE

TEST_DATA_DIR = os.path.join(script_path, '..', 'tests', 'data')

Expand Down
7 changes: 6 additions & 1 deletion metagraph/integration_tests/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import argparse
from helpers import TimeLoggingTestResult
from base import update_prefix


"""Run all integration tests"""
Expand All @@ -31,8 +32,12 @@ def create_test_suite(filter_pattern="*"):
try:
parser = argparse.ArgumentParser(description='Metagraph integration tests.')
parser.add_argument('--test_filter', dest='filter', type=str, default="*",
help='filter test cases (default: run all)')
help='filter test cases (default: run all)')
parser.add_argument('--gdb', dest='use_gdb', action='store_true',
help='run metagraph with gdb')
args = parser.parse_args()
if args.use_gdb:
update_prefix('gdb -ex run -ex bt -ex quit --args ')

result = unittest.TextTestRunner(
resultclass=TimeLoggingTestResult
Expand Down
28 changes: 14 additions & 14 deletions metagraph/src/annotation/binary_matrix/row_diff/row_diff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ node_index row_diff_successor(const graph::DeBruijnGraph &graph,
succ = adjacent_node;
}
});
assert(succ != graph::DeBruijnGraph::npos && "a row diff successor must exist");
assert(graph.in_graph(succ) && "a row diff successor must exist");
return succ;
}
}
Expand Down Expand Up @@ -81,22 +81,22 @@ IRowDiff::get_rd_ids(const std::vector<BinaryMatrix::Row> &row_ids) const {
node_index node = graph::AnnotatedSequenceGraph::anno_to_graph_index(row);

while (true) {
if (graph_->in_graph(node)) {
row = graph::AnnotatedSequenceGraph::graph_to_anno_index(node);
assert(graph_->in_graph(node));
row = graph::AnnotatedSequenceGraph::graph_to_anno_index(node);

auto [it, is_new] = node_to_rd.try_emplace(row, node_to_rd.size());
rd_paths_trunc[i].push_back(it.value());
auto [it, is_new] = node_to_rd.try_emplace(row, node_to_rd.size());
rd_paths_trunc[i].push_back(it.value());

// If a node had been reached before, we interrupt the diff path.
// The annotation for that node will have been reconstructed earlier
// than for other nodes in this path as well. Thus, we will start
// reconstruction from that node and don't need its successors.
if (!is_new)
break;
// If a node had been reached before, we interrupt the diff path.
// The annotation for that node will have been reconstructed earlier
// than for other nodes in this path as well. Thus, we will start
// reconstruction from that node and don't need its successors.
if (!is_new)
break;

if (anchor_[row])
break;

if (anchor_[row])
break;
}
if (fork_succ_.size()) {
node = row_diff_successor(*graph_, node, fork_succ_);
} else { // Only happens in DBGSuccinct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const std::string kRowDiffForkSuccExt = ".rd_succ";

const size_t RD_PATH_RESERVE_SIZE = 2;


class IRowDiff {
public:
typedef bit_vector_small anchor_bv_type;
Expand Down
1 change: 0 additions & 1 deletion metagraph/src/annotation/row_diff_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ void assign_anchors(const graph::DeBruijnGraph &graph,
[&](int32_t count) {
// check if the reduction is negative
if (count < 0) {
logger->error("anchoring {}", to_node(i));
anchors_bv[to_node(i)] = true;
}
i++;
Expand Down
12 changes: 6 additions & 6 deletions metagraph/tests/annotation/test_converters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ TEST(RowDiff, ConvertFromColumnCompressedSameLabels) {
EXPECT_EQ(labels.size() * expected_relations[max_depth - 1],
annotator.num_relations());

for (uint32 i = 0; i < annotator.num_objects(); ++i) {
ASSERT_THAT(annotator.get_labels(i), ContainerEq(labels));
}
graph->call_nodes([&](uint32_t node_idx) {
ASSERT_THAT(annotator.get_labels(node_idx - 1), ContainerEq(labels));
});
}
}
std::filesystem::remove_all(dst_dir);
Expand Down Expand Up @@ -353,9 +353,9 @@ TEST(RowDiff, ConvertFromColumnCompressedSameLabelsMultipleColumns) {
ASSERT_EQ(graph->max_index(), annotator.num_objects());
EXPECT_EQ(expected_relations[max_depth - 1], annotator.num_relations());

for (uint32 idx = 0; idx < annotator.num_objects(); ++idx) {
ASSERT_THAT(annotator.get_labels(idx), ElementsAre(labels[i]));
}
graph->call_nodes([&](uint32_t node_idx) {
ASSERT_THAT(annotator.get_labels(node_idx - 1), ElementsAre(labels[i]));
});
}
}
}
Expand Down

0 comments on commit f4e3648

Please sign in to comment.