Skip to content

Commit d6c88e4

Browse files
src/analysis/nanopore.cpp src/dnmtools.cpp src/CMakeLists.txt configure.ac and Makefile.am: adding condition to build for nanopore if htslib version is recent enough to support mods and user requests it
1 parent 662d6d3 commit d6c88e4

File tree

5 files changed

+51
-18
lines changed

5 files changed

+51
-18
lines changed

Makefile.am

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ ACLOCAL_AMFLAGS = -I m4
2222

2323
SUBDIRS := src/smithlab_cpp src/abismal
2424
install installdirs: SUBDIRS := $(filter-out src/smithlab_cpp src/abismal, $(SUBDIRS))
25-
AM_CPPFLAGS = -I $(top_srcdir)/src/common -I $(top_srcdir)/src/smithlab_cpp -I $(top_srcdir)/src/bamxx
25+
AM_CPPFLAGS = \
26+
-I $(top_srcdir)/src/common \
27+
-I $(top_srcdir)/src/smithlab_cpp \
28+
-I $(top_srcdir)/src/bamxx
29+
if BUILD_NANOPORE
30+
AM_CPPFLAGS += -DBUILD_NANOPORE
31+
endif
2632

2733
AM_CXXFLAGS = -Wall -Wextra -Wpedantic -Wno-unknown-attributes
2834

configure.ac

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ AC_ARG_WITH([libdeflate],
5555
[AS_HELP_STRING([--with-libdeflate], [use libdeflate for BAM output])],
5656
[with_libdeflate=yes], [with_libdeflate=no])
5757

58+
dnl arg for building with mods support in 'counts'
59+
AC_ARG_WITH([htsmods],
60+
[AS_HELP_STRING([--with-htsmods], [use HTSLib 'mods' to support Nanopore])],
61+
[with_htsmods=yes], [with_htsmods=no])
62+
5863
dnl check for required libraries
5964
AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_FAILURE(["pthread library not found"])])
6065
AC_SEARCH_LIBS([gzopen], [z], [], [AC_MSG_FAILURE(["Zlib library not found"])])
@@ -66,18 +71,22 @@ AS_IF([test "x$with_libdeflate" = "xyes"],
6671
AC_SEARCH_LIBS([hts_version], [hts], [], [AC_MSG_FAILURE([$hts_fail_msg])])
6772
AC_CHECK_HEADERS([htslib/hts.h], [], [AC_MSG_ERROR([hts.h not found])])
6873
# Require HTS_VERSION >= 102000
69-
AC_COMPILE_IFELSE(
70-
[AC_LANG_PROGRAM([[
71-
#include <htslib/hts.h>
72-
#if !defined(HTS_VERSION)
73-
# error HTS_VERSION not defined
74-
#endif
75-
#if HTS_VERSION < 102000
76-
# error htslib library too old
77-
#endif
78-
]], [[]])],
79-
[have_hts=yes],
80-
[have_hts=no]
74+
AS_IF([test "x$with_htsmods" = "xyes"],
75+
[
76+
AC_COMPILE_IFELSE(
77+
[
78+
AC_LANG_PROGRAM([[
79+
#include <htslib/hts.h>
80+
#if !defined(HTS_VERSION)
81+
# error HTS_VERSION not defined
82+
#endif
83+
#if HTS_VERSION < 102000
84+
# error htslib library too old
85+
#endif
86+
]], [[]])
87+
], [have_htsmods_version=yes], [have_htsmods_version=no])
88+
],
89+
[have_htsmods_version=yes]
8190
)
8291

8392
AC_COMPUTE_INT(
@@ -87,8 +96,13 @@ AC_COMPUTE_INT(
8796
[AC_MSG_ERROR([Could not compute HTS_VERSION])]
8897
)
8998
AC_MSG_NOTICE([Detected htslib version: $hts_version_macro])
90-
AS_IF([test "x$have_hts" != "xyes"],
91-
[AC_MSG_ERROR([Required htslib version must be at least 102000 (v1.20)])])
99+
100+
AS_IF([test "x$have_htsmods_version" != "xyes"], [
101+
AC_MSG_ERROR([
102+
HTSLib version must be at least 102000 (v1.20) for mods support
103+
])
104+
])
105+
AM_CONDITIONAL([BUILD_NANOPORE], [test "x$with_htsmods" = "xyes"])
92106

93107
AC_SEARCH_LIBS([cblas_dgemm], [gslcblas], [], [AC_MSG_FAILURE([$gsl_fail_msg])])
94108
AC_SEARCH_LIBS([gsl_blas_dgemm], [gsl], [], [AC_MSG_FAILURE([$gsl_fail_msg])])

src/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
# You should have received a copy of the GNU General Public License along with
1414
# this program. If not, see <https://www.gnu.org/licenses/>.
1515

16-
find_package(HTSLIB 1.20 REQUIRED)
16+
if(BUILD_NANOPORE)
17+
find_package(HTSLIB 1.20 REQUIRED)
18+
add_compile_definitions(BUILD_NANOPORE)
19+
else()
20+
find_package(HTSLIB REQUIRED)
21+
endif()
1722
find_package(Threads REQUIRED)
1823

1924
if(NOT TARGET bamxx)

src/analysis/nanopore.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* more details.
1717
*/
1818

19+
#ifdef BUILD_NANOPORE
20+
1921
#include "counts_header.hpp"
2022

2123
#include "OptionParser.hpp"
@@ -1085,3 +1087,5 @@ main_nanocount(int argc, char *argv[]) { // NOLINT(*-avoid-c-arrays)
10851087
}
10861088

10871089
// NOLINTEND(*-narrowing-conversions,*-pointer-arithmetic)
1090+
1091+
#endif

src/dnmtools.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ simreads(int argc, char *argv[]);
7474
int
7575
main_counts(int argc, char *argv[]);
7676
int
77-
main_nanocount(int argc, char *argv[]);
78-
int
7977
main_allelicmeth(int argc, char *argv[]);
8078
int
8179
main_amrfinder(int argc, char *argv[]);
@@ -153,6 +151,10 @@ int
153151
kmersites(int argc, char *argv[]);
154152
int
155153
main_summary(int argc, char *argv[]);
154+
#ifdef BUILD_NANOPORE
155+
int
156+
main_nanocount(int argc, char *argv[]);
157+
#endif
156158
// NOLINTEND(*-avoid-c-arrays)
157159

158160
void
@@ -188,7 +190,9 @@ main(int argc, char *argv[]) { // NOLINT(*-avoid-c-arrays)
188190
{"uniq", "remove duplicate reads from sorted mapped reads", main_uniq},
189191
{"bsrate", "compute the BS conversion rate from BS-seq reads mapped to a genome", main_bsrate},
190192
{"counts", "get methylation levels from mapped WGBS reads", main_counts},
193+
#ifdef BUILD_NANOPORE
191194
{"counts-nano", "get methylation levels from mapped nanopore reads", main_nanocount},
195+
#endif
192196
{"sym", "get CpG sites and make methylation levels symmetric", main_symmetric_cpgs},
193197
{"levels", "compute methylation summary statistics from a counts file", main_levels}}}},
194198

0 commit comments

Comments
 (0)