sam_open |
Open a SAM file for reading, either uncompressed or compressed by gzip/zlib.
tamFile sam_open( const char *fn);
fn
SAM file handler
sam_close |
Close a SAM file handler
void sam_close( tamFile fp);
fp
sam_read1 |
Read one alignment from a SAM file handler
int sam_read1( tamFile fp, bam_header_t *header, bam1_t *b);
fp
header
b
0 if successful; otherwise negative
sam_header_read2 |
Read header information from a TAB-delimited list file.
bam_header_t *sam_header_read2( const char *fn_list);
fn_list
a pointer to the header structure
Each line in this file consists of chromosome name and the length of chromosome.
sam_header_read |
Read header from a SAM file (if present)
bam_header_t *sam_header_read( tamFile fp);
fp
pointer to header struct; 0 if no @SQ lines available
sam_header_parse |
Parse @SQ lines a update a header struct
int sam_header_parse( bam_header_t *h);
h
number of target sequences
bam_header_t::{n_targets,target_len,target_name} will be destroyed in the first place.
sam_header_parse_rg |
Parse @RG lines a update a header struct
int sam_header_parse_rg( bam_header_t *h);
h
number of @RG lines
bam_header_t::rg2lib will be destroyed in the first place.
bam_header_init |
Initialize a header structure.
bam_header_t *bam_header_init();
the pointer to the header structure
This function also modifies the global variable bam_is_be.
bam_header_destroy |
Destroy a header structure.
void bam_header_destroy( bam_header_t *header);
header
bam_header_read |
Read a header structure from BAM.
bam_header_t *bam_header_read( bamFile fp);
fp
pointer to the header structure
The file position indicator must be placed at the beginning of the file. Upon success, the position indicator will be set at the start of the first alignment.
bam_header_write |
Write a header structure to BAM.
int bam_header_write( bamFile fp, const bam_header_t *header);
fp
header
always 0 currently
bam_read1 |
Read an alignment from BAM.
int bam_read1( bamFile fp, bam1_t *b);
fp
b
number of bytes read from the file
The file position indicator must be placed right before an alignment. Upon success, this function will set the position indicator to the start of the next alignment. This function is not affected by the machine endianness.
bam_write1_core |
Write an alignment to BAM.
int bam_write1_core( bamFile fp, const bam1_core_t *c, int data_len, uint8_t *data);
fp
c
data_len
data
number of bytes written to the file
This function is not affected by the machine endianness.
bam_write1 |
It is equivalent to: bam_write1_core(fp, &b->core, b->data_len, b->data)
int bam_write1( bamFile fp, const bam1_t *b);
fp
b
number of bytes written to the file
bam_format1 |
Format a BAM record in the SAM format
char *bam_format1( const bam_header_t *header, const bam1_t *b);
header
b
a pointer to the SAM string
bam_plbuf_reset |
Reset a pileup buffer for another pileup process
void bam_plbuf_reset( bam_plbuf_t *buf);
buf
bam_plbuf_init |
Initialize a buffer for pileup.
bam_plbuf_t *bam_plbuf_init( bam_pileup_f func, void *data);
func
data
pointer to the pileup buffer
bam_plbuf_destroy |
Destroy a pileup buffer.
void bam_plbuf_destroy( bam_plbuf_t *buf);
buf
bam_plbuf_push |
Push an alignment to the pileup buffer.
See:
- bam_plbuf_init()" -->
int bam_plbuf_push( const bam1_t *b, bam_plbuf_t *buf);
b
buf
always 0 currently
If all the alignments covering a particular site have
been collected, this function will call the user defined function
as is provided to bam_plbuf_init(). The coordinate of the site and
all the alignments will be transferred to the user defined
function as function parameters.
When all the alignments are pushed to the buffer, this function
needs to be called with b equal to NULL. This will flush the
buffer. A pileup buffer can only be reused when bam_plbuf_reset()
is called.
bam_lplbuf_init |
bam_plbuf_init() equivalent with level calculated.
bam_lplbuf_t *bam_lplbuf_init( bam_pileup_f func, void *data);
bam_lplbuf_destroy |
bam_plbuf_destroy() equivalent with level calculated.
void bam_lplbuf_destroy( bam_lplbuf_t *tv);
bam_lplbuf_push |
bam_plbuf_push() equivalent with level calculated.
int bam_lplbuf_push( const bam1_t *b, bam_lplbuf_t *buf);
bam_lpileup_file |
bam_plbuf_file() equivalent with level calculated.
int bam_lpileup_file( bamFile fp, int mask, bam_pileup_f func, void *func_data);
bam_index_build |
Build index for a BAM file.
int bam_index_build( const char *fn);
fn
always 0 currently
Index file "fn.bai" will be created.
bam_index_load |
Load index from file "fn.bai".
bam_index_t *bam_index_load( const char *fn);
fn
pointer to the index structure
bam_index_destroy |
Destroy an index structure.
void bam_index_destroy( bam_index_t *idx);
idx
bam_fetch |
Retrieve the alignments that are overlapped with the specified region.
int bam_fetch( bamFile fp, const bam_index_t *idx, int tid, int beg, int end, void *data, bam_fetch_f func);
fp
idx
tid
beg
end
data
func
A user defined function will be called for each
retrieved alignment ordered by its start position.
bam_parse_region |
Parse a region in the format: "chr2:100,000-200,000".
void bam_parse_region( bam_header_t *header, const char *str, int *ref_id, int *begin, int *end);
header
str
ref_id
begin
end
bam_header_t::hash will be initialized if empty.
bam_aux_get |
Retrieve data of a tag
uint8_t *bam_aux_get( const bam1_t *b, const char tag[2]);
b
tag
pointer to the type and data. The first character is the
type that can be 'iIsScCdfAZH'.
Use bam_aux2?() series to convert the returned data to the corresponding type.
bam_calend |
Calculate the rightmost coordinate of an alignment on the reference genome.
uint32_t bam_calend( const bam1_core_t *c, const uint32_t *cigar);
c
cigar
the rightmost coordinate, 0-based
bam_cigar2qlen |
Calculate the length of the query sequence from CIGAR.
int32_t bam_cigar2qlen( const bam1_core_t *c, const uint32_t *cigar);
c
cigar
length of the query sequence
bam_reg2bin |
Calculate the minimum bin that contains a region [beg,end).
static inline int bam_reg2bin( uint32_t beg, uint32_t end)
beg
end
bin
bam_copy1 |
Copy an alignment
static inline bam1_t *bam_copy1( bam1_t *bdst, const bam1_t *bsrc)
bdst
bsrc
pointer to the destination alignment struct
bam_dup1 |
Duplicate an alignment
static inline bam1_t *bam_dup1( const bam1_t *src)
src
pointer to the destination alignment struct
© Genome Research Ltd. Last Updated: Saturday, June 13, 2009