X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=pysam.git;a=blobdiff_plain;f=pysam%2Fpysam_util.h;h=89e381bbd8fee3762d56a1d7dad14b9c44f6b8a2;hp=ff5d569ee24019d8abeb0bb72b2decef7a0d707a;hb=e1756c41e7a1d7cc01fb95e42df9dd04da2d2991;hpb=aa8ecff068edbb09a03bd874fce716e93e22e53c diff --git a/pysam/pysam_util.h b/pysam/pysam_util.h index ff5d569..89e381b 100644 --- a/pysam/pysam_util.h +++ b/pysam/pysam_util.h @@ -2,74 +2,25 @@ #define PYSAM_UTIL_H ////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////// -// code for iterator - -/*! @typedef - @Structure for holding current state (current alignment etc.) for iterating through - alignments overlapping a specified region. - @field b pointer to the current alignment - @field off pointer to an array of chunk loci (each with beg/end positions) - @field n_off The number of chunks - @field curr_off The current file positon - @field curr_chunk The item in a list of chunk - @discussion See also bam_fetch_iterate -*/ -struct __bam_fetch_iterator_t; -typedef struct __bam_fetch_iterator_t bam_fetch_iterator_t; - -/*! - @abstract Retrieve the alignments that are overlapped with the - specified region. - - @discussion Returns iterator object to retrieve successive alignments ordered by - start position. - @param fp BAM file handler - @param idx pointer to the alignment index - @param tid chromosome ID as is defined in the header - @param beg start coordinate, 0-based - @param end end coordinate, 0-based -*/ -bam_fetch_iterator_t * bam_init_fetch_iterator(bamFile fp, const bam_index_t *idx, int tid, int beg, int end); - - -/*! - @abstract Iterates through alignments overlapped the specified region. - @discussion Returns pointer to successive alignments ordered by start position. - Returns null pointer to signal the end of the iteration. - The alignment data is nested within the iterator to avoid unnecessary allocations. -*/ -bam1_t * bam_fetch_iterate(bam_fetch_iterator_t *iter); - -bam_fetch_iterator_t* bam_init_fetchall_iterator(bamFile fp, const bam_index_t *idx); -bam1_t * bam_fetchall_iterate(bam_fetch_iterator_t *iter); +// set pysam standard error to point to stream +FILE * pysam_set_stderr( FILE * f ); ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// // various helper functions +// +// fill pileup buffer for next position. -int pysam_bam_plbuf_push(const bam1_t *b, bam_plbuf_t *buf, int cont); - -// accessor functions - necessary as bam_plbuf_t is hidden -// among the implementation -int pysam_get_pos( const bam_plbuf_t *buf); -int pysam_get_tid( const bam_plbuf_t *buf); -bam_pileup1_t * pysam_get_pileup( const bam_plbuf_t *buf); +int pysam_pileup_next(const bam1_t *b, + bam_plbuf_t *buf, + bam_pileup1_t ** plp, + int * tid, + int * pos, + int * n_plp); int pysam_dispatch(int argc, char *argv[] ); -// stand-in for macro - not wrappable in pyrex -void pysam_bam_destroy1( bam1_t * b ); - -// stand-in for other samtools macros -uint32_t * pysam_bam1_cigar( const bam1_t * b); -char * pysam_bam1_qname( const bam1_t * b); -uint8_t * pysam_bam1_seq( const bam1_t * b); -uint8_t * pysam_bam1_qual( const bam1_t * b); -uint8_t * pysam_bam1_aux( const bam1_t * b); - /*! @abstract Update the variable length data within a bam1_t entry @@ -91,5 +42,18 @@ bam1_t * pysam_bam_update( bam1_t * b, // translate a nucleotide character to binary code unsigned char pysam_translate_sequence( const unsigned char s ); +// defined in bam_import.c +extern unsigned char bam_nt16_table[256]; + +// translate a reference string *s* to a tid +int pysam_reference2tid( bam_header_t *header, const char * s ); + +// debugging functions +#include "glf.h" +uint32_t pysam_glf_depth( glf1_t * g); + +#include "bam_maqcns.h" +void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c ); + #endif