| 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <new> |
| 4 | |
| 5 | #include "searchGENOME.H" |
| 6 | |
| 7 | #if 0 |
| 8 | void |
| 9 | statusThread(void *) { |
| 10 | double finish = 0.0; |
| 11 | |
| 12 | if (config._outputPos > 0) |
| 13 | finish = (config._numberOfQueries - config._outputPos) / (config._outputPos / (getTime() - config._zeroTime)); |
| 14 | |
| 15 | fprintf(stderr, "O:"uint32FMTW(7)" S:"uint32FMTW(7)" I:"uint32FMTW(7)" T:"uint32FMTW(7)" (%5.1f%%; %8.3f/sec) Finish in %5.2f seconds.\r", |
| 16 | outputPos, |
| 17 | inputTail, |
| 18 | inputHead, |
| 19 | numberOfQueries, |
| 20 | 100.0 * outputPos / numberOfQueries, |
| 21 | outputPos / (getTime() - zeroTime), |
| 22 | finish); |
| 23 | fflush(stderr); |
| 24 | |
| 25 | double perSec = outputPos / (getTime() - zeroTime + 0.0000001); |
| 26 | |
| 27 | if (perSec < 32.0) |
| 28 | outputMask = 0xf; |
| 29 | else if (perSec < 256.0) |
| 30 | outputMask = 0x7f; |
| 31 | else if (perSec < 1024.0) |
| 32 | outputMask = 0x1ff; |
| 33 | else |
| 34 | outputMask = 0x3ff; |
| 35 | } |
| 36 | #endif |
| 37 | |
| 38 | |
| 39 | |
| 40 | void* |
| 41 | writerThread(void *U, void *Q) { |
| 42 | encodedQuery *query = (encodedQuery *)Q; |
| 43 | |
| 44 | // Write the hits |
| 45 | // |
| 46 | if (query->theOutputLength() > 0) { |
| 47 | errno = 0; |
| 48 | write(config._outputFile, query->theOutput(), query->theOutputLength()); |
| 49 | if (errno) |
| 50 | fprintf(stderr, "Couldn't write to the output file '%s'.\n%s\n", |
| 51 | config._outputFileName, strerror(errno)), exit(1); |
| 52 | } |
| 53 | |
| 54 | // Write the query match counts, too! |
| 55 | // |
| 56 | if (config._matchCountsFile) { |
| 57 | char str[256]; |
| 58 | |
| 59 | sprintf(str, uint32FMT"\n", query->numberOfResults()); |
| 60 | |
| 61 | errno = 0; |
| 62 | write(config._matchCountsFile, str, strlen(str)); |
| 63 | if (errno) |
| 64 | fprintf(stderr, "Couldn't write to the match counts file '%s'.\n%s\n", |
| 65 | config._queryMatchFileName, strerror(errno)), exit(1); |
| 66 | } |
| 67 | |
| 68 | delete query; |
| 69 | |
| 70 | return(0L); |
| 71 | } |