Skip to content

Commit 88e2074

Browse files
committed
merge conda-build, unbundle htslib/samtools
2 parents 64a2974 + 244cd6d commit 88e2074

File tree

8 files changed

+232
-72
lines changed

8 files changed

+232
-72
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,4 @@ src/3rdparty/samtools/htslib-1.20/**/*.pico
8383

8484
# Generated docs
8585
site/
86+
output/

cmake/patch_panman.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,14 @@ HEREDOC
2828
sed -i.bak '1i\
2929
#include "pair_hash_compat.hpp"
3030
' "$SRCDIR/src/common.hpp"
31+
32+
# Fix parallel_reduce identity type mismatch (oneTBB 2022+ C++20 concepts
33+
# require exact type match: 0 is int but lambda returns size_t).
34+
# Also fix lambda taking non-const range ref (oneTBB requires const Range&).
35+
if [ -f "$SRCDIR/src/summary.cpp" ]; then
36+
sed -i.bak \
37+
-e 's/children\.size()), 0,/children.size()), (size_t)0,/g' \
38+
-e 's/\](tbb::blocked_range<size_t>\& r,/](const tbb::blocked_range<size_t>\& r,/g' \
39+
"$SRCDIR/src/summary.cpp"
40+
fi
3141
fi

recipe/CMakeLists.txt

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ project(panmap VERSION 0.1.0)
44
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
55
set(CMAKE_CXX_STANDARD 20)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pipe -Wno-unused-function -Wno-deprecated-declarations -w")
7+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -pipe -Wno-unused-function -Wno-deprecated-declarations -w")
88

9-
include(ExternalProject)
109
include(GNUInstallDirs)
1110

1211
# ===== Find all system packages =====
@@ -25,7 +24,8 @@ find_library(CAPNP_LIBRARY NAMES capnp REQUIRED)
2524
find_library(KJ_LIBRARY NAMES kj REQUIRED)
2625
find_library(DEFLATE_LIBRARY NAMES deflate REQUIRED)
2726
find_library(ZSTD_LIBRARY NAMES zstd REQUIRED)
28-
27+
find_library(HTS_LIBRARY NAMES hts REQUIRED)
28+
find_path(HTS_INCLUDE_DIR htslib/hts.h REQUIRED)
2929
find_program(CAPNP_EXECUTABLE NAMES capnp REQUIRED)
3030
find_program(CAPNPC_CXX_EXECUTABLE NAMES capnpc-c++ REQUIRED)
3131

@@ -102,7 +102,7 @@ execute_process(
102102
file(WRITE "${PANMAN_SOURCE_DIR}/CMakeLists.txt" [=[
103103
cmake_minimum_required(VERSION 3.8)
104104
project(panmanUtils)
105-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pipe -Wno-unused-function -Wno-deprecated-declarations -w")
105+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -pipe -Wno-unused-function -Wno-deprecated-declarations -w")
106106
set(CMAKE_INCLUDE_CURRENT_DIR ON)
107107
108108
find_package(Protobuf REQUIRED)
@@ -190,7 +190,7 @@ endif()
190190

191191
add_custom_command(
192192
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib/libminimap2.a
193-
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/minimap2 && make clean && make -j ${MINIMAP2_MAKE_ARGS}
193+
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/minimap2 && make clean && make -j libminimap2.a "CPPFLAGS=-I${CMAKE_INSTALL_PREFIX}/include" ${MINIMAP2_MAKE_ARGS}
194194
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/lib ${CMAKE_CURRENT_BINARY_DIR}/bin
195195
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/minimap2/libminimap2.a ${CMAKE_CURRENT_BINARY_DIR}/lib/libminimap2.a
196196
COMMAND rm -f ${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/minimap2/*.o
@@ -202,41 +202,12 @@ add_custom_target(minimap2_target
202202
COMMENT "Building minimap2 library"
203203
)
204204

205-
# Htslib
206-
set(HTSLIB_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/htslib_install)
207-
ExternalProject_Add(htslib_ext
208-
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/samtools/htslib-1.20
209-
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${HTSLIB_INSTALL_DIR}
210-
--disable-lzma --disable-bz2 --disable-libcurl --disable-libdeflate
211-
BUILD_COMMAND make -j lib-static
212-
INSTALL_COMMAND make install
213-
BUILD_IN_SOURCE 1
214-
UPDATE_COMMAND ""
215-
)
216-
add_library(htslib STATIC IMPORTED GLOBAL)
217-
set_target_properties(htslib PROPERTIES IMPORTED_LOCATION ${HTSLIB_INSTALL_DIR}/lib/libhts.a)
218-
add_dependencies(htslib htslib_ext)
219-
220-
# Samtools
221-
set(SAMTOOLS_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/samtools_build)
222-
ExternalProject_Add(samtools_ext
223-
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/samtools
224-
BINARY_DIR ${SAMTOOLS_BUILD_DIR}
225-
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy_directory
226-
${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty/samtools ${SAMTOOLS_BUILD_DIR}
227-
BUILD_COMMAND ${CMAKE_COMMAND} -E env
228-
"LDFLAGS=-L${HTSLIB_INSTALL_DIR}/lib -lz -lpthread"
229-
LD_LIBRARY_PATH=${HTSLIB_INSTALL_DIR}/lib
230-
CPPFLAGS=-I${HTSLIB_INSTALL_DIR}/include
231-
sh -c "cd ${SAMTOOLS_BUILD_DIR} && autoheader && autoconf && ./configure --with-htslib=${HTSLIB_INSTALL_DIR} --disable-lzma --disable-bz2 --disable-libcurl --disable-shared --with-pic --without-curses && make libst.a"
232-
INSTALL_COMMAND ""
233-
BUILD_IN_SOURCE 0
234-
UPDATE_COMMAND ""
235-
DEPENDS htslib_ext
205+
# Htslib (system/conda package)
206+
add_library(htslib SHARED IMPORTED GLOBAL)
207+
set_target_properties(htslib PROPERTIES
208+
IMPORTED_LOCATION "${HTS_LIBRARY}"
209+
INTERFACE_INCLUDE_DIRECTORIES "${HTS_INCLUDE_DIR}"
236210
)
237-
add_library(samtools STATIC IMPORTED GLOBAL)
238-
set_target_properties(samtools PROPERTIES IMPORTED_LOCATION "${SAMTOOLS_BUILD_DIR}/libst.a")
239-
add_dependencies(samtools samtools_ext)
240211

241212
# BWA
242213
set(BWA_SOURCES
@@ -263,7 +234,7 @@ set(BWA_SOURCES
263234
file(GLOB BCFTOOLS_SOURCES src/3rdparty/bcftools/*.c)
264235

265236
# Build dependency targets
266-
add_custom_target(build-deps DEPENDS htslib_ext samtools_ext minimap2_target capnp_tools)
237+
add_custom_target(build-deps DEPENDS minimap2_target capnp_tools)
267238

268239
add_library(minimap2 STATIC IMPORTED)
269240
set_target_properties(minimap2 PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/lib/libminimap2.a")
@@ -275,6 +246,7 @@ target_compile_options(bwa PRIVATE -fPIC -w)
275246

276247
add_library(bcftools STATIC ${BCFTOOLS_SOURCES})
277248
target_include_directories(bcftools PUBLIC src/3rdparty/bcftools)
249+
target_include_directories(bcftools PRIVATE ${HTS_INCLUDE_DIR})
278250
target_compile_options(bcftools PRIVATE -fPIC -w)
279251

280252
# ===== panmap executable =====
@@ -292,7 +264,7 @@ target_sources(panmap PRIVATE ${LITE_CAPNP_GEN_CPP})
292264
target_include_directories(panmap PRIVATE
293265
${CMAKE_CURRENT_BINARY_DIR}
294266
${CMAKE_CURRENT_SOURCE_DIR}/src/3rdparty
295-
${HTSLIB_INSTALL_DIR}/include
267+
${HTS_INCLUDE_DIR}
296268
)
297269

298270
target_link_libraries(panmap PRIVATE
@@ -301,7 +273,6 @@ target_link_libraries(panmap PRIVATE
301273
bwa
302274
bcftools
303275
minimap2
304-
samtools
305276
htslib
306277
${CAPNP_LIBRARY}
307278
${KJ_LIBRARY}

recipe/build.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#!/bin/bash
2-
set -ex
1+
#!/usr/bin/env bash
2+
set -eux
33

44
# Copy the recipe's CMakeLists.txt over the upstream one
55
cp -f "${RECIPE_DIR}/CMakeLists.txt" "${SRC_DIR}/panmap/CMakeLists.txt"
@@ -20,6 +20,12 @@ cat > "${SRC_DIR}/panmap/external/panman/src/version.hpp" <<'VEOF'
2020
#endif
2121
VEOF
2222

23+
# Revert bcftools include paths from vendored htslib to system htslib
24+
# (upstream bcftools uses <htslib/...>, panmap's fork rewrote them to relative paths)
25+
find "${SRC_DIR}/panmap/src/3rdparty/bcftools" \( -name "*.c" -o -name "*.h" \) \
26+
-exec sed -i.bak 's|"../samtools/htslib-1.20/htslib/\([^"]*\)"|<htslib/\1>|g' {} +
27+
find "${SRC_DIR}/panmap/src/3rdparty/bcftools" -name "*.bak" -delete
28+
2329
cd "${SRC_DIR}/panmap"
2430

2531
export LDFLAGS="${LDFLAGS} -L${PREFIX}/lib"
@@ -58,3 +64,4 @@ cmake --build build -j "${CPU_COUNT}"
5864

5965
install -d "${PREFIX}/bin"
6066
install -v -m 0755 build/bin/panmap "${PREFIX}/bin/"
67+
install -v -m 0755 build/panman-build/panmanUtils "${PREFIX}/bin/"

recipe/meta.yaml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,48 @@ package:
88

99
source:
1010
- url: https://github.com/amkram/panmap/archive/v{{ version }}.tar.gz
11-
sha256: fd00bcf2bbf70918d2e79590975f973b653156c91e085b89fdba2b2b8917025e
11+
sha256: 5f9d925c348331478fdaa6b1bda6c3f07fc7640c6abdb15024401fab129cd40b
1212
folder: panmap
1313
- url: https://github.com/TurakhiaLab/panman/archive/refs/tags/v{{ panman_version }}.tar.gz
1414
sha256: 6e987799cd4f713f88b6e3ddafa9b59798a210c8ff1d8b59381bbc5fd2661c72
1515
folder: panman
1616

1717
build:
1818
number: 0
19+
run_exports:
20+
- {{ pin_subpackage(name, max_pin="x.x") }}
1921

2022
requirements:
2123
build:
2224
- {{ compiler('c') }}
2325
- {{ compiler('cxx') }}
2426
- cmake
2527
- make
26-
- autoconf
27-
- automake
28-
- libtool
2928
host:
3029
- zlib
31-
- boost-cpp
30+
- htslib
31+
- libboost-devel
3232
- libprotobuf
3333
- tbb-devel
3434
- capnproto >=1.0
3535
- jsoncpp
3636
- spdlog
37-
- abseil-cpp
3837
- zstd
3938
- libdeflate
4039
- eigen
41-
run:
42-
- boost-cpp
43-
- libprotobuf
44-
- tbb
45-
- capnproto >=1.0
46-
- jsoncpp
47-
- spdlog
48-
- fmt
49-
- libabseil
50-
- zstd
51-
- libdeflate
5240

5341
test:
5442
commands:
5543
- panmap --help
44+
- panmanUtils --help
5645

5746
about:
58-
home: "https://github.com/amkram/panmap"
47+
home: "https://github.com/amkram/{{ name }}"
5948
license: "MIT"
6049
license_family: MIT
6150
license_file: "panmap/LICENSE"
6251
summary: "Pangenome-based sequence placement, alignment, and genotyping"
63-
dev_url: "https://github.com/amkram/panmap"
52+
dev_url: "https://github.com/amkram/{{ name }}"
6453

6554
extra:
6655
additional-platforms:

recipe/recipe.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
context:
2+
version: "0.1.0"
3+
panman_version: "0.1.4"
4+
5+
package:
6+
name: panmap
7+
version: ${{ version }}
8+
9+
source:
10+
- url: https://github.com/amkram/panmap/archive/v${{ version }}.tar.gz
11+
sha256: fd00bcf2bbf70918d2e79590975f973b653156c91e085b89fdba2b2b8917025e
12+
target_directory: panmap
13+
- url: https://github.com/TurakhiaLab/panman/archive/refs/tags/v${{ panman_version }}.tar.gz
14+
sha256: 6e987799cd4f713f88b6e3ddafa9b59798a210c8ff1d8b59381bbc5fd2661c72
15+
target_directory: panman
16+
17+
build:
18+
number: 0
19+
script: build.sh
20+
21+
requirements:
22+
build:
23+
- ${{ compiler('c') }}
24+
- ${{ compiler('cxx') }}
25+
- cmake
26+
- make
27+
- autoconf
28+
- automake
29+
- libtool
30+
host:
31+
- zlib
32+
- boost-cpp
33+
- libprotobuf
34+
- tbb-devel
35+
- capnproto >=1.0
36+
- jsoncpp
37+
- spdlog
38+
- abseil-cpp
39+
- zstd
40+
- docopt.cpp
41+
- libdeflate
42+
- eigen
43+
run:
44+
- boost-cpp
45+
- libprotobuf
46+
- tbb
47+
- capnproto >=1.0
48+
- jsoncpp
49+
- spdlog
50+
- fmt
51+
- libabseil
52+
- zstd
53+
- libdeflate
54+
55+
tests:
56+
- script:
57+
- panmap --help
58+
59+
about:
60+
homepage: https://github.com/amkram/panmap
61+
license: MIT
62+
license_file: panmap/LICENSE
63+
summary: Pangenome-based sequence placement, alignment, and genotyping
64+
repository: https://github.com/amkram/panmap

src/pileup.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
#include <htslib/cram.h>
2-
#include <htslib/faidx.h>
3-
#include <htslib/hts.h>
4-
#include <htslib/khash_str2int.h>
5-
#include <htslib/klist.h>
6-
#include <htslib/kstring.h>
7-
#include <htslib/sam.h>
8-
#include <samtools/bam_plcmd.h>
9-
#include <samtools/samtools.h>
1+
#include "samtools_compat.h"
102

113
void bam_and_ref_to_mplp(sam_hdr_t *header, bam1_t **bam_lines, int nbams,
124
char *ref_string, int lref, kstring_t *mplp_string);

0 commit comments

Comments
 (0)