annotate mrfast-2.1.0.4/Output.c @ 0:7b3dc85dc7fd

Uploaded mrfast source tarball
author calkan
date Tue, 21 Feb 2012 10:29:47 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
1 /*
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
2 * Copyright (c) <2008 - 2012>, University of Washington, Simon Fraser University
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
3 * All rights reserved.
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
4 *
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without modification,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
6 * are permitted provided that the following conditions are met:
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
7 *
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
8 * Redistributions of source code must retain the above copyright notice, this list
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
9 * of conditions and the following disclaimer.
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
10 * - Redistributions in binary form must reproduce the above copyright notice, this
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
11 * list of conditions and the following disclaimer in the documentation and/or other
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
12 * materials provided with the distribution.
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
13 * - Neither the names of the University of Washington, Simon Fraser University,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
14 * nor the names of its contributors may be
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
15 * used to endorse or promote products derived from this software without specific
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
16 * prior written permission.
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
17 *
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
29 */
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
30
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
31 /*
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
32 Authors:
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
33 Farhad Hormozdiari
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
34 Faraz Hach
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
35 Can Alkan
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
36 Emails:
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
37 farhadh AT uw DOT edu
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
38 fhach AT cs DOT sfu DOT ca
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
39 calkan AT uw DOT edu
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
40 */
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
41
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
42
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
43 #include <stdio.h>
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
44 #include <stdlib.h>
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
45 #include <zlib.h>
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
46 #include <string.h>
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
47 #include "Common.h"
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
48 #include "Output.h"
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
49
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
50 FILE *_out_fp;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
51 gzFile _out_gzfp;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
52
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
53 char buffer[300000];
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
54 int bufferSize = 0;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
55
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
56
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
57 void finalizeGZOutput()
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
58 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
59 gzclose(_out_gzfp);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
60 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
61
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
62 void finalizeTXOutput()
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
63 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
64 fclose(_out_fp);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
65 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
66
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
67
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
68 void gzOutputQ(SAM map)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
69 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
70 gzprintf(_out_gzfp, "%s\t%d\t%s\t%d\t%d\t%s\t%s\t%d\t%d\t%s\t%s",
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
71 map.QNAME,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
72 map.FLAG,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
73 map.RNAME,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
74 map.POS,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
75 map.MAPQ,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
76 map.CIGAR,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
77 map.MRNAME,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
78 map.MPOS,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
79 map.ISIZE,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
80 map.SEQ,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
81 map.QUAL);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
82
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
83 int i;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
84
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
85 for ( i = 0; i < map.optSize; i++)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
86 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
87 switch (map.optFields[i].type)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
88 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
89 case 'A':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
90 gzprintf(_out_gzfp, "\t%s:%c:%c", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].cVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
91 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
92 case 'i':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
93 gzprintf(_out_gzfp, "\t%s:%c:%d", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].iVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
94 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
95 case 'f':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
96 gzprintf(_out_gzfp, "\t%s:%c:%f", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].fVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
97 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
98 case 'Z':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
99 case 'H':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
100 gzprintf(_out_gzfp, "\t%s:%c:%s", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].sVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
101 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
102 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
103 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
104 gzprintf(_out_gzfp, "\n");
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
105 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
106
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
107 void outputSAM(FILE *fp, SAM map)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
108 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
109 fprintf(fp, "%s\t%d\t%s\t%d\t%d\t%s\t%s\t%d\t%d\t%s\t%s",
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
110 map.QNAME,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
111 map.FLAG,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
112 map.RNAME,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
113 map.POS,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
114 map.MAPQ,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
115 map.CIGAR,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
116 map.MRNAME,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
117 map.MPOS,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
118 map.ISIZE,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
119 map.SEQ,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
120 map.QUAL);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
121
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
122
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
123 int i;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
124
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
125 for ( i = 0; i < map.optSize; i++)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
126 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
127 switch (map.optFields[i].type)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
128 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
129 case 'A':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
130 fprintf(fp, "\t%s:%c:%c", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].cVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
131 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
132 case 'i':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
133 fprintf(fp, "\t%s:%c:%d", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].iVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
134 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
135 case 'f':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
136 fprintf(fp, "\t%s:%c:%f", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].fVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
137 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
138 case 'Z':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
139 case 'H':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
140 fprintf(fp, "\t%s:%c:%s", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].sVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
141 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
142 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
143 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
144
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
145 fprintf(fp, "\n");
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
146
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
147 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
148
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
149 void outputQ(SAM map)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
150 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
151
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
152 fprintf(_out_fp, "%s\t%d\t%s\t%d\t%d\t%s\t%s\t%d\t%d\t%s\t%s",
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
153 map.QNAME,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
154 map.FLAG,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
155 map.RNAME,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
156 map.POS,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
157 map.MAPQ,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
158 map.CIGAR,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
159 map.MRNAME,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
160 map.MPOS,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
161 map.ISIZE,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
162 map.SEQ,
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
163 map.QUAL);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
164
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
165
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
166 int i;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
167
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
168 for ( i = 0; i < map.optSize; i++)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
169 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
170 switch (map.optFields[i].type)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
171 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
172 case 'A':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
173 fprintf(_out_fp, "\t%s:%c:%c", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].cVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
174 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
175 case 'i':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
176 fprintf(_out_fp, "\t%s:%c:%d", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].iVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
177 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
178 case 'f':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
179 fprintf(_out_fp, "\t%s:%c:%f", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].fVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
180 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
181 case 'Z':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
182 case 'H':
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
183 fprintf(_out_fp, "\t%s:%c:%s", map.optFields[i].tag, map.optFields[i].type, map.optFields[i].sVal);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
184 break;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
185 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
186 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
187
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
188 fprintf(_out_fp, "\n");
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
189 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
190
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
191 int initOutput ( char *fileName, int compressed)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
192 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
193 if (compressed)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
194 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
195 char newFileName[strlen(fileName)+4];
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
196 sprintf(newFileName, "%s.gz", fileName);
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
197
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
198 _out_gzfp = fileOpenGZ(newFileName, "w1f");
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
199 if (_out_gzfp == Z_NULL)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
200 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
201 return 0;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
202 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
203
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
204 finalizeOutput = &finalizeGZOutput;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
205
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
206 output = &gzOutputQ;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
207 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
208 else
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
209 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
210 _out_fp = fileOpen(fileName, "w");
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
211 if (_out_fp == NULL)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
212 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
213 return 0;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
214 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
215
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
216 finalizeOutput = &finalizeTXOutput;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
217 output = &outputQ;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
218 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
219 buffer[0] = '\0';
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
220 return 1;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
221 }
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
222
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
223 FILE* getOutputFILE()
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
224 {
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
225 if(_out_fp != NULL)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
226 return _out_fp;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
227 else if(_out_gzfp != NULL)
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
228 return _out_gzfp;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
229 else
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
230 return NULL;
7b3dc85dc7fd Uploaded mrfast source tarball
calkan
parents:
diff changeset
231 }