Bioconductor / Rsamtools

Binary alignment (BAM), FASTA, variant call (BCF), and tabix file import
https://bioconductor.org/packages/Rsamtools
Other
27 stars 27 forks source link

Issue with CRAM support install #21

Closed lmckinno closed 3 years ago

lmckinno commented 3 years ago

Hello! I am trying to install Rsamtools with cram support using BiocManager::install("Bioconductor/Rsamtools@cram"). This gives the error "hts_utilities.c:2:10: fatal error: cram/cram.h: No such file or directory". I have tried on both Mac and Linux, with Bioconductor version 1.30.10 and Rhtslib version 1.22.0. Can you help me figure out how to use the CRAM support for Rsamtools?

mtmorgan commented 3 years ago

This also requires BiocManager::install("Bioconductor/Rhtslib@enable-cram")

lmckinno commented 3 years ago

This worked for me! Thank you!

trickytank commented 2 years ago

Hi, It seems that Bioconductor/Rhtslib no longer has the enable-cram branch. I can't get that installed and still have the cram/cram.h not existing error. Any way around this? Thanks

vjcitn commented 2 years ago

This might be best posted at the support site, where a proper post would include result of sessionInfo() for which you are encountering trouble. Certainly the master branch of Rhtslib has cram/cram.h.

mtmorgan commented 2 years ago

Bioconductor/Rsamtools@cram requires use of the development branch of Bioconductor (see here for information on using the devel branch), where I have

> packageVersion("Rhtslib")
[1] ‘1.99.5’
hpages commented 2 years ago

Are we talking about a branch called enable-cram or cram? Is it for Rsamtools or Rhtslib? I see a little bit of everything in this thread.

@trickytank: As far as Rhtslib is concerned, I don't see an enable-cram branch here https://github.com/Bioconductor/Rhtslib/branches/all. Maybe there was one at some point, can't remember for sure. Anyways, my recent (and clumsy) attempt at "exposing" the CRAM stuff in Rhtslib was quickly noticed by an HTSlib expert who rightly pointed out that this was not necessary (see https://github.com/Bioconductor/Rhtslib/issues/30). So I reverted it.

Bottom line is: yes, as Martin said, first make sure that you have the latest Rhtslib, which is only available in BioC devel (BioC 3.16).

That being said, I still get the error you mentioned above when I try to install Bioconductor/Rsamtools@cram:

> packageVersion("Rhtslib")
[1] ‘1.99.5’

> BiocManager::install("Bioconductor/Rsamtools@cram")
Bioconductor version 3.16 (BiocManager 1.30.18), R 4.2.0 Patched (2022-05-04
  r82318)
Installing github package(s) 'Bioconductor/Rsamtools@cram'
Downloading GitHub repo Bioconductor/Rsamtools@cram
   checking for file ‘/tmp/RtmpFNGwRt/remotes811b450bbe1c/Bioconductor-Rsamtools-b4c2e5a/DESCRIPTION’ .✔  checking for file ‘/tmp/RtmpFNGwRt/remotes811b450bbe1c/Bioconductor-Rsamtools-b4c2e5a/DESCRIPTION’
─  preparing ‘Rsamtools’:
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘Rsamtools_2.13.3.tar.gz’

* installing *source* package ‘Rsamtools’ ...
** using staged installation
** libs
/usr/bin/gcc -I"/home/hpages/R/R-4.2.r82318/include" -DNDEBUG -D_FILE_OFFSET_BITS=64 -I'/home/hpages/R/R-4.2.r82318/library/Rhtslib/include' -I'/home/hpages/R/R-4.2.r82318/library/S4Vectors/include' -I'/home/hpages/R/R-4.2.r82318/library/IRanges/include' -I'/home/hpages/R/R-4.2.r82318/library/XVector/include' -I'/home/hpages/R/R-4.2.r82318/library/Biostrings/include' -I/usr/local/include   -fpic  -O3 -c Biostrings_stubs.c -o Biostrings_stubs.o
...
...
/usr/bin/gcc -I"/home/hpages/R/R-4.2.r82318/include" -DNDEBUG -D_FILE_OFFSET_BITS=64 -I'/home/hpages/R/R-4.2.r82318/library/Rhtslib/include' -I'/home/hpages/R/R-4.2.r82318/library/S4Vectors/include' -I'/home/hpages/R/R-4.2.r82318/library/IRanges/include' -I'/home/hpages/R/R-4.2.r82318/library/XVector/include' -I'/home/hpages/R/R-4.2.r82318/library/Biostrings/include' -I/usr/local/include   -fpic  -O3 -c hts_utilities.c -o hts_utilities.o
hts_utilities.c:2:10: fatal error: cram/cram.h: No such file or directory
    2 | #include <cram/cram.h>
      |          ^~~~~~~~~~~~~
compilation terminated.
make: *** [/home/hpages/R/R-4.2.r82318/etc/Makeconf:168: hts_utilities.o] Error 1
ERROR: compilation failed for package ‘Rsamtools’
* removing ‘/home/hpages/R/R-4.2.r82318/library/Rsamtools’
* restoring previous ‘/home/hpages/R/R-4.2.r82318/library/Rsamtools’
Warning message:
In i.p(...) :
  installation of package ‘/tmp/RtmpFNGwRt/file811b725fa87b/Rsamtools_2.13.3.tar.gz’ had non-zero exit status

@mtmorgan ?

H.

trickytank commented 2 years ago

Hi @hpages.

I was using the instructions before I commented, and the BiocManager::install("Bioconductor/Rhtslib@enable-cram") would no longer work.

I updated to the development version of Bioconductor but still get the same error too (although I thought this might be a problem at my end as I can't update all packages due to permissions).

mtmorgan commented 2 years ago

Thanks @hpages I had

> packageVersion("Rhtslib")
[1] ‘1.99.5’
> dir(system.file(package = "Rhtslib", "include", "cram"))
 [1] "cram_codecs.h"     "cram_decode.h"     "cram_encode.h"
 [4] "cram_index.h"      "cram_io.h"         "cram_samtools.h"
 [7] "cram_stats.h"      "cram_structs.h"    "cram.h"
[10] "mFILE.h"           "misc.h"            "open_trace_file.h"
[13] "os.h"              "pooled_alloc.h"    "string_alloc.h"

but forcing an update

> BiocManager::install("Rhtslib", force = TRUE)
...

I now have

> packageVersion("Rhtslib")
[1] ‘1.99.5’
> dir(system.file(package = "Rhtslib", "include", "cram"))
character(0)

so see the compilation problem.

Unfortunately Rsamtools wants to use cram_ptell()-like functionality, and copied this (there wasn't an obvious alternative) from sam.c, requiring cram/cram.h. I guess this problem was pointed out to me before https://github.com/Bioconductor/Rhtslib/issues/30#issuecomment-1136005858 I'll look into updating this...