haizi-zh / bedtorch

Fast and native toolsuite for BED file manipulation
https://haizi-zh.github.io/bedtorch/
Other
3 stars 2 forks source link

Build with rhtslib 1.22.0 fails #1

Open rekado opened 3 years ago

rekado commented 3 years ago

Hi,

I'm attempting to package bedtorch for GNU Guix, the reproducible package manager. Unfortunately, it seems that there's an undeclared variable when building with rhtslib 1.22.0:

* installing *source* package ‘bedtorch’ ...
** using staged installation
** libs
g++ -std=gnu++11 -I"/gnu/store/bhdixzi1c7x4jyh93zx5aqgwzzw3i182-r-minimal-4.0.4/lib/R/include" -DNDEBUG -D_FILE_OFFSET_BITS=64 -I'/gnu/store/dvw3j61vim56rbc75baw5fb4ld075qv2-r-rcpp-1.0.6/site-library/Rcpp/include' -I'/gnu/store/95ynmhvd3xd0v1bs1g0y3hglhp52ra5v-r-rhtslib-1.22.0/site-library/Rhtslib/include' -I/usr/local/include   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/gnu/store/bhdixzi1c7x4jyh93zx5aqgwzzw3i182-r-minimal-4.0.4/lib/R/include" -DNDEBUG -D_FILE_OFFSET_BITS=64 -I'/gnu/store/dvw3j61vim56rbc75baw5fb4ld075qv2-r-rcpp-1.0.6/site-library/Rcpp/include' -I'/gnu/store/95ynmhvd3xd0v1bs1g0y3hglhp52ra5v-r-rhtslib-1.22.0/site-library/Rhtslib/include' -I/usr/local/include   -fpic  -g -O2  -c htslib.cpp -o htslib.o
htslib.cpp: In function ‘int query_regions(args_t*, tbx_conf_t*, char*, const char*, char**, int, FILE*)’:
htslib.cpp:80:46: error: ‘HTS_IDX_SAVE_REMOTE’ was not declared in this scope
         fname, fnidx, args->download_index ? HTS_IDX_SAVE_REMOTE : 0);
                                              ^~~~~~~~~~~~~~~~~~~
htslib.cpp:80:46: note: suggested alternative: ‘HTS_IDX_START’
         fname, fnidx, args->download_index ? HTS_IDX_SAVE_REMOTE : 0);
                                              ^~~~~~~~~~~~~~~~~~~
                                              HTS_IDX_START
htslib.cpp:79:18: error: ‘tbx_index_load3’ was not declared in this scope
     tbx_t *tbx = tbx_index_load3(
                  ^~~~~~~~~~~~~~~
htslib.cpp:79:18: note: suggested alternative: ‘tbx_index_load2’
     tbx_t *tbx = tbx_index_load3(
                  ^~~~~~~~~~~~~~~
                  tbx_index_load2
make: *** [/gnu/store/bhdixzi1c7x4jyh93zx5aqgwzzw3i182-r-minimal-4.0.4/lib/R/etc/Makeconf:181: htslib.o] Error 1
ERROR: compilation failed for package ‘bedtorch’
* removing ‘/gnu/store/bhxxnrz7h7g7vhmcmibj7vr72pkyiij6-r-bedtorch-0.1.8-1.3512b91/site-library/bedtorch’
command "R" "CMD" "INSTALL" "--install-tests" "--library=/gnu/store/bhxxnrz7h7g7vhmcmibj7vr72pkyiij6-r-bedtorch-0.1.8-1.3512b91/site-library/" "--built-timestamp=1970-01-01" "." failed with status 1

Indeed, there is no definition of HTS_IDX_SAVE_REMOTE in any of the headers provided in /gnu/store/95ynmhvd3xd0v1bs1g0y3hglhp52ra5v-r-rhtslib-1.22.0/site-library/Rhtslib/include.

haizi-zh commented 3 years ago

@rekado That's right. Currently, the official Rhtslib package is a wrapper over htslib 1.7 (https://github.com/Bioconductor/Rhtslib). However, htslib 1.7 is an outdated version (over 3 years), and lacks many useful features, especially the networking code. For new features, please refer to (https://github.com/samtools/htslib/releases/tag/1.12).

Some of bedtorch's read/write functionality relies on these features. That's why your build failed because of the outdated htslib version. To solve this, I forked Rhtslib and upgraded it so that it is a wrapper of htslib 1.12. I'm going to submit a pull request soon. For now, to avoid name conflict, I named my modified Rhtslib as Rhtslib12 (https://github.com/haizi-zh/Rhtslib12), and bedtorch depends on this specific version of Rhtslib (https://github.com/haizi-zh/bedtorch/blob/main/DESCRIPTION). If you're using devtools or remotes, as suggested in README, it should be fine.

BTW: thanks for being interested in this package. Currently I'm trying to improve the performance of several operations. I will release a new commit earlier next week.

rekado commented 3 years ago

Ah, I see. Thanks for clarifying!

My importer code doesn't parse the Remotes field in the DESCRIPTION file (and when I ran it the dependency still had the Rhtslib name), so I didn't notice it. I'll update the importer code in Guix and make sure to use your fork of Rhtslib.

Cheers!