| 1 | #ifndef HITREADER_H |
| 2 | #define HITREADER_H |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <string.h> |
| 7 | #include "bio.h" |
| 8 | #include "aHit.H" |
| 9 | |
| 10 | // Define this if your hits have answers and you're curious about how |
| 11 | // well the filter is performing. |
| 12 | // |
| 13 | // This is used in filterEST.C also. |
| 14 | // |
| 15 | //#define WITH_ANSWERS |
| 16 | |
| 17 | |
| 18 | // XXX: Lots of this stuff can be moved into hitReader as temporary variables |
| 19 | // |
| 20 | typedef struct { |
| 21 | bool stillMore; |
| 22 | readBuffer *buff; |
| 23 | char b[1024]; |
| 24 | aHit a; |
| 25 | bool isBINARY; |
| 26 | } hitFile_s; |
| 27 | |
| 28 | |
| 29 | typedef struct { |
| 30 | aHit a; |
| 31 | double coverage; |
| 32 | double multiplicity; |
| 33 | uint32 estid; |
| 34 | #ifdef WITH_ANSWERS |
| 35 | uint32 mappedIdentity; |
| 36 | uint32 mappedCoverage; |
| 37 | #endif |
| 38 | } hit_s; |
| 39 | |
| 40 | |
| 41 | |
| 42 | class hitReader { |
| 43 | public: |
| 44 | hitReader(int m); |
| 45 | ~hitReader(); |
| 46 | |
| 47 | void addInputFile(char *filename); |
| 48 | |
| 49 | void loadHit(hitFile_s *HF); |
| 50 | bool loadHits(void); |
| 51 | |
| 52 | double bestScore(void) { return(_bestScore); }; |
| 53 | double worstScore(void) { return(_worstScore); }; |
| 54 | uint32 iid(void) { return(_iid); }; |
| 55 | uint32 numHits(void) { return(_listLen); }; |
| 56 | |
| 57 | void sortByCoverage(void); |
| 58 | void mergeOverlappingHits(void); |
| 59 | |
| 60 | hit_s &operator[](uint32 x) { |
| 61 | if (x >= _listLen) { |
| 62 | fprintf(stderr, "hitReader::operator[]()-- ERROR: asked for hit "uint32FMT" out of "uint32FMT".\n", x, _listLen); |
| 63 | exit(1); |
| 64 | } |
| 65 | |
| 66 | return(_list[x]); |
| 67 | }; |
| 68 | private: |
| 69 | uint32 _filesMax; |
| 70 | uint32 _filesLen; |
| 71 | hitFile_s *_files; |
| 72 | |
| 73 | uint32 _listLen; |
| 74 | uint32 _listMax; |
| 75 | hit_s *_list; |
| 76 | |
| 77 | double _bestScore; |
| 78 | double _worstScore; |
| 79 | uint32 _iid; |
| 80 | }; |
| 81 | |
| 82 | #endif // HITREADER_H |