Imported Upstream version 0.7
[pysam.git] / pysam / pysam_util.h
1 #ifndef PYSAM_UTIL_H
2 #define PYSAM_UTIL_H
3
4 //////////////////////////////////////////////////////////////////
5 /*! set pysam standard error to point to file descriptor
6
7   Setting the stderr will close the previous stderr.
8  */
9 FILE * pysam_set_stderr( int fd );
10
11 //////////////////////////////////////////////////////////////////
12 /*! set pysam standard error to /dev/null.
13   
14   Unsetting the stderr will close the previous stderr.
15  */
16 void pysam_unset_stderr();
17
18 //////////////////////////////////////////////////////////////////
19 //////////////////////////////////////////////////////////////////
20 //////////////////////////////////////////////////////////////////
21 // various helper functions
22 //
23 // fill pileup buffer for next position.
24
25 int pysam_pileup_next(const bam1_t *b,
26                       bam_plbuf_t *buf,
27                       bam_pileup1_t ** plp,
28                       int * tid,
29                       int * pos,
30                       int * n_plp);
31
32 int pysam_dispatch(int argc, char *argv[] );
33
34 /*!
35   @abstract Update the variable length data within a bam1_t entry
36
37   Old data is deleted and the data within b are re-arranged to 
38   make place for new data.
39   
40   @discussion Returns b
41
42   @param  b           bam1_t data
43   @param  nbytes_old  size of old data
44   @param  nbytes_new  size of new data
45   @param  pos         position of data
46 */
47 bam1_t * pysam_bam_update( bam1_t * b,
48                            const size_t nbytes_old,
49                            const size_t nbytes_new,
50                            uint8_t * pos );
51
52 // translate a nucleotide character to binary code
53 unsigned char pysam_translate_sequence( const unsigned char s );
54
55 // defined in bam_import.c
56 extern unsigned char bam_nt16_table[256];
57
58 // translate a reference string *s* to a tid
59 int pysam_reference2tid( bam_header_t *header, const char * s );
60
61 // return number of mapped reads for tid
62 uint32_t pysam_get_mapped( const bam_index_t *idx, const int tid );
63
64 // return number of unmapped reads for tid
65 uint32_t pysam_get_unmapped( const bam_index_t *idx, const int tid );
66
67 // debugging functions
68 /* #include "glf.h" */
69 /* uint32_t pysam_glf_depth( glf1_t * g); */
70
71 /* #include "bam_maqcns.h" */
72 /* void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c ); */
73
74
75 // return size of auxilliary type
76 // int bam_aux_type2size(int x);
77
78 #endif