Entering edit mode
9.4 years ago
QVINTVS_FABIVS_MAXIMVS
★
2.6k
I want to use the htslib C API to perform this task
my $pos = "1:100-1000";
my $bam_file = "in.bam";
my @reads = get_reads_from_htslib($bam_file,$pos)
foreach(@reads) {
# do stuff...
}
I wrote it in perl but you get the idea. I can't find an example anywhere online. Does anyone have experience with htslib and getting reads from a region?
Livesaver thanks!
What function calls here come from samtools.h?
may be none :-)
Dear Pierre, I have another question. Now I have a sam file without the index file, and I want to iterate all the reads of the sam file, how can I make it? Thanks in advance.
It seems that I have to compress the sam file to bam file, and get the index file then I can make it..
Dear Pierre I used the exact code and bash line but I face an error. I've downloaded
htslib
andsamtools
and put them in the same folder as the .c file.Should I build samtools and htslib as mentioned here ?
I think so, furthermore, the code above is ~5 years old, the htslib has since much changed.
Thanks for fast respond.