Samtools C Api Examples
1
0
Entering edit mode
8.3 years ago

Greetings,

I am writing a C++ program to analyze BAM files. I am new to C and C++. I was wondering if anyone had some examples using the Samtools C headers in C++. So far I have been using the awesome Bamtools API, but I want to try the faidx.h header to access fasta sequences.

I have read the documentation, but I learn best by reading through code.

samtools c api • 6.1k views
ADD COMMENT
0
Entering edit mode

Unless you absolutely want to go for speed, why not use a BAM API in a langauge you already know. Also maybe one the other API's already supports what you want to do.

ADD REPLY
0
Entering edit mode

Yup. If I was in "a get shit done mode" I would just hammer it out in a scripting language, but I am trying to learn a compiled language.

ADD REPLY
1
Entering edit mode

Learn Java :P It is a bit more high level language and still, object oriented, type safe and fast. And there is a good BAM API, Picard: http://picard.sourceforge.net/javadoc/

ADD REPLY
2
Entering edit mode
8.3 years ago

I played with the samtools API: see http://variationtoolkit.googlecode.com/svn/trunk/src/ (warning , not everything here should be used in production, some sources are just some ideas I'm testing...)

See

http://variationtoolkit.googlecode.com/svn/trunk/src/xfaidx.cpp and xfaidx.h for a C++ wrapper around fai*

http://variationtoolkit.googlecode.com/svn/trunk/src/bam1sequence.h for a C++ wrapper around bam1_t

etc...

there is also http://samtools.sourceforge.net/sam-exam.shtml

ADD COMMENT
0
Entering edit mode

Thank you very much.

ADD REPLY
0
Entering edit mode

well, I don't think using an external library like samtools is the best way to learn C/C++. It's rather complicated . You should start with the std library an try to implement some simple things like parsing a fasta file or implementing your own version of faidx.

ADD REPLY
0
Entering edit mode

I am comfortable with the STL, getting to the point of being able to write useful tools. It would be a good exercise to implement my own fasta indexing schema.

ADD REPLY

Login before adding your answer.

Traffic: 1521 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6