Skip to content

Commit 09e7e86

Browse files
committed
feat: add chopper fast-layout wrapper
1 parent 2aa71e7 commit 09e7e86

File tree

9 files changed

+92
-1
lines changed

9 files changed

+92
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ CPMGetPackage (use_ccache)
7474
CPMGetPackage (seqan3)
7575
CPMGetPackage (sharg)
7676
CPMGetPackage (hibf)
77+
CPMGetPackage (chopper)
7778

7879
# Add the application. This will include `src/CMakeLists.txt`.
7980
add_subdirectory (src)

cmake/package-lock.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ CPMDeclarePackage (hibf
1818
OPTIONS "INSTALL_HIBF OFF"
1919
)
2020

21+
# chopper
22+
set (NEEDLE_CHOPPER_VERSION 0d03e6e80bd4f4ce82eaa8b059590de2bf7d4f7c CACHE STRING "")
23+
CPMDeclarePackage (chopper
24+
NAME chopper
25+
GIT_TAG ${NEEDLE_CHOPPER_VERSION} # fast_layout_newest_only_fast_layout
26+
GITHUB_REPOSITORY smehringer/chopper
27+
SYSTEM TRUE
28+
OPTIONS "CHOPPER_INSTALL OFF" "CHOPPER_BUILD_DOC OFF" "CHOPPER_BUILD_TEST OFF"
29+
"CMAKE_MESSAGE_LOG_LEVEL WARNING"
30+
EXCLUDE_FROM_ALL TRUE
31+
)
32+
2133
# seqan3
2234
set (NEEDLE_SEQAN3_VERSION 3.4.0 CACHE STRING "")
2335
CPMDeclarePackage (seqan3

include/layout/layout.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
2+
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
3+
// SPDX-License-Identifier: BSD-3-Clause
4+
5+
/*!\file
6+
* \brief Provides chopper_layout.
7+
* \author Enrico Seiler <enrico.seiler AT fu-berlin.de>
8+
*/
9+
10+
#pragma once
11+
12+
#include <sharg/parser.hpp>
13+
14+
void chopper_layout(sharg::parser & parser);

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ target_link_libraries ("${PROJECT_NAME}_lib" PUBLIC sharg::sharg)
2828
target_link_libraries ("${PROJECT_NAME}_lib" PUBLIC seqan::hibf)
2929
target_include_directories ("${PROJECT_NAME}_lib" PUBLIC ../include)
3030

31+
add_subdirectory (layout)
32+
3133
add_executable ("${PROJECT_NAME}" needle.cpp)
3234
target_link_libraries ("${PROJECT_NAME}" PRIVATE "${PROJECT_NAME}_lib")
35+
target_link_libraries ("${PROJECT_NAME}" PRIVATE "${PROJECT_NAME}_layout")
3336
set_target_properties ("${PROJECT_NAME}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
3437
target_compile_definitions ("${PROJECT_NAME}" PRIVATE NEEDLE_VERSION="${NEEDLE_ARGPARSE_VERSION}")
3538
target_compile_definitions ("${PROJECT_NAME}" PRIVATE NEEDLE_DATE="${NEEDLE_ARGPARSE_DATE}")

src/layout/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
2+
# SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
5+
cmake_minimum_required (VERSION 3.25...3.30)
6+
7+
if (TARGET "${PROJECT_NAME}_layout")
8+
return ()
9+
endif ()
10+
11+
add_library ("${PROJECT_NAME}_layout" STATIC layout.cpp)
12+
target_link_libraries ("${PROJECT_NAME}_layout" PRIVATE "chopper::chopper")

src/layout/layout.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
2+
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
3+
// SPDX-License-Identifier: BSD-3-Clause
4+
5+
/*!\file
6+
* \brief Implements chopper_layout.
7+
* \author Enrico Seiler <enrico.seiler AT fu-berlin.de>
8+
*/
9+
10+
#include <chopper/chopper_layout.hpp>
11+
#include <chopper/set_up_parser.hpp>
12+
13+
void chopper_layout(sharg::parser & parser)
14+
{
15+
chopper::configuration config;
16+
set_up_parser(parser, config);
17+
parser.info.author = "Svenja Mehringer";
18+
parser.info.email = "svenja.mehringer@fu-berlin.de";
19+
20+
chopper::chopper_layout(config, parser);
21+
}

src/needle.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "estimate.hpp"
1212
#include "ibf.hpp"
1313
#include "insert.hpp"
14+
#include "layout/layout.hpp"
1415
#include "minimiser.hpp"
1516
#include "shared.hpp"
1617

@@ -618,7 +619,7 @@ int main(int argc, char const ** argv)
618619
argc,
619620
argv,
620621
sharg::update_notifications::on,
621-
{"count", "delete", "estimate", "genome", "ibf", "ibfmin", "insert", "insertmin", "minimiser"}};
622+
{"count", "delete", "estimate", "genome", "ibf", "ibfmin", "insert", "insertmin", "layout", "minimiser"}};
622623
add_parser_meta(needle_parser);
623624
needle_parser.info.description.push_back(
624625
"Needle allows you to build an Interleaved Bloom Filter (IBF) with the "
@@ -648,6 +649,8 @@ int main(int argc, char const ** argv)
648649
else if (sub_parser.info.app_name == std::string_view{"needle-insertmin"})
649650
throw sharg::parser_error{"This operation is not yet supported for Needle with HIBF."};
650651
// run_needle_insert_min(sub_parser);
652+
else if (sub_parser.info.app_name == std::string_view{"needle-layout"})
653+
chopper_layout(sub_parser);
651654
else if (sub_parser.info.app_name == std::string_view{"needle-minimiser"})
652655
run_needle_minimiser(sub_parser);
653656
}

test/cli/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ add_app_test (ibf_options_test.cpp)
1010
add_app_test (minimiser_options_test.cpp)
1111
add_app_test (estimate_options_test.cpp)
1212
add_app_test (count_options_test.cpp)
13+
add_app_test (layout_options_test.cpp)
1314
# add_app_test (delete_options_test.cpp) # Not yet supported for Needle with HIBF.

test/cli/layout_options_test.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
2+
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
3+
// SPDX-License-Identifier: BSD-3-Clause
4+
5+
#include <string> // strings
6+
7+
#include "../app_test.hpp"
8+
9+
struct needle_layout_test : public app_test
10+
{};
11+
12+
TEST_F(needle_layout_test, no_options)
13+
{
14+
app_test_result result = execute_app("layout");
15+
std::string expected{"needle-layout - Compute an HIBF layout\n"
16+
"======================================\n"
17+
" --input <file> [--output <file>] [--threads <number>] [--kmer <number>]\n"
18+
" [--fpr <number>] [--hash <number>] [--disable-estimate-union]\n"
19+
" [--disable-rearrangement]\n"
20+
" Try -h or --help for more information.\n"};
21+
EXPECT_SUCCESS(result);
22+
EXPECT_EQ(result.out, expected);
23+
EXPECT_EQ(result.err, std::string{});
24+
}

0 commit comments

Comments
 (0)