Skip to content

Commit

Permalink
[MISC] Add and unify parser meta info
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Nov 7, 2024
1 parent 3e221c5 commit 823727e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ project (needle
LANGUAGES CXX
VERSION 1.0.3
DESCRIPTION "A fast and space-efficient pre-filter for estimating the quantification of very large collections of nucleotide sequences"
HOMEPAGE_URL "https://github.com/seqan/needle"
)

set (NEEDLE_ARGPARSE_VERSION
"${needle_VERSION}"
CACHE STRING "Needle version to display in the help message."
)
set (NEEDLE_ARGPARSE_DATE
"2024-11-07"
CACHE STRING "Needle's \"Last update:\" date to display in the help message."
)

# This allows including `*.cmake` files from the `cmake` directory without specifying the full path.
Expand Down
7 changes: 5 additions & 2 deletions cmake/package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# SPDX-License-Identifier: BSD-3-Clause

## PACKAGE
# Change version in this file: project (needle VERSION x.x.x)
# Change version in src/main.cpp: parser.info.version = "x.x.x";
# Change in top-level CMakeLists.txt:
# Version -> project (needle VERSION x.x.x)
# Date -> set (NEEDLE_ARGPARSE_DATE "YYYY-MM-DD")
# No dependencies should be locally installed.
# To package, create a clean directory:
#
Expand All @@ -19,6 +20,8 @@
# cmake --build . --target package_source
#
# Will create needle-[VERSION]-Source.tar.xz{,.sha256}.
#
# Alternatively, the ci_install workflow will export the source package as artifact.

cmake_minimum_required (VERSION 3.7...3.30)

Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ target_include_directories ("${PROJECT_NAME}_lib" PUBLIC ../include)
add_executable ("${PROJECT_NAME}" main.cpp)
target_link_libraries ("${PROJECT_NAME}" PRIVATE "${PROJECT_NAME}_lib")
set_target_properties ("${PROJECT_NAME}" PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
target_compile_definitions ("${PROJECT_NAME}" PRIVATE NEEDLE_VERSION="${NEEDLE_ARGPARSE_VERSION}")
target_compile_definitions ("${PROJECT_NAME}" PRIVATE NEEDLE_DATE="${NEEDLE_ARGPARSE_DATE}")

include (GNUInstallDirs)
install (TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
Expand Down
25 changes: 21 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ uint32_t w_size;
uint64_t shape{};
uint64_t se;

void add_parser_meta(seqan3::argument_parser & parser)
{
parser.info.author = "Mitra Darvish";
parser.info.citation = "Needle: a fast and space-efficient prefilter for estimating the quantification of very "
"large collections of expression experiments; Mitra Darvish, Enrico Seiler, Svenja "
"Mehringer, René Rahn, and Knut Reinert; Bioinformatics, Volume 38, Issue 17, 1 September "
"2022, Pages 4100-4108. doi: https://doi.org/10.1093/bioinformatics/btac492";
parser.info.date = NEEDLE_DATE;
// REUSE-IgnoreStart
parser.info.long_copyright = "This application uses SPDX identifiers.\n"
"SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin\n"
"SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik\n"
"SPDX-License-Identifier: BSD-3-Clause";
// REUSE-IgnoreEnd
parser.info.short_copyright = "BSD 3-Clause License";
parser.info.url = "https://github.com/seqan/needle";
parser.info.version = NEEDLE_VERSION;
}

void initialise_min_arguments(seqan3::argument_parser & parser, min_arguments & args)
{
parser.add_option(args.k, 'k', "kmer", "Define k-mer size for the minimisers. Default: 20.");
Expand Down Expand Up @@ -190,8 +209,6 @@ int run_needle_estimate(seqan3::argument_parser & parser)
estimate_ibf_arguments args{};
estimate_arguments estimate_args{};
parser.info.short_description = "Estimate expression value of transcript based on the Needle index.";
parser.info.version = "1.0.3";
parser.info.author = "Mitra Darvish";

args.path_out = "expressions.out";

Expand Down Expand Up @@ -579,11 +596,10 @@ int main(int argc, char const ** argv)
argv,
seqan3::update_notifications::on,
{"count", "delete", "estimate", "genome", "ibf", "ibfmin", "insert", "insertmin", "minimiser"}};
add_parser_meta(needle_parser);
needle_parser.info.description.push_back("Needle allows you to build an Interleaved Bloom Filter (IBF) with the "
"command ibf or estimate the expression of transcripts with the command "
"estimate.");
needle_parser.info.version = "1.0.3";
needle_parser.info.author = "Mitra Darvish";

try
{
Expand All @@ -595,6 +611,7 @@ int main(int argc, char const ** argv)
return -1;
}
seqan3::argument_parser & sub_parser = needle_parser.get_sub_parser(); // hold a reference to the sub_parser
add_parser_meta(sub_parser);
if (sub_parser.info.app_name == std::string_view{"needle-count"})
run_needle_count(sub_parser);
else if (sub_parser.info.app_name == std::string_view{"needle-delete"})
Expand Down

0 comments on commit 823727e

Please sign in to comment.