Thanks to visit codestin.com
Credit goes to code.bioconductor.org

Browse code

Add DAPAR, gcatest, iCheck, Imetagene, lfa, MEAL, metagenomeFeatures, pathVar, Prostar, SICtools, SISPA, SWATH2stats

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/SICtools@109238 bc3139a8-67e5-0310-9ffc-ced21a209358

James Hester authored on 06/10/2015 17:15:15
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,99 @@
1
+#ifndef BAM_SAM_H
2
+#define BAM_SAM_H
3
+
4
+#include "bam.h"
5
+
6
+/*!
7
+  @header
8
+
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.
12
+
13
+  @copyright Genome Research Ltd.
14
+ */
15
+
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
23
+ */
24
+typedef struct {
25
+	int type;
26
+	union {
27
+		tamFile tamr;
28
+		bamFile bam;
29
+		FILE *tamw;
30
+	} x;
31
+	bam_header_t *header;
32
+} samfile_t;
33
+
34
+#ifdef __cplusplus
35
+extern "C" {
36
+#endif
37
+
38
+	/*!
39
+	  @abstract     Open a SAM/BAM file
40
+
41
+	  @param fn SAM/BAM file name; "-" is recognized as stdin (for
42
+	  reading) or stdout (for writing).
43
+
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.
50
+
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.
56
+
57
+	  @return       SAM/BAM file handler
58
+	 */
59
+	samfile_t *samopen(const char *fn, const char *mode, const void *aux);
60
+
61
+	/*!
62
+	  @abstract     Close a SAM/BAM handler
63
+	  @param  fp    file handler to be closed
64
+	 */
65
+	void samclose(samfile_t *fp);
66
+
67
+	/*!
68
+	  @abstract     Read one alignment
69
+	  @param  fp    file handler
70
+	  @param  b     alignment
71
+	  @return       bytes read
72
+	 */
73
+	int samread(samfile_t *fp, bam1_t *b);
74
+
75
+	/*!
76
+	  @abstract     Write one alignment
77
+	  @param  fp    file handler
78
+	  @param  b     alignment
79
+	  @return       bytes written
80
+	 */
81
+	int samwrite(samfile_t *fp, const bam1_t *b);
82
+
83
+	/*!
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()
89
+	 */
90
+	int sampileup(samfile_t *fp, int mask, bam_pileup_f func, void *data);
91
+
92
+	char *samfaipath(const char *fn_ref);
93
+	int samthreads(samfile_t *fp, int n_threads, int n_sub_blks);
94
+
95
+#ifdef __cplusplus
96
+}
97
+#endif
98
+
99
+#endif