| 1 |
#include "bio++.H" |
| 2 |
|
| 3 |
// Reads a sequence file, outputs a list of the mers in it. You can |
| 4 |
// then pipe this to unix sort and uniq to do a mercount. You |
| 5 |
// probably don't want to count large things this way... |
| 6 |
|
| 7 |
int |
| 8 |
main(int argc, char **argv) { |
| 9 |
char *seqName = 0L; |
| 10 |
uint32 merSize = 20; |
| 11 |
|
| 12 |
int arg=1; |
| 13 |
while (arg < argc) { |
| 14 |
if (strcmp(argv[arg], "-s") == 0) { |
| 15 |
seqName = argv[++arg]; |
| 16 |
} else if (strcmp(argv[arg], "-m") == 0) { |
| 17 |
merSize = strtouint32(argv[++arg], 0L); |
| 18 |
} |
| 19 |
arg++; |
| 20 |
} |
| 21 |
|
| 22 |
if (seqName == 0L) { |
| 23 |
fprintf(stderr, "usage: %s [-m mersize] -s seqfile.fasta\n", argv[0]); |
| 24 |
exit(1); |
| 25 |
} |
| 26 |
|
| 27 |
seqStream *CS = new seqStream(seqName, true); |
| 28 |
merStream *MS = new merStream(new kMerBuilder(merSize), CS); |
| 29 |
char str[1024]; |
| 30 |
|
| 31 |
while (MS->nextMer()) |
| 32 |
fprintf(stdout, "%s\n", MS->theFMer().merToString(str)); |
| 33 |
|
| 34 |
delete MS; |
| 35 |
delete CS; |
| 36 |
|
| 37 |
exit(0); |
| 38 |
} |