Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a debugging compilation option for showing list of NAMs #427

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include(FetchContent)

option(ENABLE_AVX "Enable AVX2 support" OFF)
option(PYTHON_BINDINGS "Build Python bindings" OFF)
option(TRACE "Highly verbose debugging output" OFF)

find_package(ZLIB)
find_package(Threads)
Expand Down Expand Up @@ -69,6 +70,10 @@ target_link_libraries(salib PUBLIC ZLIB::ZLIB Threads::Threads zstr::zstr)
IF(ENABLE_AVX)
target_compile_options(salib PUBLIC "-mavx2")
ENDIF()
if (TRACE)
target_compile_definitions(salib PUBLIC "TRACE")
endif()

add_dependencies(salib version)

add_executable(strobealign src/main.cpp)
Expand Down
13 changes: 12 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@ more focused discussion.
When compiling strobealign, you can add `-DCMAKE_BUILD_TYPE=RelWithDebInfo` to
the `cmake` options to get debug symbols.

If needed, run `make` with `VERBOSE=1` to get more logging output.
If needed, run `make` with `VERBOSE=1` to get more logging output at build
time.

To get more logging output when running strobealign, add the `-v` option to
the command line.

Add `--details` to get more detailed SAM output with some
strobealign-specific tags added to each alignment record.
(See below.)

To get even more verbose output, add `-DTRACE=ON` to your CMake options and
re-compile strobealign. This outputs a list of the found NAMs for each read.

## Testing

Expand Down
19 changes: 19 additions & 0 deletions src/aln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,18 @@ void align_or_map_paired(
nams_pair[is_revcomp] = nams;
}

#ifdef TRACE
for (int is_revcomp : {0, 1}) {
const auto& record = is_revcomp == 0 ? record1 : record2;
std::cerr << "R" << is_revcomp + 1 << " name: " << record.name << '\n';
const auto& nams = nams_pair[is_revcomp];
std::cerr << "Found " << nams.size() << " NAMs\n";
for (auto& nam : nams) {
std::cerr << "- " << nam << '\n';
}
}
#endif

Timer extend_timer;
if (map_param.output_format != OutputFormat::SAM) { // PAF or abundance
Nam nam_read1;
Expand Down Expand Up @@ -1185,6 +1197,13 @@ void align_or_map_single(
shuffle_top_nams(nams, random_engine);
statistics.tot_sort_nams += nam_sort_timer.duration();

#ifdef TRACE
std::cerr << "Query: " << record.name << '\n';
std::cerr << "Found " << nams.size() << " NAMs\n";
for (auto& nam : nams) {
std::cerr << "- " << nam << '\n';
}
#endif

Timer extend_timer;
size_t n_best = 0;
Expand Down
8 changes: 7 additions & 1 deletion src/cmdline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

struct CommandLineOptions {
int n_threads { 1 };
int chunk_size { 10000 };
int chunk_size {
#ifdef TRACE
1
#else
10000
#endif
};

// Input/output
std::string output_file_name;
Expand Down
Loading