| 1 | #cxx . . $ `<file>/seatac/seatac.C`/include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <new> |
| 4 | #include "seatac.H"cxx . . $ `<file>/seatac/seatac.H`/ |
| 5 | |
| 6 | |
| 7 | // Shared data |
| 8 | // |
| 9 | configurationcxx . . $ configuration# configcxx . . $ config.; |
| 10 | seqCachecxx . . $ seqCache# *qsFASTAcxx . . $ qsFASTA. = 0L; |
| 11 | positionDBcxx . . $ positionDB# *positionscxx . . $ positions. = 0L; |
| 12 | volatile uint32cxx . . $ uint32# numberOfQueriescxx . . $ numberOfQueries. = 0; |
| 13 | filterObjcxx . . $ filterObj# **outputcxx . . $ output. = 0L; |
| 14 | pthread_mutex_t inputTailMutexcxx . . $ inputTailMutex.; |
| 15 | seqInCorecxx . . $ seqInCore# **inputcxx . . $ input. = 0L; |
| 16 | volatile uint32cxx . . $ uint32# inputHeadcxx . . $ inputHead. = 0; |
| 17 | volatile uint32cxx . . $ uint32# inputTailcxx . . $ inputTail. = 0; |
| 18 | volatile uint32cxx . . $ uint32# outputPoscxx . . $ outputPos. = 0; |
| 19 | char *threadStatscxx . . $ threadStats.[MAX_THREADScxx . . $ `seatac/seatac.H:61:9`!] = { 0L }; |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | #ifdef _AIX |
| 26 | static |
| 27 | void |
| 28 | aix_new_handler() { |
| 29 | fprintf(stderr, "aix_new_handler()-- Memory allocation failed.\n"); |
| 30 | throw std::bad_alloc(); |
| 31 | } |
| 32 | #endif |
| 33 | |
| 34 | |
| 35 | int |
| 36 | maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) { |
| 37 | |
| 38 | #ifdef _AIX |
| 39 | // By default, AIX Visual Age C++ new() returns 0L; this turns on |
| 40 | // exceptions. |
| 41 | // |
| 42 | std::set_new_handler(aix_new_handler); |
| 43 | #endif |
| 44 | |
| 45 | // Read the configuration from the command line |
| 46 | // |
| 47 | if (argc < 2) { |
| 48 | configcxx . . $ config..usagecxx . . $ configuration#usage(fda57c8427c60377).(argv[0]); |
| 49 | exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 50 | } |
| 51 | configcxx . . $ config..readcxx . . $ configuration#read(c759356ac01a31e7).(argc, argv); |
| 52 | |
| 53 | configcxx . . $ config.._startTimecxx . . $ configuration#_startTime. = getTime(); |
| 54 | |
| 55 | // Open and init the query sequence |
| 56 | // |
| 57 | qsFASTAcxx . . $ qsFASTA. = new seqCachecxx . . $ seqCache#seqCache(cc76bd1196c143a3).(configcxx . . $ config.._qsFileNamecxx . . $ configuration#_qsFileName.); |
| 58 | |
| 59 | numberOfQueriescxx . . $ numberOfQueries. = qsFASTAcxx . . $ qsFASTA.->getNumberOfSequencescxx . . $ seqCache#getNumberOfSequences(db52760e79bf9054).(); |
| 60 | outputcxx . . $ output. = new filterObjcxx . . $ filterObj# * [numberOfQueriescxx . . $ numberOfQueries.]; |
| 61 | inputcxx . . $ input. = new seqInCorecxx . . $ seqInCore# * [numberOfQueriescxx . . $ numberOfQueries.]; |
| 62 | inputHeadcxx . . $ inputHead. = 0; |
| 63 | inputTailcxx . . $ inputTail. = 0; |
| 64 | |
| 65 | for (uint32cxx . . $ uint32# i=numberOfQueriescxx . . $ numberOfQueries.; i--; ) { |
| 66 | outputcxx . . $ output.[i] = 0L; |
| 67 | inputcxx . . $ input.[i] = 0L; |
| 68 | } |
| 69 | |
| 70 | configcxx . . $ config.._initTimecxx . . $ configuration#_initTime. = getTime(); |
| 71 | |
| 72 | configcxx . . $ config.._genomecxx . . $ configuration#_genome. = new seqStreamcxx . . $ seqStream#(configcxx . . $ config.._dbFileNamecxx . . $ configuration#_dbFileName.); |
| 73 | |
| 74 | // Create the chunk, returning a positionDB. Threads will use both |
| 75 | // chain and postions to build hitMatrices. |
| 76 | // |
| 77 | if ((configcxx . . $ config.._tableFileNamecxx . . $ configuration#_tableFileName.) && (fileExists(configcxx . . $ config.._tableFileNamecxx . . $ configuration#_tableFileName.))) { |
| 78 | if (configcxx . . $ config.._tableBuildOnlycxx . . $ configuration#_tableBuildOnly.) { |
| 79 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "All done. Table '%s' already build.\n", configcxx . . $ config.._tableFileNamecxx . . $ configuration#_tableFileName.); |
| 80 | exitcxx . . $ exit(44ed87f96534fad7).(0); |
| 81 | } else { |
| 82 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Loading positionDB state from '%s'\n", configcxx . . $ config.._tableFileNamecxx . . $ configuration#_tableFileName.); |
| 83 | positionscxx . . $ positions. = new positionDBcxx . . $ positionDB#(configcxx . . $ config.._tableFileNamecxx . . $ configuration#_tableFileName., configcxx . . $ config.._merSizecxx . . $ configuration#_merSize., configcxx . . $ config.._merSkipcxx . . $ configuration#_merSkip., 0); |
| 84 | } |
| 85 | } else { |
| 86 | |
| 87 | existDBcxx . . $ existDB# *maskDB = 0L; |
| 88 | if (configcxx . . $ config.._maskFileNamecxx . . $ configuration#_maskFileName.) { |
| 89 | if (configcxx . . $ config.._beVerbosecxx . . $ configuration#_beVerbose.) |
| 90 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Building maskDB from '%s'\n", configcxx . . $ config.._maskFileNamecxx . . $ configuration#_maskFileName.); |
| 91 | maskDB = new existDBcxx . . $ existDB#(configcxx . . $ config.._maskFileNamecxx . . $ configuration#_maskFileName., configcxx . . $ config.._merSizecxx . . $ configuration#_merSize., existDBcanonicalcxx . . $ existDBcanonical. | existDBcompressHashcxx . . $ existDBcompressHash. | existDBcompressBucketscxx . . $ existDBcompressBuckets., 0, ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!); |
| 92 | } |
| 93 | |
| 94 | existDBcxx . . $ existDB# *onlyDB = 0L; |
| 95 | if (configcxx . . $ config.._onlyFileNamecxx . . $ configuration#_onlyFileName.) { |
| 96 | if (configcxx . . $ config.._beVerbosecxx . . $ configuration#_beVerbose.) |
| 97 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Building onlyDB from '%s'\n", configcxx . . $ config.._onlyFileNamecxx . . $ configuration#_onlyFileName.); |
| 98 | onlyDB = new existDBcxx . . $ existDB#(configcxx . . $ config.._onlyFileNamecxx . . $ configuration#_onlyFileName., configcxx . . $ config.._merSizecxx . . $ configuration#_merSize., existDBcanonicalcxx . . $ existDBcanonical. | existDBcompressHashcxx . . $ existDBcompressHash. | existDBcompressBucketscxx . . $ existDBcompressBuckets., 0, ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!); |
| 99 | } |
| 100 | |
| 101 | merStreamcxx . . $ merStream# *MS = new merStreamcxx . . $ merStream#(new kMerBuildercxx . . $ kMerBuilder#(configcxx . . $ config.._merSizecxx . . $ configuration#_merSize.), |
| 102 | configcxx . . $ config.._genomecxx . . $ configuration#_genome., |
| 103 | true, false); |
| 104 | |
| 105 | positionscxx . . $ positions. = new positionDBcxx . . $ positionDB#(MS, configcxx . . $ config.._merSizecxx . . $ configuration#_merSize., configcxx . . $ config.._merSkipcxx . . $ configuration#_merSkip., maskDB, onlyDB, 0L, 0, 0, 0, 0, configcxx . . $ config.._beVerbosecxx . . $ configuration#_beVerbose.); |
| 106 | |
| 107 | delete MS; |
| 108 | |
| 109 | delete maskDB; |
| 110 | delete onlyDB; |
| 111 | |
| 112 | if (configcxx . . $ config.._tableFileNamecxx . . $ configuration#_tableFileName.) { |
| 113 | if (configcxx . . $ config.._beVerbosecxx . . $ configuration#_beVerbose.) |
| 114 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Dumping positions table to '%s'\n", configcxx . . $ config.._tableFileNamecxx . . $ configuration#_tableFileName.); |
| 115 | |
| 116 | positionscxx . . $ positions.->saveStatecxx . . $ positionDB#saveState(85c52e162fed56f9).(configcxx . . $ config.._tableFileNamecxx . . $ configuration#_tableFileName.); |
| 117 | |
| 118 | if (configcxx . . $ config.._tableBuildOnlycxx . . $ configuration#_tableBuildOnly.) |
| 119 | exitcxx . . $ exit(44ed87f96534fad7).(0); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | configcxx . . $ config.._buildTimecxx . . $ configuration#_buildTime. = getTime(); |
| 124 | |
| 125 | |
| 126 | // |
| 127 | // Initialize threads |
| 128 | // |
| 129 | pthread_attr_t threadAttr; |
| 130 | pthread_t threadID; |
| 131 | |
| 132 | pthread_mutex_init(&inputTailMutexcxx . . $ inputTailMutex., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 133 | |
| 134 | pthread_attr_init(&threadAttr); |
| 135 | pthread_attr_setscope(&threadAttr, PTHREAD_SCOPE_SYSTEMcxx . . $ `<external>/14712363683955484316/pthread.h:137:9`!); |
| 136 | pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHEDcxx . . $ `<external>/14712363683955484316/pthread.h:42:9`!); |
| 137 | pthread_attr_setschedpolicy(&threadAttr, SCHED_OTHERcxx . . $ `<external>/4872883757279652994/sched.h:28:9`!); |
| 138 | |
| 139 | // Start the deadlock detection threads |
| 140 | // |
| 141 | #ifdef __alpha |
| 142 | fprintf(stderr, "Deadlock detection enabled!\n"); |
| 143 | pthread_create(&threadID, &threadAttr, deadlockDetector, 0L); |
| 144 | pthread_create(&threadID, &threadAttr, deadlockChecker, 0L); |
| 145 | #endif |
| 146 | |
| 147 | // Start the loader thread |
| 148 | // |
| 149 | pthread_create(&threadID, &threadAttr, loaderThreadcxx . . $ loaderThread(9f162e79bfc6c74)., 0L); |
| 150 | |
| 151 | // Start the search threads |
| 152 | // |
| 153 | for (uint32cxx . . $ uint32# i=0; i<configcxx . . $ config.._numSearchThreadscxx . . $ configuration#_numSearchThreads.; i++) { |
| 154 | threadStatscxx . . $ threadStats.[i] = 0L; |
| 155 | pthread_create(&threadID, &threadAttr, searchThreadcxx . . $ searchThread(9f162e79bfc6c74)., (void *)(unsigned long)i); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | // Open output file |
| 160 | // |
| 161 | FILE *resultFILE = stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!; |
| 162 | |
| 163 | if (configcxx . . $ config.._outputFileNamecxx . . $ configuration#_outputFileName.) { |
| 164 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 165 | int rf = open(configcxx . . $ config.._outputFileNamecxx . . $ configuration#_outputFileName., |
| 166 | O_WRONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:44:9`! | O_LARGEFILEcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:136:10`! | O_CREATcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:47:10`! | O_TRUNCcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:56:10`!, |
| 167 | S_IRUSRcxx . . $ `<external>/14710646456994434043/fcntl.h:105:10`! | S_IWUSRcxx . . $ `<external>/14710646456994434043/fcntl.h:106:10`! | S_IRGRPcxx . . $ `<external>/14710646456994434043/fcntl.h:111:10`! | S_IWGRPcxx . . $ `<external>/14710646456994434043/fcntl.h:112:10`! | S_IROTHcxx . . $ `<external>/14710646456994434043/fcntl.h:117:10`! | S_IWOTHcxx . . $ `<external>/14710646456994434043/fcntl.h:118:10`!); |
| 168 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) { |
| 169 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Couldn't open the output file '%s'?\n%s\n", configcxx . . $ config.._outputFileNamecxx . . $ configuration#_outputFileName., strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 170 | exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 171 | } |
| 172 | |
| 173 | resultFILE = fdopen(rf, "w"); |
| 174 | } |
| 175 | |
| 176 | |
| 177 | // Dump our information to the output file. |
| 178 | // |
| 179 | configcxx . . $ config..writeATACheadercxx . . $ configuration#writeATACheader(8d4262d45fc644ab).(resultFILE); |
| 180 | |
| 181 | |
| 182 | |
| 183 | // Initialize the statistics collection object |
| 184 | // |
| 185 | statObjcxx . . $ statObj# *stats = new statObjcxx . . $ statObj#statObj(6f6da539ca2a87b6).(configcxx . . $ config.._filterObjcxx . . $ configuration#_filterObj., configcxx . . $ config.._filteroptscxx . . $ configuration#_filteropts.); |
| 186 | |
| 187 | // Wait for threads to produce output |
| 188 | // |
| 189 | outputPoscxx . . $ outputPos. = 0; |
| 190 | |
| 191 | // The match id of each output record. |
| 192 | // |
| 193 | uint64cxx . . $ uint64# matchID = 0; |
| 194 | |
| 195 | double zeroTime = getTime() - 0.00000001; |
| 196 | |
| 197 | while (outputPoscxx . . $ outputPos. < numberOfQueriescxx . . $ numberOfQueries.) { |
| 198 | if (outputcxx . . $ output.[outputPoscxx . . $ outputPos.]) { |
| 199 | if (configcxx . . $ config.._beVerbosecxx . . $ configuration#_beVerbose. && ((outputPoscxx . . $ outputPos. & 0x1ff) == 0x1ff)) { |
| 200 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, |
| 201 | "O:"uint32FMTWcxx . . $ `libutil/util.h:64:10`!(7)" S:"uint32FMTWcxx . . $ `libutil/util.h:64:10`!(7)" I:"uint32FMTWcxx . . $ `libutil/util.h:64:10`!(7)" T:"uint32FMTWcxx . . $ `libutil/util.h:64:10`!(7)" (%5.1f%%; %8.3f/sec) Finish in %5.2f seconds.\r", |
| 202 | outputPoscxx . . $ outputPos., |
| 203 | inputTailcxx . . $ inputTail., |
| 204 | inputHeadcxx . . $ inputHead., |
| 205 | numberOfQueriescxx . . $ numberOfQueries., |
| 206 | 100.0 * outputPoscxx . . $ outputPos. / numberOfQueriescxx . . $ numberOfQueries., |
| 207 | outputPoscxx . . $ outputPos. / (getTime() - zeroTime), |
| 208 | (numberOfQueriescxx . . $ numberOfQueries. - outputPoscxx . . $ outputPos.) / (outputPoscxx . . $ outputPos. / (getTime() - zeroTime))); |
| 209 | fflush(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 210 | } |
| 211 | |
| 212 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 213 | matchID = outputcxx . . $ output.[outputPoscxx . . $ outputPos.]->outputcxx . . $ filterObj#output(9bd1d5b934681de1).(resultFILE, matchID); |
| 214 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) { |
| 215 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Couldn't write to the output file '%s'.\n%d: %s\n", |
| 216 | configcxx . . $ config.._outputFileNamecxx . . $ configuration#_outputFileName., errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 217 | exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 218 | } |
| 219 | |
| 220 | // Add this set of results to the statistics collector |
| 221 | // |
| 222 | stats->addcxx . . $ statObj#add(53ed47f03c7187f9).(outputcxx . . $ output.[outputPoscxx . . $ outputPos.]); |
| 223 | |
| 224 | //stats->show(stderr); |
| 225 | |
| 226 | delete inputcxx . . $ input.[outputPoscxx . . $ outputPos.]; |
| 227 | delete outputcxx . . $ output.[outputPoscxx . . $ outputPos.]; |
| 228 | |
| 229 | inputcxx . . $ input.[outputPoscxx . . $ outputPos.] = 0L; |
| 230 | outputcxx . . $ output.[outputPoscxx . . $ outputPos.] = 0L; |
| 231 | |
| 232 | outputPoscxx . . $ outputPos.++; |
| 233 | } else { |
| 234 | nanosleep(&configcxx . . $ config.._writerSleepcxx . . $ configuration#_writerSleep., 0L); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | if (configcxx . . $ config.._beVerbosecxx . . $ configuration#_beVerbose.) { |
| 239 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "\n"uint32FMTWcxx . . $ `libutil/util.h:64:10`!(7)" sequences (%5.1f%%; %8.3f/sec) %5.2f seconds.\n", |
| 240 | numberOfQueriescxx . . $ numberOfQueries., |
| 241 | 100.0 * outputPoscxx . . $ outputPos. / numberOfQueriescxx . . $ numberOfQueries., |
| 242 | outputPoscxx . . $ outputPos. / (getTime() - zeroTime), |
| 243 | getTime() - zeroTime); |
| 244 | } |
| 245 | |
| 246 | // Print statistics |
| 247 | // |
| 248 | stats->showcxx . . $ statObj#show(8d4262d45fc644ab).(resultFILE); |
| 249 | delete stats; |
| 250 | |
| 251 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 252 | fclose(resultFILE); |
| 253 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) |
| 254 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Couldn't close to the output file '%s'.\n%s\n", configcxx . . $ config.._outputFileNamecxx . . $ configuration#_outputFileName., strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 255 | |
| 256 | configcxx . . $ config.._searchTimecxx . . $ configuration#_searchTime. = getTime(); |
| 257 | |
| 258 | // Clean up |
| 259 | // |
| 260 | delete positionscxx . . $ positions.; |
| 261 | |
| 262 | pthread_attr_destroy(&threadAttr); |
| 263 | pthread_mutex_destroy(&inputTailMutexcxx . . $ inputTailMutex.); |
| 264 | |
| 265 | delete [] inputcxx . . $ input.; |
| 266 | delete [] outputcxx . . $ output.; |
| 267 | |
| 268 | return(0); |
| 269 | } |