annotate PsiCLASS-1.0.2/samtools-0.1.19/sam.h @ 0:903fc43d6227 draft default tip

Uploaded
author lsong10
date Fri, 26 Mar 2021 16:52:45 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
1 #ifndef BAM_SAM_H
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
2 #define BAM_SAM_H
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
3
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
4 #include "bam.h"
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
5
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
6 /*!
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
7 @header
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
8
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
9 This file provides higher level of I/O routines and unifies the APIs
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
10 for SAM and BAM formats. These APIs are more convenient and
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
11 recommended.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
12
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
13 @copyright Genome Research Ltd.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
14 */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
15
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
16 /*! @typedef
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
17 @abstract SAM/BAM file handler
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
18 @field type type of the handler; bit 1 for BAM, 2 for reading and bit 3-4 for flag format
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
19 @field bam BAM file handler; valid if (type&1) == 1
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
20 @field tamr SAM file handler for reading; valid if type == 2
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
21 @field tamw SAM file handler for writing; valid if type == 0
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
22 @field header header struct
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
23 */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
24 typedef struct {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
25 int type;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
26 union {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
27 tamFile tamr;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
28 bamFile bam;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
29 FILE *tamw;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
30 } x;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
31 bam_header_t *header;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
32 } samfile_t;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
33
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
34 #ifdef __cplusplus
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
35 extern "C" {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
36 #endif
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
37
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
38 /*!
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
39 @abstract Open a SAM/BAM file
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
40
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
41 @param fn SAM/BAM file name; "-" is recognized as stdin (for
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
42 reading) or stdout (for writing).
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
43
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
44 @param mode open mode /[rw](b?)(u?)(h?)([xX]?)/: 'r' for reading,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
45 'w' for writing, 'b' for BAM I/O, 'u' for uncompressed BAM output,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
46 'h' for outputing header in SAM, 'x' for HEX flag and 'X' for
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
47 string flag. If 'b' present, it must immediately follow 'r' or
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
48 'w'. Valid modes are "r", "w", "wh", "wx", "whx", "wX", "whX",
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
49 "rb", "wb" and "wbu" exclusively.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
50
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
51 @param aux auxiliary data; if mode[0]=='w', aux points to
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
52 bam_header_t; if strcmp(mode, "rb")!=0 and @SQ header lines in SAM
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
53 are absent, aux points the file name of the list of the reference;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
54 aux is not used otherwise. If @SQ header lines are present in SAM,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
55 aux is not used, either.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
56
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
57 @return SAM/BAM file handler
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
58 */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
59 samfile_t *samopen(const char *fn, const char *mode, const void *aux);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
60
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
61 /*!
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
62 @abstract Close a SAM/BAM handler
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
63 @param fp file handler to be closed
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
64 */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
65 void samclose(samfile_t *fp);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
66
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
67 /*!
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
68 @abstract Read one alignment
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
69 @param fp file handler
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
70 @param b alignment
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
71 @return bytes read
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
72 */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
73 int samread(samfile_t *fp, bam1_t *b);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
74
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
75 /*!
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
76 @abstract Write one alignment
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
77 @param fp file handler
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
78 @param b alignment
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
79 @return bytes written
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
80 */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
81 int samwrite(samfile_t *fp, const bam1_t *b);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
82
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
83 /*!
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
84 @abstract Get the pileup for a whole alignment file
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
85 @param fp file handler
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
86 @param mask mask transferred to bam_plbuf_set_mask()
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
87 @param func user defined function called in the pileup process
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
88 #param data user provided data for func()
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
89 */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
90 int sampileup(samfile_t *fp, int mask, bam_pileup_f func, void *data);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
91
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
92 char *samfaipath(const char *fn_ref);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
93 int samthreads(samfile_t *fp, int n_threads, int n_sub_blks);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
94
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
95 #ifdef __cplusplus
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
96 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
97 #endif
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
98
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
99 #endif