Last active
May 7, 2020 06:45
-
-
Save brainstorm/83ab0fe91b3aaa1e73072e58319d15bb to your computer and use it in GitHub Desktop.
htslib access (un)compressed offsets, now with newest htslib featuring hts_idx_load3 method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <htslib/hts.h> | |
#include <htslib/bgzf.h> | |
#include <hts_internal.h> | |
#include <string.h> | |
#include <unistd.h> | |
int main(int argc, char **argv) | |
{ | |
hts_idx_t *baifile = NULL; | |
baifile = hts_idx_load3("htsnexus_test_NA12878.bam", | |
"htsnexus_test_NA12878.bam.bai", | |
HTS_FMT_BAI, 0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
${CC} -g -Wall -I. -L. -I../rust-htslib/hts-sys/htslib -L../rust-htslib/hts-sys/htslib -I/usr/local/opt/bzip2/include -I/usr/local/Cellar/curl-openssl/7.68.0/include -I/usr/local/Cellar/xz/5.2.4/include -I/usr/local/opt/zlib/include s3_htslib.c -o s3_htslib -llzma -lz -lbz2 -lhts | |
clean: | |
rm s3_htslib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <htslib/hfile.h> | |
#include <htslib/hts.h> | |
#include <htslib/sam.h> | |
#include <string.h> | |
#include <unistd.h> | |
//export DYLD_LIBRARY_PATH=/Users/romanvg/dev/umccr/htsget/rust-htslib/hts-sys/htslib | |
int main(int argc, char **argv) | |
{ | |
samFile *fp_in = hts_open(argv[1],"r"); //open bam file | |
bam_hdr_t *bamHdr = sam_hdr_read(fp_in); //read header | |
printf("%s\n", bamHdr->target_name[1]); | |
} |
Then, usage be like:
$ aws sso login
$ samtools view -H s3://umccr-research-dev/htsget/htsnexus_test_NA12878.bam
(...) (all header)
$ export DYLD_LIBRARY_PATH=/Users/romanvg/dev/umccr/htsget/rust-htslib/hts-sys/htslib
$ ./s3_htslib s3://umccr-research-dev/htsget/htsnexus_test_NA12878.bam
2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On OSX Compile with: