modified: nfig1.py
[GalaxyCodeBases.git] / BGI / SOAPdenovo2 / sparsePregraph / inc / sam.h
blob26e7a1e126f6d752ea79a781ec3022629deffb6c
1 #ifndef BAM_SAM_H
2 #define BAM_SAM_H
4 #include "bam.h"
6 /*!
7 @header
9 This file provides higher level of I/O routines and unifies the APIs
10 for SAM and BAM formats. These APIs are more convenient and
11 recommended.
13 @copyright Genome Research Ltd.
16 /*! @typedef
17 @abstract SAM/BAM file handler
18 @field type type of the handler; bit 1 for BAM, 2 for reading and bit 3-4 for flag format
19 @field bam BAM file handler; valid if (type&1) == 1
20 @field tamr SAM file handler for reading; valid if type == 2
21 @field tamw SAM file handler for writing; valid if type == 0
22 @field header header struct
24 typedef struct
26 int type;
27 union
29 tamFile tamr;
30 bamFile bam;
31 FILE * tamw;
32 } x;
33 bam_header_t * header;
34 } samfile_t;
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 /*!
41 @abstract Open a SAM/BAM file
43 @param fn SAM/BAM file name; "-" is recognized as stdin (for
44 reading) or stdout (for writing).
46 @param mode open mode /[rw](b?)(u?)(h?)([xX]?)/: 'r' for reading,
47 'w' for writing, 'b' for BAM I/O, 'u' for uncompressed BAM output,
48 'h' for outputing header in SAM, 'x' for HEX flag and 'X' for
49 string flag. If 'b' present, it must immediately follow 'r' or
50 'w'. Valid modes are "r", "w", "wh", "wx", "whx", "wX", "whX",
51 "rb", "wb" and "wbu" exclusively.
53 @param aux auxiliary data; if mode[0]=='w', aux points to
54 bam_header_t; if strcmp(mode, "rb")!=0 and @SQ header lines in SAM
55 are absent, aux points the file name of the list of the reference;
56 aux is not used otherwise. If @SQ header lines are present in SAM,
57 aux is not used, either.
59 @return SAM/BAM file handler
61 samfile_t * samopen ( const char * fn, const char * mode, const void * aux );
63 /*!
64 @abstract Close a SAM/BAM handler
65 @param fp file handler to be closed
67 void samclose ( samfile_t * fp );
69 /*!
70 @abstract Read one alignment
71 @param fp file handler
72 @param b alignment
73 @return bytes read
75 int samread ( samfile_t * fp, bam1_t * b );
77 /*!
78 @abstract Write one alignment
79 @param fp file handler
80 @param b alignment
81 @return bytes written
83 int samwrite ( samfile_t * fp, const bam1_t * b );
85 /*!
86 @abstract Get the pileup for a whole alignment file
87 @param fp file handler
88 @param mask mask transferred to bam_plbuf_set_mask()
89 @param func user defined function called in the pileup process
90 #param data user provided data for func()
92 int sampileup ( samfile_t * fp, int mask, bam_pileup_f func, void * data );
94 char * samfaipath ( const char * fn_ref );
96 #ifdef __cplusplus
98 #endif
100 #endif