annotate mrfast-2.1.0.5/baseFAST.c @ 1:d4054b05b015 default tip

Version update to 2.1.0.5
author calkan
date Fri, 09 Mar 2012 07:35:51 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
1 /*
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
2 * Copyright (c) <2008 - 2012>, University of Washington, Simon Fraser University
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
3 * All rights reserved.
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
4 *
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without modification,
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
6 * are permitted provided that the following conditions are met:
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
7 *
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
8 * Redistributions of source code must retain the above copyright notice, this list
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
9 * of conditions and the following disclaimer.
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
10 * - Redistributions in binary form must reproduce the above copyright notice, this
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
11 * list of conditions and the following disclaimer in the documentation and/or other
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
12 * materials provided with the distribution.
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
13 * - Neither the names of the University of Washington, Simon Fraser University,
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
14 * nor the names of its contributors may be
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
15 * used to endorse or promote products derived from this software without specific
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
16 * prior written permission.
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
17 *
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
29 */
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
30
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
31 /*
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
32 Authors:
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
33 Farhad Hormozdiari
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
34 Faraz Hach
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
35 Can Alkan
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
36 Emails:
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
37 farhadh AT uw DOT edu
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
38 fhach AT cs DOT sfu DOT ca
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
39 calkan AT uw DOT edu
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
40 */
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
41
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
42
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
43
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
44
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
45
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
46 #include <stdio.h>
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
47 #include <stdlib.h>
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
48 #include <string.h>
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
49 #include <math.h>
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
50 #include "Common.h"
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
51 #include "CommandLineParser.h"
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
52 #include "Reads.h"
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
53 #include "Output.h"
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
54 #include "HashTable.h"
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
55 #include "MrFAST.h"
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
56
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
57 char *versionNumber = "2.1"; // Current Version
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
58 unsigned char seqFastq;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
59
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
60 int main(int argc, char *argv[])
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
61 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
62 if (!parseCommandLine(argc, argv))
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
63 return 1;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
64
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
65 configHashTable();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
66 /****************************************************
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
67 * INDEXING
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
68 ***************************************************/
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
69 if (indexingMode)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
70 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
71 int i;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
72 /********************************
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
73 * Regular Mode
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
74 ********************************/
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
75 configHashTable();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
76 for (i = 0; i < fileCnt; i++)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
77 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
78 generateHashTable(fileName[i][0], fileName[i][1]);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
79 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
80 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
81 /****************************************************
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
82 * SEARCHING
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
83 ***************************************************/
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
84 else
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
85 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
86 Read *seqList;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
87 unsigned int seqListSize;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
88 int fc;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
89 int samplingLocsSize;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
90 int *samplingLocs;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
91 double totalLoadingTime = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
92 double totalMappingTime = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
93 double startTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
94 double loadingTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
95 double mappingTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
96 double lstartTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
97 double ppTime = 0.0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
98 double tmpTime;;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
99 char *prevGen = getMem(CONTIG_NAME_SIZE);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
100 prevGen[0]='\0';
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
101 char *curGen;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
102 int flag;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
103 double maxMem=0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
104 char fname1[FILE_NAME_LENGTH];
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
105 char fname2[FILE_NAME_LENGTH];
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
106 char fname3[FILE_NAME_LENGTH];
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
107 char fname4[FILE_NAME_LENGTH];
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
108 char fname5[FILE_NAME_LENGTH];
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
109
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
110 char outputFileName[FILE_NAME_LENGTH];
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
111 // Loading Sequences & Sampling Locations
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
112 startTime = getTime();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
113 if (!readAllReads(seqFile1, seqFile2, seqCompressed, &seqFastq, pairedEndMode, &seqList, &seqListSize))
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
114 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
115 return 1;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
116 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
117
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
118 loadSamplingLocations(&samplingLocs, &samplingLocsSize);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
119 totalLoadingTime += getTime()-startTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
120
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
121 if (pairedEndMode)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
122 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
123 //Switching to Inferred Size
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
124 minPairEndedDistance = minPairEndedDistance - SEQ_LENGTH + 2;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
125 maxPairEndedDistance = maxPairEndedDistance - SEQ_LENGTH + 2;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
126 if (pairedEndDiscordantMode)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
127 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
128 maxPairEndedDiscordantDistance = maxPairEndedDiscordantDistance - SEQ_LENGTH + 2;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
129 minPairEndedDiscordantDistance = minPairEndedDiscordantDistance - SEQ_LENGTH + 2;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
130 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
131
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
132 sprintf(fname1, "__%s__1", mappingOutput);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
133 sprintf(fname2, "__%s__2", mappingOutput);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
134 sprintf(fname3, "__%s__disc", mappingOutput);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
135 sprintf(fname4, "__%s__oea1", mappingOutput);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
136 sprintf(fname5, "__%s__oea2", mappingOutput);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
137 unlink(fname1);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
138 unlink(fname2);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
139 unlink(fname3);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
140 unlink(fname4);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
141 unlink(fname5);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
142 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
143
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
144 sprintf(outputFileName, "%s%s",mappingOutputPath , mappingOutput);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
145 // Preparing output
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
146 initOutput(outputFileName, outCompressed);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
147
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
148 fprintf(stdout, "-----------------------------------------------------------------------------------------------------------\n");
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
149 fprintf(stdout, "| %15s | %15s | %15s | %15s | %15s %15s |\n","Genome Name","Loading Time", "Mapping Time", "Memory Usage(M)","Total Mappings","Mapped reads");
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
150 fprintf(stdout, "-----------------------------------------------------------------------------------------------------------\n");
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
151
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
152 /********************************
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
153 * Regular Mode
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
154 ********************************/
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
155 if (!pairedEndMode)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
156 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
157 initLookUpTable();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
158 if(bestMode)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
159 initBestMapping(seqListSize);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
160
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
161 for (fc = 0; fc <fileCnt; fc++)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
162 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
163 if (!initLoadingHashTable(fileName[fc][1]))
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
164 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
165 return 1;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
166 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
167
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
168 mappingTime = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
169 loadingTime = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
170 prevGen[0] = '\0';
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
171 flag = 1;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
172
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
173 do
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
174 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
175 flag = loadHashTable ( &tmpTime, errThreshold); // Reading a fragment
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
176 curGen = getRefGenomeName();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
177
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
178 // First Time
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
179 if (flag && prevGen[0]== '\0')
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
180 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
181 sprintf(prevGen, "%s", curGen);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
182 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
183
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
184 if ( !flag || strcmp(prevGen, curGen)!=0)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
185 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
186
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
187 fprintf(stdout, "| %15s | %15.2f | %15.2f | %15.2f | %15lld %15lld |\n",
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
188 prevGen,loadingTime, mappingTime, maxMem, mappingCnt , mappedSeqCnt);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
189 fflush(stdout);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
190
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
191 totalMappingTime += mappingTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
192 totalLoadingTime += loadingTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
193
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
194 loadingTime = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
195 mappingTime = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
196 maxMem = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
197
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
198 if (!flag)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
199 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
200 break;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
201 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
202 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
203 else if (progressRep && mappingTime != 0)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
204 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
205 fprintf(stdout, "| %15s | %15.2f | %15.2f | %15.2f | %15lld %15lld |\n",
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
206 prevGen,loadingTime, mappingTime, maxMem, mappingCnt , mappedSeqCnt);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
207 fflush(stdout);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
208 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
209
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
210 sprintf(prevGen, "%s", curGen);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
211
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
212 loadingTime += tmpTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
213 // lstartTime = getTime();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
214
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
215 initFAST(seqList, seqListSize, samplingLocs, samplingLocsSize, fileName[fc][0]);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
216
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
217 lstartTime = getTime();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
218
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
219
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
220 mapAllSingleEndSeq();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
221
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
222
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
223
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
224 mappingTime += getTime() - lstartTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
225 if (maxMem < getMemUsage())
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
226 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
227 maxMem = getMemUsage();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
228 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
229 } while (flag);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
230
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
231 } // end for;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
232 if(bestMode)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
233 finalizeBestSingleMapping();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
234 finalizeFAST();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
235 finalizeLoadingHashTable();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
236
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
237 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
238 // Pairedend Mapping Mode
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
239 else
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
240 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
241 initLookUpTable();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
242 if(pairedEndMode)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
243 initBestConcordantDiscordant(seqListSize);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
244 for (fc = 0; fc < fileCnt; fc++)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
245 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
246 if (!initLoadingHashTable(fileName[fc][1]))
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
247 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
248 return 1;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
249 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
250 mappingTime = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
251 loadingTime = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
252 prevGen[0] = '\0';
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
253 flag = 1;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
254
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
255 do
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
256 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
257 flag = loadHashTable ( &tmpTime , errThreshold); // Reading a fragment
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
258 curGen = getRefGenomeName();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
259
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
260 // First Time
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
261 if (flag && prevGen[0]== '\0')
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
262 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
263 sprintf(prevGen, "%s", curGen);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
264 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
265
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
266 if ( !flag || strcmp(prevGen, curGen)!=0)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
267 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
268
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
269 // DISCORDANT
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
270 lstartTime = getTime();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
271 outputPairedEnd();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
272 mappingTime += getTime() - lstartTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
273 //DISCORDANT
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
274
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
275 fprintf(stdout, "| %15s | %15.2f | %15.2f | %15.2f | %15lld %15lld |\n",
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
276 prevGen,loadingTime, mappingTime, maxMem, mappingCnt , mappedSeqCnt);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
277 fflush(stdout);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
278
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
279 totalMappingTime += mappingTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
280 totalLoadingTime += loadingTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
281
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
282 loadingTime = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
283 mappingTime = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
284 maxMem = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
285
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
286 if (!flag)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
287 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
288 break;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
289 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
290 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
291 else if (progressRep && mappingTime != 0)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
292 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
293 fprintf(stdout, "| %15s | %15.2f | %15.2f | %15.2f | %15lld %15lld |\n",
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
294 prevGen,loadingTime, mappingTime, maxMem, mappingCnt , mappedSeqCnt);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
295 fflush(stdout);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
296 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
297
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
298 sprintf(prevGen, "%s", curGen);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
299
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
300 loadingTime += tmpTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
301 lstartTime = getTime();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
302
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
303 initFAST(seqList, seqListSize, samplingLocs, samplingLocsSize, fileName[fc][0]);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
304
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
305 mapPairedEndSeq();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
306
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
307 mappingTime += getTime() - lstartTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
308 if (maxMem < getMemUsage())
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
309 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
310 maxMem = getMemUsage();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
311 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
312
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
313 } while (flag);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
314
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
315 } // end for;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
316
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
317 if(pairedEndMode)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
318 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
319 sprintf(outputFileName, "%s%s",mappingOutputPath , mappingOutput);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
320 finalizeOEAReads(outputFileName);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
321 outputAllTransChromosal(transChromosal);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
322 finalizeBestConcordantDiscordant();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
323 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
324
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
325 finalizeLoadingHashTable();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
326
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
327 if (pairedEndDiscordantMode)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
328 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
329 lstartTime = getTime();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
330 outputPairedEndDiscPP();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
331 ppTime = getTime() - lstartTime;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
332 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
333 finalizeFAST();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
334 } //else
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
335
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
336 finalizeOutput();
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
337
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
338 fprintf(stdout, "-----------------------------------------------------------------------------------------------------------\n");
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
339 fprintf(stdout, "%19s%16.2f%18.2f\n\n", "Total:",totalLoadingTime, totalMappingTime);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
340 if (pairedEndDiscordantMode)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
341 fprintf(stdout, "Post Processing Time: %18.2f \n", ppTime);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
342 fprintf(stdout, "%-30s%10.2f\n","Total Time:", totalMappingTime+totalLoadingTime);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
343 fprintf(stdout, "%-30s%10d\n","Total No. of Reads:", seqListSize);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
344 fprintf(stdout, "%-30s%10lld\n","Total No. of Mappings:", mappingCnt);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
345 fprintf(stdout, "%-30s%10.0f\n\n","Avg No. of locations verified:", ceil((float)verificationCnt/seqListSize));
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
346
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
347 int cof = (pairedEndMode)?2:1;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
348
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
349 if (progressRep && maxHits != 0)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
350 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
351 int frequency[maxHits+1];
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
352 int i;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
353 for ( i=0 ; i <= maxHits; i++)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
354 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
355 frequency[i] = 0;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
356 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
357
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
358
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
359 for (fc = 0; fc < seqListSize; fc++)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
360 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
361 frequency[(int)(*(seqList[fc*cof].hits))]++;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
362 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
363 frequency[maxHits] = completedSeqCnt;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
364 for ( i=0 ; i <= maxHits; i++)
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
365 {
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
366 fprintf(stdout, "%-30s%10d%10d%10.2f%%\n","Reads Mapped to ", i, frequency[i], 100*(float)frequency[i]/(float)seqListSize);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
367 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
368 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
369
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
370
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
371 finalizeReads(unmappedOutput);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
372 freeMem(prevGen, CONTIG_NAME_SIZE);
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
373 }
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
374
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
375 return 1;
d4054b05b015 Version update to 2.1.0.5
calkan
parents:
diff changeset
376 }