| 1 |
#include "bio++.H" |
| 2 |
#include "existDB.H" |
| 3 |
#include "positionDB.H" |
| 4 |
|
| 5 |
// Tests a positionDB when using an existDB for masking. |
| 6 |
// |
| 7 |
// existDB can be either include or exclude |
| 8 |
// positionDB can use include, exclude or threshold |
| 9 |
// |
| 10 |
|
| 11 |
#define MERSIZE 14 |
| 12 |
|
| 13 |
int |
| 14 |
main(int argc, char **argv) { |
| 15 |
existDB *include; |
| 16 |
existDB *exclude; |
| 17 |
positionDB *full; |
| 18 |
positionDB *incl; |
| 19 |
positionDB *excl; |
| 20 |
positionDB *thrs; |
| 21 |
|
| 22 |
if (argc != 4) { |
| 23 |
fprintf(stderr, "usage: %s seq.fasta mask.fasta incl.fasta\n", argv[0]); |
| 24 |
exit(1); |
| 25 |
} |
| 26 |
|
| 27 |
char *seqName = argv[1]; |
| 28 |
char *mskName = argv[2]; |
| 29 |
char *incName = argv[3]; |
| 30 |
|
| 31 |
fprintf(stderr, "BUILDING EXCLUDE\n"); |
| 32 |
exclude = new existDB(mskName, MERSIZE, existDBnoFlags, uint32ZERO, ~uint32ZERO); |
| 33 |
|
| 34 |
fprintf(stderr, "BUILDING INCLUDE\n"); |
| 35 |
include = new existDB(incName, MERSIZE, existDBnoFlags, uint32ZERO, ~uint32ZERO); |
| 36 |
|
| 37 |
seqStream *F = new seqStream(seqName, true); |
| 38 |
merStream *T = new merStream(new kMerBuilder(MERSIZE), F); |
| 39 |
|
| 40 |
fprintf(stderr, "BUILDING FULL\n"); |
| 41 |
full = new positionDB(T, MERSIZE, 0, 0L, 0L, 0L, 0, 0, 0, 0, true); |
| 42 |
full->saveState("junk-full"); |
| 43 |
delete full; |
| 44 |
|
| 45 |
fprintf(stderr, "BUILDING INCL\n"); |
| 46 |
incl = new positionDB(T, MERSIZE, 0, 0L, include, 0L, 0, 0, 0, 0, true); |
| 47 |
incl->saveState("junk-incl"); |
| 48 |
delete incl; |
| 49 |
|
| 50 |
fprintf(stderr, "BUILDING EXCL\n"); |
| 51 |
excl = new positionDB(T, MERSIZE, 0, exclude, 0L, 0L, 0, 0, 0, 0, true); |
| 52 |
excl->saveState("junk-excl"); |
| 53 |
delete excl; |
| 54 |
|
| 55 |
fprintf(stderr, "BUILDING THRS\n"); |
| 56 |
thrs = new positionDB(T, MERSIZE, 0, 0L, 0L, 0L, 1, 0, 0, 0, true); |
| 57 |
thrs->saveState("junk-thrs"); |
| 58 |
delete thrs; |
| 59 |
|
| 60 |
full = new positionDB("junk-full", MERSIZE, 0, 0); |
| 61 |
incl = new positionDB("junk-incl", MERSIZE, 0, 0); |
| 62 |
excl = new positionDB("junk-excl", MERSIZE, 0, 0); |
| 63 |
thrs = new positionDB("junk-thrs", MERSIZE, 0, 0); |
| 64 |
|
| 65 |
char themer[1000]; |
| 66 |
uint32 mernum = 0; |
| 67 |
|
| 68 |
uint32 err = 0; |
| 69 |
|
| 70 |
// Check everything looks ok |
| 71 |
T->rewind(); |
| 72 |
while (T->nextMer()) { |
| 73 |
|
| 74 |
if (!full->existsExact(T->theFMer())) { |
| 75 |
fprintf(stderr, "Didn't find mer "uint32FMT" %s in full.\n", mernum, T->theFMer().merToString(themer)); |
| 76 |
err++; |
| 77 |
} |
| 78 |
|
| 79 |
if (include->exists(T->theFMer())) { |
| 80 |
if (!incl->existsExact(T->theFMer())) { |
| 81 |
fprintf(stderr, "Didn't find mer "uint32FMT" %s in incl.\n", mernum, T->theFMer().merToString(themer)); |
| 82 |
err++; |
| 83 |
} |
| 84 |
} else { |
| 85 |
if (incl->existsExact(T->theFMer())) { |
| 86 |
fprintf(stderr, "Found extra mer "uint32FMT" %s in incl.\n", mernum, T->theFMer().merToString(themer)); |
| 87 |
err++; |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
if (exclude->exists(T->theFMer())) { |
| 92 |
if (excl->existsExact(T->theFMer())) { |
| 93 |
fprintf(stderr, "Found extra mer "uint32FMT" %s in excl.\n", mernum, T->theFMer().merToString(themer)); |
| 94 |
err++; |
| 95 |
} |
| 96 |
} else { |
| 97 |
if (!excl->existsExact(T->theFMer())) { |
| 98 |
fprintf(stderr, "Didn't find mer "uint32FMT" %s in excl.\n", mernum, T->theFMer().merToString(themer)); |
| 99 |
err++; |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
mernum++; |
| 104 |
} |
| 105 |
|
| 106 |
delete T; |
| 107 |
delete F; |
| 108 |
|
| 109 |
exit(err > 0); |
| 110 |
} |