| 1 | #cxx . . $ `<file>/seatac/configuration.C`/include "seatac.H"cxx . . $ `<file>/seatac/seatac.H`/ |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | #include <stdlib.h> |
| 5 | #include <string.h> |
| 6 | #include <math.h> |
| 7 | |
| 8 | #include "sharedObj.H"cxx . . $ `<file>/seatac/sharedObj.H`/ |
| 9 | |
| 10 | configurationcxx . . $ configuration#::configurationcxx . . $ configuration#configuration(49f6e7a06ebc5aa8).(void) { |
| 11 | |
| 12 | _beVerbosecxx . . $ configuration#_beVerbose. = false; |
| 13 | |
| 14 | _merSizecxx . . $ configuration#_merSize. = 20; |
| 15 | _merSkipcxx . . $ configuration#_merSkip. = 0; |
| 16 | _numSearchThreadscxx . . $ configuration#_numSearchThreads. = 4; |
| 17 | |
| 18 | _doReversecxx . . $ configuration#_doReverse. = true; |
| 19 | _doForwardcxx . . $ configuration#_doForward. = true; |
| 20 | |
| 21 | _maxDiagonalcxx . . $ configuration#_maxDiagonal. = 25; |
| 22 | _maxGapcxx . . $ configuration#_maxGap. = 0; |
| 23 | _qsOverlapcxx . . $ configuration#_qsOverlap. = 15; |
| 24 | _dsOverlapcxx . . $ configuration#_dsOverlap. = 15; |
| 25 | |
| 26 | _minLengthcxx . . $ configuration#_minLength. = 20; |
| 27 | |
| 28 | _dbFileNamecxx . . $ configuration#_dbFileName. = 0L; |
| 29 | _qsFileNamecxx . . $ configuration#_qsFileName. = 0L; |
| 30 | _maskFileNamecxx . . $ configuration#_maskFileName. = 0L; |
| 31 | _onlyFileNamecxx . . $ configuration#_onlyFileName. = 0L; |
| 32 | _outputFileNamecxx . . $ configuration#_outputFileName. = 0L; |
| 33 | _statsFileNamecxx . . $ configuration#_statsFileName. = 0L; |
| 34 | |
| 35 | _tableFileNamecxx . . $ configuration#_tableFileName. = 0L; |
| 36 | _tableBuildOnlycxx . . $ configuration#_tableBuildOnly. = false; |
| 37 | |
| 38 | _filternamecxx . . $ configuration#_filtername. = 0L; |
| 39 | _filteroptscxx . . $ configuration#_filteropts. = 0L; |
| 40 | _filterObjcxx . . $ configuration#_filterObj. = 0L; |
| 41 | |
| 42 | _startTimecxx . . $ configuration#_startTime. = 0.0; |
| 43 | _initTimecxx . . $ configuration#_initTime. = 0.0; |
| 44 | _buildTimecxx . . $ configuration#_buildTime. = 0.0; |
| 45 | _searchTimecxx . . $ configuration#_searchTime. = 0.0; |
| 46 | _totalTimecxx . . $ configuration#_totalTime. = 0.0; |
| 47 | |
| 48 | _loaderHighWaterMarkcxx . . $ configuration#_loaderHighWaterMark. = 2; |
| 49 | _loaderSleepcxx . . $ configuration#_loaderSleep..tv_sec = 1; |
| 50 | _loaderSleepcxx . . $ configuration#_loaderSleep..tv_nsec = 0; |
| 51 | _loaderWarningscxx . . $ configuration#_loaderWarnings. = false; |
| 52 | |
| 53 | _searchSleepcxx . . $ configuration#_searchSleep..tv_sec = 0; |
| 54 | _searchSleepcxx . . $ configuration#_searchSleep..tv_nsec = 10000000; |
| 55 | |
| 56 | _writerHighWaterMarkcxx . . $ configuration#_writerHighWaterMark. = 256; |
| 57 | _writerSleepcxx . . $ configuration#_writerSleep..tv_sec = 1; |
| 58 | _writerSleepcxx . . $ configuration#_writerSleep..tv_nsec = 0; |
| 59 | _writerWarningscxx . . $ configuration#_writerWarnings. = false; |
| 60 | } |
| 61 | |
| 62 | configurationcxx . . $ configuration#::~cxx . . $ configuration#`~configuration`(ced63f7c635d850d).configurationcxx . . $ configuration#() { |
| 63 | } |
| 64 | |
| 65 | static char const *usageStringcxx . . $ usageString. = |
| 66 | "usage: %s [options]\n" |
| 67 | "\n" |
| 68 | "Algorithm Options:\n" |
| 69 | " -mersize k Use k-mers\n" |
| 70 | " -merskip j Skip j mers between each mer inserted into table\n" |
| 71 | " -forward Search only the normal query sequences\n" |
| 72 | " -reverse Search only the reverse-complemented query sequences\n" |
| 73 | " -maxdiagonal d\n" |
| 74 | " -maxgap g\n" |
| 75 | " -qoverlap q\n" |
| 76 | " -doverlap d\n" |
| 77 | " -minelength l\n" |
| 78 | "\n" |
| 79 | "Process Options\n" |
| 80 | " -numthreads n Use n search threads\n" |
| 81 | " -loaderhighwatermark h Size of the loader queue\n" |
| 82 | " -loadersleep t Time the loader will sleep when its output queue is full\n" |
| 83 | " -loaderwarnings Enable warning messages for the loader\n" |
| 84 | " -searchsleep t Time the searcher will sleep when it has no input\n" |
| 85 | " -writerhighwatermark h Size of the output queue\n" |
| 86 | " -writersleep t Time the writer will sleep when it has nothing to write\n" |
| 87 | " -writerwarnings Enable warning messages for the writer\n" |
| 88 | "\n" |
| 89 | " -usetables datfile If 'datfile' exists AND is a complete and valid file,\n" |
| 90 | " load the tables from the file and do the compute.\n" |
| 91 | " Otherwise, fail.\n" |
| 92 | "\n" |
| 93 | " -buildtables datfile If 'datfile' doesn't exist, build the tables, write\n" |
| 94 | " them to 'datfile' and exit. Otherwise, quit.\n" |
| 95 | "\n" |
| 96 | "Filtering Options\n" |
| 97 | " -filtername x.so Use the shared object x.so as a filter method.\n" |
| 98 | " -filteropts opts The string 'opts' is passed to the filter on creation.\n" |
| 99 | "\n" |
| 100 | "Input Options:\n" |
| 101 | " -mask f Ignore all mers listed in file f\n" |
| 102 | " -only f Use only the mers listed in file f\n" |
| 103 | " -stream s.fasta Query sequences (the stream)\n" |
| 104 | " -table t.fasta Database sequences (the table)\n" |
| 105 | " -use #,#,#,# using only those sequences specified\n" |
| 106 | " -use file using only those sequences listed in the file\n" |
| 107 | "\n" |
| 108 | "Output Options\n" |
| 109 | " -verbose Entertain the user\n" |
| 110 | " -output f Write output to file f\n" |
| 111 | " -stats f Write resource statistics to f\n"; |
| 112 | |
| 113 | |
| 114 | |
| 115 | void |
| 116 | configurationcxx . . $ configuration#::usagecxx . . $ configuration#usage(fda57c8427c60377).(char *name) { |
| 117 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, usageStringcxx . . $ usageString., name); |
| 118 | } |
| 119 | |
| 120 | |
| 121 | |
| 122 | void |
| 123 | configurationcxx . . $ configuration#::readcxx . . $ configuration#read(c759356ac01a31e7).(int argc, char **argv) { |
| 124 | int fail = 0; |
| 125 | int arg = 1; |
| 126 | while (arg < argc) { |
| 127 | if (strcmp(argv[arg], "-mersize") == 0) { |
| 128 | arg++; |
| 129 | _merSizecxx . . $ configuration#_merSize. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[arg]); |
| 130 | } else if (strcmp(argv[arg], "-merskip") == 0) { |
| 131 | arg++; |
| 132 | _merSkipcxx . . $ configuration#_merSkip. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[arg]); |
| 133 | } else if (strcmp(argv[arg], "-numthreads") == 0) { |
| 134 | arg++; |
| 135 | _numSearchThreadscxx . . $ configuration#_numSearchThreads. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[arg]); |
| 136 | } else if (strcmp(argv[arg], "-mask") == 0) { |
| 137 | arg++; |
| 138 | _maskFileNamecxx . . $ configuration#_maskFileName. = argv[arg]; |
| 139 | } else if (strcmp(argv[arg], "-only") == 0) { |
| 140 | arg++; |
| 141 | _onlyFileNamecxx . . $ configuration#_onlyFileName. = argv[arg]; |
| 142 | } else if (strcmp(argv[arg], "-usetables") == 0) { |
| 143 | arg++; |
| 144 | _tableFileNamecxx . . $ configuration#_tableFileName. = argv[arg]; |
| 145 | _tableBuildOnlycxx . . $ configuration#_tableBuildOnly. = false; |
| 146 | } else if (strcmp(argv[arg], "-buildtables") == 0) { |
| 147 | arg++; |
| 148 | _tableFileNamecxx . . $ configuration#_tableFileName. = argv[arg]; |
| 149 | _tableBuildOnlycxx . . $ configuration#_tableBuildOnly. = true; |
| 150 | } else if (strcmp(argv[arg], "-stream") == 0) { |
| 151 | arg++; |
| 152 | _qsFileNamecxx . . $ configuration#_qsFileName. = argv[arg]; |
| 153 | } else if (strcmp(argv[arg], "-table") == 0) { |
| 154 | arg++; |
| 155 | _dbFileNamecxx . . $ configuration#_dbFileName. = argv[arg]; |
| 156 | } else if (strcmp(argv[arg], "-use") == 0) { |
| 157 | arg++; |
| 158 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: -use not supported anymore.\n", argv[0]); |
| 159 | exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 160 | } else if (strcmp(argv[arg], "-forward") == 0) { |
| 161 | _doForwardcxx . . $ configuration#_doForward. = true; |
| 162 | _doReversecxx . . $ configuration#_doReverse. = false; |
| 163 | } else if (strcmp(argv[arg], "-reverse") == 0) { |
| 164 | _doReversecxx . . $ configuration#_doReverse. = true; |
| 165 | _doForwardcxx . . $ configuration#_doForward. = false; |
| 166 | } else if (strcmp(argv[arg], "-verbose") == 0) { |
| 167 | _beVerbosecxx . . $ configuration#_beVerbose. = true; |
| 168 | } else if (strcmp(argv[arg], "-output") == 0) { |
| 169 | arg++; |
| 170 | _outputFileNamecxx . . $ configuration#_outputFileName. = argv[arg]; |
| 171 | } else if (strcmp(argv[arg], "-stats") == 0) { |
| 172 | arg++; |
| 173 | _statsFileNamecxx . . $ configuration#_statsFileName. = argv[arg]; |
| 174 | } else if (strcmp(argv[arg], "-maxdiagonal") == 0) { |
| 175 | arg++; |
| 176 | _maxDiagonalcxx . . $ configuration#_maxDiagonal. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[arg]); |
| 177 | } else if (strcmp(argv[arg], "-maxgap") == 0) { |
| 178 | arg++; |
| 179 | _maxGapcxx . . $ configuration#_maxGap. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[arg]); |
| 180 | } else if (strcmp(argv[arg], "-qoverlap") == 0) { |
| 181 | arg++; |
| 182 | _qsOverlapcxx . . $ configuration#_qsOverlap. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[arg]); |
| 183 | } else if (strcmp(argv[arg], "-doverlap") == 0) { |
| 184 | arg++; |
| 185 | _dsOverlapcxx . . $ configuration#_dsOverlap. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[arg]); |
| 186 | } else if (strcmp(argv[arg], "-minlength") == 0) { |
| 187 | arg++; |
| 188 | _minLengthcxx . . $ configuration#_minLength. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[arg]); |
| 189 | } else if (strncmp(argv[arg], "-loaderhighwatermark", 8) == 0) { |
| 190 | _loaderHighWaterMarkcxx . . $ configuration#_loaderHighWaterMark. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[++arg]); |
| 191 | } else if (strncmp(argv[arg], "-loadersleep", 8) == 0) { |
| 192 | setTimecxx . . $ configuration#setTime(ac28bcc6049edbea).(&_loaderSleepcxx . . $ configuration#_loaderSleep., atofcxx . . $ atof(9b0361fcbc284e4f).(argv[++arg])); |
| 193 | } else if (strncmp(argv[arg], "-loaderwarnings", 8) == 0) { |
| 194 | _loaderWarningscxx . . $ configuration#_loaderWarnings. = true; |
| 195 | } else if (strncmp(argv[arg], "-searchsleep", 8) == 0) { |
| 196 | setTimecxx . . $ configuration#setTime(ac28bcc6049edbea).(&_searchSleepcxx . . $ configuration#_searchSleep., atofcxx . . $ atof(9b0361fcbc284e4f).(argv[++arg])); |
| 197 | } else if (strncmp(argv[arg], "-writerhighwatermark", 8) == 0) { |
| 198 | _writerHighWaterMarkcxx . . $ configuration#_writerHighWaterMark. = atoicxx . . $ atoi(f5ecf3191ed0cd93).(argv[++arg]); |
| 199 | } else if (strncmp(argv[arg], "-writersleep", 8) == 0) { |
| 200 | setTimecxx . . $ configuration#setTime(ac28bcc6049edbea).(&_writerSleepcxx . . $ configuration#_writerSleep., atofcxx . . $ atof(9b0361fcbc284e4f).(argv[++arg])); |
| 201 | } else if (strncmp(argv[arg], "-writerwarnings", 8) == 0) { |
| 202 | _writerWarningscxx . . $ configuration#_writerWarnings. = true; |
| 203 | } else if (strcmp(argv[arg], "-filtername") == 0) { |
| 204 | arg++; |
| 205 | _filternamecxx . . $ configuration#_filtername. = argv[arg]; |
| 206 | _filterObjcxx . . $ configuration#_filterObj. = new sharedObjcxx . . $ sharedObj#(argv[arg]); |
| 207 | } else if (strcmp(argv[arg], "-filteropts") == 0) { |
| 208 | arg++; |
| 209 | _filteroptscxx . . $ configuration#_filteropts. = argv[arg]; |
| 210 | } else { |
| 211 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: Unknown option '%s'\n", argv[arg]); |
| 212 | fail++; |
| 213 | } |
| 214 | arg++; |
| 215 | } |
| 216 | |
| 217 | if (fail) |
| 218 | exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 219 | |
| 220 | // |
| 221 | // Make sure some constraints are met |
| 222 | // |
| 223 | |
| 224 | if (_numSearchThreadscxx . . $ configuration#_numSearchThreads. > MAX_THREADScxx . . $ `seatac/seatac.H:61:9`!) { |
| 225 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: Threads are limited to %d.\n", MAX_THREADScxx . . $ `seatac/seatac.H:61:9`!); |
| 226 | exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 227 | } |
| 228 | |
| 229 | if (_maskFileNamecxx . . $ configuration#_maskFileName. && _onlyFileNamecxx . . $ configuration#_onlyFileName.) { |
| 230 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: At most one of -mask and -only may be used.\n"); |
| 231 | exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 232 | } |
| 233 | |
| 234 | // |
| 235 | // Check that the mers are at least adjacent |
| 236 | // |
| 237 | if (_merSkipcxx . . $ configuration#_merSkip. >= _merSizecxx . . $ configuration#_merSize.) { |
| 238 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "ERROR: Mers are not adjacent; make sure merskip <= mersize.\n"); |
| 239 | exitcxx . . $ exit(44ed87f96534fad7).(1); |
| 240 | } |
| 241 | |
| 242 | // |
| 243 | // Test that we can build filter and stat objects |
| 244 | // |
| 245 | if (_filternamecxx . . $ configuration#_filtername.) { |
| 246 | filterObjcxx . . $ filterObj# *testf = new filterObjcxx . . $ filterObj#(_filterObjcxx . . $ configuration#_filterObj., _filteroptscxx . . $ configuration#_filteropts.); |
| 247 | delete testf; |
| 248 | |
| 249 | statObjcxx . . $ statObj# *tests = new statObjcxx . . $ statObj#statObj(6f6da539ca2a87b6).(_filterObjcxx . . $ configuration#_filterObj., _filteroptscxx . . $ configuration#_filteropts.); |
| 250 | delete tests; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | |
| 255 | void |
| 256 | configurationcxx . . $ configuration#::writeATACheadercxx . . $ configuration#writeATACheader(8d4262d45fc644ab).(FILE *out) { |
| 257 | fprintf(out, "! format atac 1.0\n"); |
| 258 | fprintf(out, "/seatacBeVerbose=%s\n", _beVerbosecxx . . $ configuration#_beVerbose. ? "enabled" : "disabled"); |
| 259 | fprintf(out, "/seatacNumSearchThreads="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", _numSearchThreadscxx . . $ configuration#_numSearchThreads.); |
| 260 | fprintf(out, "/seatacLoaderHighWaterMark="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", _loaderHighWaterMarkcxx . . $ configuration#_loaderHighWaterMark.); |
| 261 | fprintf(out, "/seatacLoaderSleep=%f\n", (double)_loaderSleepcxx . . $ configuration#_loaderSleep..tv_sec + (double)_loaderSleepcxx . . $ configuration#_loaderSleep..tv_nsec * 1e-9); |
| 262 | fprintf(out, "/seatacLoaderWarnings=%s\n", _loaderWarningscxx . . $ configuration#_loaderWarnings. ? "true" : "false"); |
| 263 | fprintf(out, "/seatacSearchSleep=%f\n", (double)_searchSleepcxx . . $ configuration#_searchSleep..tv_sec + (double)_searchSleepcxx . . $ configuration#_searchSleep..tv_nsec * 1e-9); |
| 264 | fprintf(out, "/seatacWriterHighWaterMark="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", _writerHighWaterMarkcxx . . $ configuration#_writerHighWaterMark.); |
| 265 | fprintf(out, "/seatacWriterSleep=%f\n", (double)_writerSleepcxx . . $ configuration#_writerSleep..tv_sec + (double)_writerSleepcxx . . $ configuration#_writerSleep..tv_nsec * 1e-9); |
| 266 | fprintf(out, "/seatacWriterWarnings=%s\n", _writerWarningscxx . . $ configuration#_writerWarnings. ? "true" : "false"); |
| 267 | fprintf(out, "/seatacMaxDiagonal="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", _maxDiagonalcxx . . $ configuration#_maxDiagonal.); |
| 268 | fprintf(out, "/seatacMaxGap="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", _maxGapcxx . . $ configuration#_maxGap.); |
| 269 | fprintf(out, "/seatacQsOverlap="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", _qsOverlapcxx . . $ configuration#_qsOverlap.); |
| 270 | fprintf(out, "/seatacDsOverlap="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", _dsOverlapcxx . . $ configuration#_dsOverlap.); |
| 271 | fprintf(out, "/seatacMinLength="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", _minLengthcxx . . $ configuration#_minLength. + _merSizecxx . . $ configuration#_merSize.); |
| 272 | fprintf(out, "/seatacMerSize="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", _merSizecxx . . $ configuration#_merSize.); |
| 273 | fprintf(out, "/seatacMerSkip="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", _merSkipcxx . . $ configuration#_merSkip.); |
| 274 | fprintf(out, "/seatacDoReverse=%s\n", (_doReversecxx . . $ configuration#_doReverse.) ? "true" : "false"); |
| 275 | fprintf(out, "/seatacDoForward=%s\n", (_doForwardcxx . . $ configuration#_doForward.) ? "true" : "false"); |
| 276 | fprintf(out, "/seatacFilterName=%s\n", (_filternamecxx . . $ configuration#_filtername.) ? _filternamecxx . . $ configuration#_filtername. : "None Specified."); |
| 277 | fprintf(out, "/seatacFilterOpts=%s\n", (_filteroptscxx . . $ configuration#_filteropts.) ? _filteroptscxx . . $ configuration#_filteropts. : "None Specified."); |
| 278 | fprintf(out, "/seatacDbFile=%s\n", (_dbFileNamecxx . . $ configuration#_dbFileName.) ? _dbFileNamecxx . . $ configuration#_dbFileName. : "None Specified."); |
| 279 | fprintf(out, "/seatacQsFile=%s\n", (_qsFileNamecxx . . $ configuration#_qsFileName.) ? _qsFileNamecxx . . $ configuration#_qsFileName. : "None Specified."); |
| 280 | fprintf(out, "/seatacMaskFile=%s\n", (_maskFileNamecxx . . $ configuration#_maskFileName.) ? _maskFileNamecxx . . $ configuration#_maskFileName. : "None Specified."); |
| 281 | fprintf(out, "/seatacOnlyFile=%s\n", (_onlyFileNamecxx . . $ configuration#_onlyFileName.) ? _onlyFileNamecxx . . $ configuration#_onlyFileName. : "None Specified."); |
| 282 | fprintf(out, "/seatacOutputFile=%s\n", (_outputFileNamecxx . . $ configuration#_outputFileName.) ? _outputFileNamecxx . . $ configuration#_outputFileName. : "None Specified."); |
| 283 | fprintf(out, "/seatacStatsFile=%s\n", (_statsFileNamecxx . . $ configuration#_statsFileName.) ? _statsFileNamecxx . . $ configuration#_statsFileName. : "None Specified."); |
| 284 | fprintf(out, "/seatacTableFile=%s\n", (_tableFileNamecxx . . $ configuration#_tableFileName.) ? _tableFileNamecxx . . $ configuration#_tableFileName. : "None Specified."); |
| 285 | } |