Skip to content

Commit

Permalink
Add GDB debugging to integration test + fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adamant-pwn committed Oct 16, 2024
1 parent 90d6840 commit 7535d81
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 39 deletions.
7 changes: 6 additions & 1 deletion metagraph/integration_tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

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

METAGRAPH = f'{os.getcwd()}/metagraph'
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")

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

Expand Down
5 changes: 1 addition & 4 deletions metagraph/integration_tests/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
import glob
import os

from base import TestingBase, METAGRAPH, TEST_DATA_DIR, NUM_THREADS
from base import PROTEIN_MODE, DNA_MODE, TestingBase, METAGRAPH, TEST_DATA_DIR, NUM_THREADS


"""Test graph construction and alignment"""

DNA_MODE = os.readlink(METAGRAPH).endswith("_DNA")
PROTEIN_MODE = os.readlink(METAGRAPH).endswith("_Protein")

graph_file_extension = {'succinct': '.dbg',
'bitmap': '.bitmapdbg',
'hash': '.orhashdbg',
Expand Down
4 changes: 1 addition & 3 deletions metagraph/integration_tests/test_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import filecmp
import glob
import os
from base import TestingBase, METAGRAPH, TEST_DATA_DIR, NUM_THREADS
from base import PROTEIN_MODE, TestingBase, METAGRAPH, TEST_DATA_DIR, NUM_THREADS


"""Test graph annotation"""

PROTEIN_MODE = os.readlink(METAGRAPH).endswith("_Protein")

graph_file_extension = {'succinct': '.dbg',
'bitmap': '.bitmapdbg',
'hash': '.orhashdbg',
Expand Down
5 changes: 1 addition & 4 deletions metagraph/integration_tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
from concurrent.futures import Future
from parameterized import parameterized, parameterized_class

from base import TestingBase, METAGRAPH, TEST_DATA_DIR

PROTEIN_MODE = os.readlink(METAGRAPH).endswith("_Protein")

from base import PROTEIN_MODE, TestingBase, METAGRAPH, TEST_DATA_DIR

class TestAPIBase(TestingBase):
@classmethod
Expand Down
4 changes: 1 addition & 3 deletions metagraph/integration_tests/test_assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import gzip
import itertools
from helpers import get_test_class_name
from base import TestingBase, graph_file_extension, METAGRAPH, TEST_DATA_DIR, NUM_THREADS
from base import PROTEIN_MODE, TestingBase, graph_file_extension, METAGRAPH, TEST_DATA_DIR, NUM_THREADS
from test_query import anno_file_extension, GRAPH_TYPES, ANNO_TYPES, product


"""Test graph assemble"""

PROTEIN_MODE = os.readlink(METAGRAPH).endswith("_Protein")

gfa_tests = {
'compacted': {
'fasta_path': TEST_DATA_DIR + '/transcripts_100.fa',
Expand Down
5 changes: 1 addition & 4 deletions metagraph/integration_tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
from tempfile import TemporaryDirectory
import glob
import os
from base import TestingBase, METAGRAPH, TEST_DATA_DIR
from base import PROTEIN_MODE, DNA_MODE, TestingBase, METAGRAPH, TEST_DATA_DIR


"""Test graph construction"""

PROTEIN_MODE = os.readlink(METAGRAPH).endswith("_Protein")
DNA_MODE = os.readlink(METAGRAPH).endswith("_DNA")

graph_file_extension = {'succinct': '.dbg',
'bitmap': '.bitmapdbg',
'hash': '.orhashdbg',
Expand Down
4 changes: 1 addition & 3 deletions metagraph/integration_tests/test_build_weighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import glob
import os
import gzip
from base import TestingBase, METAGRAPH, TEST_DATA_DIR
from base import PROTEIN_MODE, TestingBase, METAGRAPH, TEST_DATA_DIR


"""Test graph construction"""

PROTEIN_MODE = os.readlink(METAGRAPH).endswith("_Protein")

graph_file_extension = {'succinct': '.dbg',
'bitmap': '.bitmapdbg',
'hash': '.orhashdbg',
Expand Down
4 changes: 1 addition & 3 deletions metagraph/integration_tests/test_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import glob
import os
import gzip
from base import TestingBase, METAGRAPH, TEST_DATA_DIR, NUM_THREADS
from base import PROTEIN_MODE, TestingBase, METAGRAPH, TEST_DATA_DIR, NUM_THREADS


"""Test graph construction"""

PROTEIN_MODE = os.readlink(METAGRAPH).endswith("_Protein")

graph_file_extension = {'succinct': '.dbg',
'bitmap': '.bitmapdbg',
'hash': '.orhashdbg',
Expand Down
5 changes: 1 addition & 4 deletions metagraph/integration_tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
import os
import numpy as np
from helpers import get_test_class_name
from base import TestingBase, METAGRAPH, TEST_DATA_DIR, graph_file_extension
from base import PROTEIN_MODE, DNA_MODE, TestingBase, METAGRAPH, TEST_DATA_DIR, graph_file_extension
import hashlib


"""Test graph construction"""

DNA_MODE = os.readlink(METAGRAPH).endswith("_DNA")
PROTEIN_MODE = os.readlink(METAGRAPH).endswith("_Protein")

anno_file_extension = {'column': '.column.annodbg',
'column_coord': '.column_coord.annodbg',
'brwt_coord': '.brwt_coord.annodbg',
Expand Down
2 changes: 0 additions & 2 deletions metagraph/integration_tests/test_transform_anno.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

"""Test operations on annotation columns"""

DNA_MODE = os.readlink(METAGRAPH).endswith("_DNA")
PROTEIN_MODE = os.readlink(METAGRAPH).endswith("_Protein")
TEST_DATA_DIR = os.path.dirname(os.path.realpath(__file__)) + '/../tests/data'

NUM_THREADS = 4
Expand Down
21 changes: 13 additions & 8 deletions metagraph/src/annotation/row_diff_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,7 @@ void build_pred_succ(const graph::DeBruijnGraph &graph,
outfbase);

std::optional<sdsl::bit_vector> dummy;
auto* succinct = dynamic_cast<graph::DBGSuccinct const*>(&graph);
if (succinct) {
if (auto* succinct = dynamic_cast<graph::DBGSuccinct const*>(&graph)) {
dummy = succinct->get_boss().mark_all_dummy_edges(num_threads);
}

Expand Down Expand Up @@ -449,16 +448,20 @@ void build_pred_succ(const graph::DeBruijnGraph &graph,
std::vector<bool> pred_boundary_buf;

for (node_index i = start; i < std::min(start + BS, graph.max_index() + 1); ++i) {
if (graph.in_graph(i)) {
if (graph.in_graph(i) && !(dummy && (*dummy)[i])) { // Legacy check for DBGSuccinct
if(!graph.has_no_outgoing(i)) {
auto j = row_diff_successor(graph, i, rd_succ);
succ_buf.push_back(to_row(j));
succ_boundary_buf.push_back(0);
if(!dummy || !(*dummy)[j]) { // Legacy check for DBGSuccinct
succ_buf.push_back(to_row(j));
succ_boundary_buf.push_back(0);
}
}
if(rd_succ[i]) {
graph.adjacent_incoming_nodes(i, [&](auto pred) {
pred_buf.push_back(to_row(pred));
pred_boundary_buf.push_back(0);
if(!dummy || !(*dummy)[pred]) { // Legacy check for DBGSuccinct
pred_buf.push_back(to_row(pred));
pred_boundary_buf.push_back(0);
}
});
}
}
Expand Down Expand Up @@ -509,8 +512,10 @@ void assign_anchors(const graph::DeBruijnGraph &graph,
sum_and_call_counts(count_vectors_dir, row_reduction_extension, "row reduction",
[&](int32_t count) {
// check if the reduction is negative
if (count < 0)
if (count < 0) {
logger->error("anchoring {}", to_node(i));
anchors_bv[to_node(i)] = true;
}
i++;
}
);
Expand Down

0 comments on commit 7535d81

Please sign in to comment.