From 823727ebdd2b092dafb4bfa37ed2f5de7975b3f5 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Thu, 7 Nov 2024 13:15:33 +0100 Subject: [PATCH] [MISC] Add and unify parser meta info --- CMakeLists.txt | 10 ++++++++++ cmake/package.cmake | 7 +++++-- src/CMakeLists.txt | 2 ++ src/main.cpp | 25 +++++++++++++++++++++---- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9bf979..740eac7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. diff --git a/cmake/package.cmake b/cmake/package.cmake index ad48e31..d2820a9 100644 --- a/cmake/package.cmake +++ b/cmake/package.cmake @@ -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: # @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a9f06d2..f2e5b6b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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}") diff --git a/src/main.cpp b/src/main.cpp index 5fab2d2..d59d846 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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."); @@ -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"; @@ -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 { @@ -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"})