void writeMessagePointer(const MessageSeverity* messServer){ writeElapsedTime(); messServer->writeMessage(); }
int main(int argc, char **argv) { char *shortSequence = NULL, *longSequence = NULL, /* eventually point to buffers for the two sequences */ *outputPath = NULL; /* eventually points to the path for the output */ int shortLength=0, longLength=0; /* space required for each of those buffers */ int repetitions = 1; /* number of repetitions: one is the default */ int n; /* index into argv array */ long start, iterationStart, dataRead, scoringDone; /* timestamps to compute elapsed time */ const char * const usage = "sw: usage is \r\n\tsw -s shortPath -l longPath -p paramPath [-o outputPath] [-r repetitions]\r\n.\r\n"; const char * const phases[] = {"Input phase:", "Scoring phase:", "Traceback phase:"}; int rc = 0; buffer = malloc(BUFFER_SIZE*sizeof(char)); Output output; output.shorterPath = output.longerPath = NULL; for(n=1; n<argc-1; n+=2) { /* pull the sequence number from the command line */ char *value = argv[n+1]; switch(argv[n][1]) { case 's': output.shorterPath = value; break; case 'l': output.longerPath = value; break; case 'o': outputPath = value; break; case 'p': readParameters(value); break; case 'r': repetitions = atoi(value); break; default: fprintf(stderr, usage); return 10; } } if (alphabetSize == 0) { /* no point in proceeding if parameters are not correct */ fprintf(stderr, "No parameter path supplied or parameters are incorrect\n%s", usage); rc = 19; } if (output.shorterPath == NULL) { fprintf(stderr, "No path for shorter sequence supplied\n%s", usage); rc = 20; } if (output.longerPath == NULL) { fprintf(stderr, "No path for longer sequence supplied\n%s", usage); rc = 21; } free(buffer); if (rc > 0) return rc; start = nowInMilliseconds(); startTimings(&output, repetitions, 3, phases); for(n = 0; n<repetitions; n++) { output.phases = 0; output.iterations = n; iterationStart = nowInMilliseconds(); shortSequence = readASequence(output.shorterPath); shortLength = 1+strlen(shortSequence); /* this is the WHOLE BUFFER SIZE: add 1 for the sentinel 0 byte */ longSequence = readASequence(output.longerPath); longLength = 1+strlen(longSequence); /* this is the WHOLE BUFFER SIZE: add 1 for the sentinel 0 byte */ dataRead = writeElapsedTime(&output, iterationStart); computeTheBestScores(shortSequence, shortLength, longSequence, longLength); scoringDone = writeElapsedTime(&output, dataRead); doTheTraceback(shortSequence, shortLength, longSequence, longLength, &output); writeElapsedTime(&output, scoringDone); free(shortSequence); free(longSequence); } writeOutput(&output, outputPath, (int)(nowInMilliseconds()-start)); return 0; }
void writeMessageReference(const MessageSeverity& messServer){ writeElapsedTime(); messServer.writeMessage(); }