| 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <unistd.h> |
| 4 | #include <string.h> |
| 5 | #include <errno.h> |
| 6 | #include "aHit.H" |
| 7 | |
| 8 | // A very simple filter. |
| 9 | // |
| 10 | // Output the top 50 hits or all hits above 0.2, whichever is _smaller_. |
| 11 | |
| 12 | #include "hitReader.H" |
| 13 | |
| 14 | #define UNIQ_THRESH 50 |
| 15 | #define QUAL_THRESH 0.2 |
| 16 | |
| 17 | int |
| 18 | main(int argc, char **argv) { |
| 19 | |
| 20 | if (argc == 1) { |
| 21 | fprintf(stderr, "ESTmapper utility function -- not for human use.\n"); |
| 22 | exit(1); |
| 23 | } |
| 24 | |
| 25 | hitReader HR(argc); |
| 26 | |
| 27 | // takes no args |
| 28 | |
| 29 | int arg = 1; |
| 30 | while (arg < argc) { |
| 31 | HR.addInputFile(argv[arg]); |
| 32 | arg++; |
| 33 | } |
| 34 | |
| 35 | while (HR.loadHits()) { |
| 36 | |
| 37 | HR.sortByCoverage(); |
| 38 | |
| 39 | // Output top 'UNIQ_THRESH' hits |
| 40 | |
| 41 | uint32 max = UNIQ_THRESH; |
| 42 | |
| 43 | if (max >= HR.numHits()) |
| 44 | max = HR.numHits(); |
| 45 | |
| 46 | for (uint32 i=0; i<max; i++) |
| 47 | ahit_printASCII(&HR[i].a, stdout); |
| 48 | |
| 49 | #if 0 |
| 50 | uint32 count = 0; |
| 51 | |
| 52 | for (uint32 i=0; i < HR.numHits(); i++) |
| 53 | if (QUAL_THRESH <= HR[i].coverage) |
| 54 | count++; |
| 55 | |
| 56 | if ((count > 0) && (count < UNIQ_THRESH)) { |
| 57 | // Output all hits above QUAL_THRESH |
| 58 | for (uint32 i=0; i < HR.numHits(); i++) |
| 59 | if (QUAL_THRESH <= HR[i].coverage) |
| 60 | ahit_printASCII(&HR[i].a, stdout); |
| 61 | } else { |
| 62 | // Output top 'UNIQ_THRESH' hits |
| 63 | for (uint32 i=0; i < UNIQ_THRESH; i++) |
| 64 | ahit_printASCII(&HR[i].a, stdout); |
| 65 | } |
| 66 | #endif |
| 67 | |
| 68 | } |
| 69 | |
| 70 | return(0); |
| 71 | } |