diff --git a/Makefile b/Makefile deleted file mode 100644 index 82b5c9f..0000000 --- a/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 2019-2020 Guilherme de Sena Brandine -# -# Authors: Andrew D. Smith -# -# This file is part of ABISMAL. -# -# ABISMAL is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ABISMAL is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. -# - -SRC_ROOT=$(shell pwd) -all: - @make -C src SRC_ROOT=$(SRC_ROOT) all - -install: - @make -C src SRC_ROOT=$(SRC_ROOT) install - -clean: - @make -C src clean -.PHONY: clean diff --git a/Makefile.am b/Makefile.am index 46a242b..8ffc954 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,22 +17,16 @@ EXTRA_DIST = README.md LICENSE Configuration example.fq test ACLOCAL_AMFLAGS = -I m4 -AM_CPPFLAGS = -I $(top_srcdir)/src -### ADS: use AM_CXXFLAGS if these are needed -## AM_CXXFLAGS = -Wall -Wextra -Wpedantic -Wno-unknown-attributes - -TESTS = test/falco.test -TEST_EXTENSIONS = .test - -bin_PROGRAMS = falco - -falco_CXXFLAGS = $(OPENMP_CXXFLAGS) $(AM_CXXFLAGS) -falco_CPPFLAGS = -DPROGRAM_PATH=\"$(abspath $(top_srcdir))\" +# ADS: fix the order of user and project set vars; shouldn't need to worry about +# setting CXXFLAGS in configure.ac +AM_CXXFLAGS = -Wall -Wextra -Wpedantic if ENABLE_HTS -falco_CPPFLAGS += -DUSE_HTS +CPPFLAGS += -DUSE_HTS endif +bin_PROGRAMS = falco + falco_SOURCES = \ src/falco.cpp \ src/FastqStats.cpp \ @@ -52,4 +46,6 @@ falco_SOURCES = \ src/smithlab_utils.hpp \ src/aux.hpp +TESTS = test/falco.test +TEST_EXTENSIONS = .test CLEANFILES = tests_build/test_data.tgz diff --git a/configure.ac b/configure.ac index d527ac1..d9a8b9a 100644 --- a/configure.ac +++ b/configure.ac @@ -31,8 +31,11 @@ AS_IF([test "x$CXXFLAGS_set" != "xset"], [ ]) AC_MSG_NOTICE([CXXFLAGS is $CXXFLAGS]) +AC_DEFINE_UNQUOTED([PROGRAM_PATH], ["$srcdir"], + [The PROGRAM_PATH variable]) + AX_CXX_COMPILE_STDCXX_17([noext], [mandatory]) -AC_OPENMP([C++]) dnl make sure we have openmp for multi-core in falco +dnl AC_OPENMP([C++]) dnl make sure we have openmp for multi-core in falco dnl check for the Zlib library AC_CHECK_LIB([z], [zlibVersion], [], diff --git a/src/FalcoConfig.cpp b/src/FalcoConfig.cpp index d4dfbfb..1d855e3 100644 --- a/src/FalcoConfig.cpp +++ b/src/FalcoConfig.cpp @@ -17,6 +17,8 @@ #include "FastqStats.hpp" #include "html_template.hpp" +#include "config.h" + #include #include @@ -25,7 +27,7 @@ #include #include -const std::string FalcoConfig::FalcoVersion = "1.2.5"; +const std::string FalcoConfig::FalcoVersion = VERSION; /*********************************************************/ /************** DEFAULT VALUES FOR FILES *****************/ diff --git a/src/HtmlMaker.cpp b/src/HtmlMaker.cpp index 3652ac0..1dc8ca6 100644 --- a/src/HtmlMaker.cpp +++ b/src/HtmlMaker.cpp @@ -15,10 +15,13 @@ #include "HtmlMaker.hpp" +#include "config.h" + #include #include #include #include +#include void HtmlMaker::put_data(const std::string &placeholder, const std::string &data) { @@ -29,7 +32,7 @@ HtmlMaker::put_data(const std::string &placeholder, const std::string &data) { // at least one placeholder found while (pos != std::string::npos) { - html_boilerplate.replace(pos, placeholder.size(), data); + html_boilerplate.replace(pos, std::size(placeholder), data); pos = html_boilerplate.find(placeholder, pos + 1); } } @@ -37,15 +40,12 @@ HtmlMaker::put_data(const std::string &placeholder, const std::string &data) { // Comments out html pieces if analyses were skipped void HtmlMaker::put_comment(std::string &comment_begin, std::string &comment_end, - bool done) { - // put html comments if analysis was skipped - if (!done) { + const bool done) { + if (!done) { // put html comments if analysis was skipped put_data(comment_begin, ""); } - - // otherwise delete placeholder - else { + else { // otherwise delete placeholder put_data(comment_begin, ""); put_data(comment_end, ""); } @@ -53,14 +53,21 @@ HtmlMaker::put_comment(std::string &comment_begin, std::string &comment_end, void HtmlMaker::put_file_details(const FalcoConfig &falco_config) { - // Put file name in filename placeholder - put_data("{{filename}}", falco_config.filename_stripped); + using namespace std::string_literals; + static const auto left_tag = "\\{\\{"s; + static const auto right_tag = "\\}\\}"s; - // Put date on date placeholder - auto tmp = - std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - std::string time_fmt = std::string(ctime(&tmp)); - put_data("{{date}}", time_fmt); -} + std::regex filename_re(left_tag + "filename"s + right_tag); + std::regex_replace(html_boilerplate, filename_re, + falco_config.filename_stripped); -HtmlMaker::HtmlMaker() { html_boilerplate = FalcoConfig::html_template; } + using system_clock = std::chrono::system_clock; + auto time_unformatted = system_clock::to_time_t(system_clock::now()); + std::string time_formatted = std::string(ctime(&time_unformatted)); + + std::regex date_re(left_tag + "date"s + right_tag); + std::regex_replace(html_boilerplate, date_re, time_formatted); + + std::regex version_re(left_tag + "version"s + right_tag); + std::regex_replace(html_boilerplate, version_re, VERSION); +} diff --git a/src/HtmlMaker.hpp b/src/HtmlMaker.hpp index becc3a5..80f9914 100644 --- a/src/HtmlMaker.hpp +++ b/src/HtmlMaker.hpp @@ -28,14 +28,14 @@ class HtmlMaker { public: std::string html_boilerplate; - HtmlMaker(); + HtmlMaker() : html_boilerplate{FalcoConfig::html_template} {} // Fill data from module void put_data(const std::string &placeholder, const std::string &data); // Comment or remove placeholders void put_comment(std::string &comment_begin, std::string &comment_end, - bool done); + const bool done); // Put file details and date void put_file_details(const FalcoConfig &falco_config); diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 71d3428..0000000 --- a/src/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (C) 2018-2019 Andrew D. Smith -# -# Authors: Andrew D. Smith -# -# This file is part of ABISMAL. -# -# ABISMAL is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# ABISMAL is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -# License for more details. - -PROGS = falco - -CXX = g++ -CXXFLAGS = -Wall -std=c++11 -CPPFLAGS = -DPROGRAM_PATH=\"$(SRC_ROOT)\" -LDLIBS = -lz -OPTFLAGS = -O3 -DEBUGFLAGS = -g - -ifdef HAVE_HTSLIB -CPPFLAGS += -DUSE_HTS -LDLIBS += -lhts -endif - -ifdef DEBUG -CXXFLAGS += $(DEBUGFLAGS) -else -CXXFLAGS += $(OPTFLAGS) -endif - -all: $(PROGS) -install: $(PROGS) - @mkdir -p $(SRC_ROOT)/bin - @install -m 755 $(PROGS) $(SRC_ROOT)/bin - -%.o: %.cpp %.hpp - $(CXX) $(CXXFLAGS) -c -o $@ $< $(CPPFLAGS) - -$(PROGS): FalcoConfig.o FastqStats.o HtmlMaker.o Module.o OptionParser.o \ - smithlab_utils.o StreamReader.o - -%: %.cpp - $(CXX) $(CXXFLAGS) -o $@ $^ $(CPPFLAGS) $(LDLIBS) - -clean: - @-rm -f $(PROGS) *.o *.so *.a *~ -.PHONY: clean - diff --git a/src/falco.cpp b/src/falco.cpp index 2f21148..30702a8 100644 --- a/src/falco.cpp +++ b/src/falco.cpp @@ -15,20 +15,24 @@ * General Public License for more details. */ -#include -#include -#include -#include -#include #include "FalcoConfig.hpp" #include "FastqStats.hpp" #include "HtmlMaker.hpp" #include "Module.hpp" + #include "OptionParser.hpp" #include "StreamReader.hpp" #include "smithlab_utils.hpp" +#include "config.h" + +#include +#include +#include +#include +#include + // Function to get seconds elapsed in program static std::size_t get_seconds_since( @@ -162,7 +166,7 @@ write_results(const FalcoConfig &falco_config, FastqStats &stats, log_process("Writing text report to " + qc_data_file); // put header - qc_data_txt << "##Falco\t" + FalcoConfig::FalcoVersion + "\n"; + qc_data_txt << "##Falco\t" + std::string{VERSION} + "\n"; if (do_call) qc_data_txt << "##Call\t" << falco_config.call << "\n"; } @@ -262,17 +266,12 @@ write_results(const FalcoConfig &falco_config, FastqStats &stats, html << html_maker.html_boilerplate; } -[[nodiscard]] inline bool -file_exists(const std::string &file_name) { - return access(file_name.data(), F_OK) == 0; -} - int main(int argc, char *argv[]) { try { static const std::string FALCO_VERSION = - "falco " + FalcoConfig::FalcoVersion; + "falco " + std::string{VERSION}; bool help = false; bool version = false; @@ -633,7 +632,7 @@ main(int argc, char *argv[]) { // check if all filenames exist bool all_files_exist = true; for (std::size_t i = 0; i < std::size(all_seq_filenames); ++i) { - if (!file_exists(all_seq_filenames[i])) { + if (!std::filesystem::exists(all_seq_filenames[i])) { std::cerr << "ERROR! File does not exist: " << all_seq_filenames[i] << '\n'; all_files_exist = false; diff --git a/src/html_template.hpp b/src/html_template.hpp index 71308d8..c016b4b 100644 --- a/src/html_template.hpp +++ b/src/html_template.hpp @@ -389,7 +389,7 @@ p { -