Skip to content

Instantly share code, notes, and snippets.

@sinamajidian
Last active April 15, 2020 11:15
Show Gist options
  • Save sinamajidian/a9f694e03a21c3951740361926bfd6e2 to your computer and use it in GitHub Desktop.
Save sinamajidian/a9f694e03a21c3951740361926bfd6e2 to your computer and use it in GitHub Desktop.
Simple C API htslib
downlaod and unzip htslib
/Users/sina/Downloads/htslib-1.10.2.tar.bz2
cd /Users/sina/Downloads/htslib-1.10.2
mkdir /installation_folder
./configure --prefix=/Users/sina/Downloads/htslib-1.10.2/installation_folder
make
make install
```
#include "sam.h"
void main()
{
samFile *fp_in = hts_open("small.bam","r"); //open bam file
bam_hdr_t *bamHdr = sam_hdr_read(fp_in); //read header
bam1_t *aln = bam_init1(); //initialize an alignment
while(sam_read1(fp_in, bamHdr, aln) > 0){
printf("\t%lld\n" aln->core.pos);
}
bam_destroy1(aln);
sam_close(fp_in);
}
```
cd /Users/sina/Downloads/test5
gcc -I/Users/sina/Downloads/htslib-1.10.2/htslib -L/Users/sina/Downloads/htslib-1.10.2/ -lhts biostar151053.c
./a.out
note
here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment