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
13 @copyright Genome Research Ltd.
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
39 @abstract Open a SAM/BAM file
41 @param fn SAM/BAM file name; "-" is recognized as stdin (for
42 reading) or stdout (for writing).
44 @param mode open mode /[rw](b?)(u?)(h?)([xX]?)/: 'r' for reading,
45 'w' for writing, 'b' for BAM I/O, 'u' for uncompressed BAM output,
46 'h' for outputing header in SAM, 'x' for HEX flag and 'X' for
47 string flag. If 'b' present, it must immediately follow 'r' or
48 'w'. Valid modes are "r", "w", "wh", "wx", "whx", "wX", "whX",
49 "rb", "wb" and "wbu" exclusively.
51 @param aux auxiliary data; if mode[0]=='w', aux points to
52 bam_header_t; if strcmp(mode, "rb")!=0 and @SQ header lines in SAM
53 are absent, aux points the file name of the list of the reference;
54 aux is not used otherwise. If @SQ header lines are present in SAM,
55 aux is not used, either.
57 @return SAM/BAM file handler
59 samfile_t *samopen(const char *fn, const char *mode, const void *aux);
62 @abstract Close a SAM/BAM handler
63 @param fp file handler to be closed
65 void samclose(samfile_t *fp);
68 @abstract Read one alignment
69 @param fp file handler
73 int samread(samfile_t *fp, bam1_t *b);
76 @abstract Write one alignment
77 @param fp file handler
81 int samwrite(samfile_t *fp, const bam1_t *b);
84 @abstract Get the pileup for a whole alignment file
85 @param fp file handler
86 @param mask mask transferred to bam_plbuf_set_mask()
87 @param func user defined function called in the pileup process
88 #param data user provided data for func()
90 int sampileup(samfile_t *fp, int mask, bam_pileup_f func, void *data);
92 char *samfaipath(const char *fn_ref);