Skip to content

Commit

Permalink
Make htslib optional
Browse files Browse the repository at this point in the history
  • Loading branch information
bkille committed Aug 22, 2023
1 parent 5094738 commit 4e0a780
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ option(LARGE_CONTIG "Use 64-bit integers instead of 32 bit for sequence coordina
if (LARGE_CONTIG)
add_definitions(-DLARGE_CONTIG)
endif()
option(USE_HTSLIB "Compile with htslib for --targetPrefix and --targetList" OFF)
if (USE_HTSLIB)
add_definitions(-DUSE_HTSLIB)
endif()
option(PROFILE "Prevent inlining and add debug symbols" OFF)

if (${CMAKE_BUILD_TYPE} MATCHES Release)
Expand Down Expand Up @@ -82,22 +86,26 @@ target_link_libraries(mashmap
gslcblas
m
pthread
hts
#rt
z
#assert
)
if (USE_HTSLIB)
target_link_libraries(mashmap hts)
endif()

target_link_libraries(mashmap-align
gsl
gslcblas
m
pthread
hts
#rt
z
#assert
)
if (USE_HTSLIB)
target_link_libraries(mashmap-align hts)
endif()

install(TARGETS mashmap DESTINATION bin)
install(TARGETS mashmap-align DESTINATION bin)
Expand Down
7 changes: 6 additions & 1 deletion src/common/seqiter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include <cassert>
#include <unordered_set>
#include "gzstream.h"
#ifdef USE_HTSLIB
#include <htslib/faidx.h>
#endif

namespace seqiter {

Expand All @@ -21,6 +23,7 @@ void for_each_seq_in_file(
const std::string& keep_prefix,
const std::function<void(const std::string&, const std::string&)>& func) {

#ifdef USE_HTSLIB
if ((!keep_seq.empty() || !keep_prefix.empty())
&& fai_index_exists(filename)) {
// Use index
Expand Down Expand Up @@ -55,7 +58,9 @@ void for_each_seq_in_file(
}
}
fai_destroy(faid); // Free FAI index
} else {
} else
#endif
{
// no index available
// detect file type
bool input_is_fasta = false;
Expand Down

0 comments on commit 4e0a780

Please sign in to comment.