4 //////////////////////////////////////////////////////////////////
5 //////////////////////////////////////////////////////////////////
6 //////////////////////////////////////////////////////////////////
10 @Structure for holding current state (current alignment etc.) for iterating through
11 alignments overlapping a specified region.
12 @field b pointer to the current alignment
13 @field off pointer to an array of chunk loci (each with beg/end positions)
14 @field n_off The number of chunks
15 @field curr_off The current file positon
16 @field curr_chunk The item in a list of chunk
17 @discussion See also bam_fetch_iterate
19 struct __bam_fetch_iterator_t;
20 typedef struct __bam_fetch_iterator_t bam_fetch_iterator_t;
23 @abstract Retrieve the alignments that are overlapped with the
26 @discussion Returns iterator object to retrieve successive alignments ordered by
28 @param fp BAM file handler
29 @param idx pointer to the alignment index
30 @param tid chromosome ID as is defined in the header
31 @param beg start coordinate, 0-based
32 @param end end coordinate, 0-based
34 bam_fetch_iterator_t * bam_init_fetch_iterator(bamFile fp, const bam_index_t *idx, int tid, int beg, int end);
38 @abstract Iterates through alignments overlapped the specified region.
39 @discussion Returns pointer to successive alignments ordered by start position.
40 Returns null pointer to signal the end of the iteration.
41 The alignment data is nested within the iterator to avoid unnecessary allocations.
43 bam1_t * bam_fetch_iterate(bam_fetch_iterator_t *iter);
45 bam_fetch_iterator_t* bam_init_fetchall_iterator(bamFile fp, const bam_index_t *idx);
46 bam1_t * bam_fetchall_iterate(bam_fetch_iterator_t *iter);
48 //////////////////////////////////////////////////////////////////
49 //////////////////////////////////////////////////////////////////
50 //////////////////////////////////////////////////////////////////
51 // various helper functions
53 int pysam_bam_plbuf_push(const bam1_t *b, bam_plbuf_t *buf, int cont);
55 // accessor functions - necessary as bam_plbuf_t is hidden
56 // among the implementation
57 int pysam_get_pos( const bam_plbuf_t *buf);
58 int pysam_get_tid( const bam_plbuf_t *buf);
59 bam_pileup1_t * pysam_get_pileup( const bam_plbuf_t *buf);
61 int pysam_dispatch(int argc, char *argv[] );
63 // stand-in for macro - not wrappable in pyrex
64 void pysam_bam_destroy1( bam1_t * b );
66 // stand-in for other samtools macros
67 uint32_t * pysam_bam1_cigar( const bam1_t * b);
68 char * pysam_bam1_qname( const bam1_t * b);
69 uint8_t * pysam_bam1_seq( const bam1_t * b);
70 uint8_t * pysam_bam1_qual( const bam1_t * b);
71 uint8_t * pysam_bam1_aux( const bam1_t * b);
74 @abstract Update the variable length data within a bam1_t entry
76 Old data is deleted and the data within b are re-arranged to
77 make place for new data.
82 @param nbytes_old size of old data
83 @param nbytes_new size of new data
84 @param pos position of data
86 bam1_t * pysam_bam_update( bam1_t * b,
87 const size_t nbytes_old,
88 const size_t nbytes_new,
91 // translate a nucleotide character to binary code
92 unsigned char pysam_translate_sequence( const unsigned char s );