Debian Codegraph @

meryl/simple.C

raw symbols SCIP
1 #cxx . . $ `<file>/meryl/simple.C`/include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4 #include <string.h>
5
6 #include <algorithm>
7
8 #include "bio++.H"cxx . . $ `<file>/libbio/bio++.H`/
9 #include "meryl.H"cxx . . $ `<file>/meryl/meryl.H`/
10
11 #include "libmeryl.H"cxx . . $ `<file>/libmeryl/libmeryl.H`/
12 #include "seqStream.H"cxx . . $ `<file>/libseq/seqStream.H`/
13 #include "merStream.H"cxx . . $ `<file>/libseq/merStream.H`/
14
15 using namespace std;
16
17 // A very simple mer counter. Allocates a gigantic 32-bit array,
18 // populates the array with mers, sorts, writes output.
19
20 int
21 maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) {
22 char *inName = 0L;
23 char *otName = 0L;
24 uint32cxx . . $ uint32# merSize = 22;
25 uint32cxx . . $ uint32# merCompression = 1;
26
27 bool doForward = true;
28 bool doReverse = false;
29 bool doCanonical = false;
30
31 speedCountercxx . . $ speedCounter# *C = 0L;
32 merStreamcxx . . $ merStream# *M = 0L;
33 merylStreamWritercxx . . $ merylStreamWriter# *W = 0L;
34
35 uint64cxx . . $ uint64# numMers = 0;
36
37 uint64cxx . . $ uint64# *theMers = 0L;
38 uint64cxx . . $ uint64# theMersMax = 0;
39 uint64cxx . . $ uint64# theMersLen = 0;
40
41 int arg = 1;
42 int err = 0;
43 while (arg < argc) {
44 if (strcmp(argv[arg], "-i") == 0) {
45 inName = argv[++arg];
46
47 } else if (strcmp(argv[arg], "-o") == 0) {
48 otName = argv[++arg];
49
50 } else if (strcmp(argv[arg], "-m") == 0) {
51 merSize = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[++arg]);
52
53 } else if (strcmp(argv[arg], "-f") == 0) {
54 doForward = true;
55 doReverse = false;
56 doCanonical = false;
57
58 } else if (strcmp(argv[arg], "-r") == 0) {
59 doForward = false;
60 doReverse = true;
61 doCanonical = false;
62
63 } else if (strcmp(argv[arg], "-C") == 0) {
64 doForward = false;
65 doReverse = false;
66 doCanonical = true;
67
68 } else if (strcmp(argv[arg], "-c") == 0) {
69 merCompression = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[++arg]);
70
71 } else {
72 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "unknown option '%s'\n", argv[arg]);
73 err++;
74 }
75
76 arg++;
77 }
78 if (inName == 0L) {
79 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "no input given with '-i'\n");
80 err++;
81 }
82 if (otName == 0L) {
83 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "no output given with '-o'\n");
84 err++;
85 }
86 if (err)
87 exitcxx . . $ exit(44ed87f96534fad7).(1);
88
89
90 {
91 M = new merStreamcxx . . $ merStream#(new kMerBuildercxx . . $ kMerBuilder#(merSize, merCompression),
92 new seqStreamcxx . . $ seqStream#(inName),
93 true, true);
94 numMers = M->approximateNumberOfMerscxx . . $ merStream#approximateNumberOfMers(f708dce9a8856c70).();
95 delete M;
96 }
97
98 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Guessing "uint64FMTcxx . . $ `libutil/util.h:55:10`!" mers in input '%s'\n", numMers, inName);
99 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Allocating "uint64FMTcxx . . $ `libutil/util.h:55:10`!"MB for mer storage.\n", numMers * 8 >> 20);
100
101 theMers = new uint64cxx . . $ uint64# [numMers];
102 theMersLen = 0;
103 theMersMax = numMers;
104
105 ////////////////////////////////////////
106
107 C = new speedCountercxx . . $ speedCounter#(" Counting mers in buckets: %7.2f Mmers -- %5.2f Mmers/second\r", 1000000.0, 0x1fffff, 1);
108 M = new merStreamcxx . . $ merStream#(new kMerBuildercxx . . $ kMerBuilder#(merSize, merCompression),
109 new seqStreamcxx . . $ seqStream#(inName),
110 true, true);
111 //M->setRange(args->mersPerBatch * segment, args->mersPerBatch * segment + args->mersPerBatch);
112
113 while (M->nextMercxx . . $ merStream#nextMer(dfa6e707f7696010).()) {
114 if (doForward)
115 theMers[theMersLen++] = M->theFMercxx . . $ merStream#theFMer(52e25c29fea41909).();
116
117 if (doReverse)
118 theMers[theMersLen++] = M->theRMercxx . . $ merStream#theRMer(52e25c29fea41909).();
119
120 if (doCanonical)
121 theMers[theMersLen++] = (M->theFMercxx . . $ merStream#theFMer(52e25c29fea41909).() <=cxx . . $ kMerTiny#`operator<=`(3a2dde3078dcd13f). M->theRMercxx . . $ merStream#theRMer(52e25c29fea41909).()) ? M->theFMercxx . . $ merStream#theFMer(52e25c29fea41909).() : M->theRMercxx . . $ merStream#theRMer(52e25c29fea41909).();
122
123 C->tickcxx . . $ speedCounter#tick(c9857a73d68e59ba).();
124 }
125
126 delete C;
127 delete M;
128
129 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Found "uint64FMTcxx . . $ `libutil/util.h:55:10`!" mers in input '%s'\n", theMersLen, inName);
130
131 if (theMersLen > theMersMax)
132 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: too many mers in input!\n"), exitcxx . . $ exit(44ed87f96534fad7).(1);
133
134 ////////////////////////////////////////
135
136 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "sorting\n");
137
138 sortcxx . . $ std/sort(249673c20e2b8d5).(theMers, theMers + theMersLen);
139
140 ////////////////////////////////////////
141
142 C = new speedCountercxx . . $ speedCounter#(" Writing output: %7.2f Mmers -- %5.2f Mmers/second\r", 1000000.0, 0x1fffff, 1);
143 W = new merylStreamWritercxx . . $ merylStreamWriter#(otName,
144 merSize, merCompression,
145 16,
146 false);
147
148 kMercxx . . $ kMer# mercxx . . $ kMerTiny#kMerTiny(cb2f890c2fdad230).(merSize);
149
150 for (uint64cxx . . $ uint64# i=0; i<theMersLen; i++) {
151 mer.setWordcxx . . $ kMerTiny#setWord(588cb903c6b0e163).(0, theMers[i]);
152 W->addMercxx . . $ merylStreamWriter#addMer(5afe88a7d2541197).(mer, 1, 0L);
153 C->tickcxx . . $ speedCounter#tick(c9857a73d68e59ba).();
154 }
155
156 delete C;
157 delete W;
158
159 ////////////////////////////////////////
160
161 delete [] theMers;
162
163 exitcxx . . $ exit(44ed87f96534fad7).(0);
164 }