Debian Codegraph @

atac-driver/lengthFilter/lengthFilter.C

raw symbols SCIP
1 // This file is part of A2Amapper.cxx . . $ `<file>/atac-driver/lengthFilter/lengthFilter.C`/
2 // Copyright (c) 2005 J. Craig Venter Institute
3 // Author: Brian Walenz
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received (LICENSE.txt) a copy of the GNU General Public
16 // License along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <ctype.h>
23
24 #include "util++.H"cxx . . $ `<file>/libutil/util++.H`/
25
26 // Filters out matches that are too short.
27 //
28 // Original implementation in Python by Clark Mobarry.
29
30 void
31 readHeadercxx . . $ readHeader(fa6d6913e4a5adf0).(char *inLine, FILE *in, uint32cxx . . $ uint32# &minLength, FILE *out) {
32 bool printedLength = false;
33
34 fgets(inLine, 1024, in);
35 while (!feof(in) && (inLine[0] != 'M')) {
36
37 if (strncmp(inLine, "/globalMatchMinSize", 18) == 0) {
38 if (minLength > 0) {
39 // Skip any whitespace, the =, and more whitespace. Copy.
40 char *tmp = inLine + 14;
41 while (isspace(*tmp)) tmp++;
42 while (*tmp == '=') tmp++;
43 while (isspace(*tmp)) tmp++;
44 minLength = strtouint32cxx . . $ `libutil/util.h:82:10`!(tmp, 0L);
45 }
46 sprintf(inLine, "/globalMatchMinSize="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", minLength);
47 printedLength = true;
48 }
49
50 if (out)
51 fputs(inLine, out);
52
53 fgets(inLine, 1024, in);
54 }
55
56 if (printedLength == false)
57 fprintf(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "/globalMatchMinSize="uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", minLength);
58
59 if (minLength == 0) {
60 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "I didn't find /globalMatchMinSize, please set it with -l\n");
61 exitcxx . . $ exit(44ed87f96534fad7).(1);
62 }
63 }
64
65
66 int
67 maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) {
68 char inLine[1024] = {0};
69 uint32cxx . . $ uint32# minLength = 0;
70 uint32cxx . . $ uint32# totalDumped = 0;
71 uint32cxx . . $ uint32# totalDumpedLength = 0;
72 uint32cxx . . $ uint32# totalSaved = 0;
73 uint32cxx . . $ uint32# totalSavedLength = 0;
74
75 int arg = 1;
76 while (arg < argc) {
77 if (strcmp(argv[arg], "-l") == 0) {
78 minLength = strtouint32cxx . . $ `libutil/util.h:82:10`!(argv[++arg], 0L);
79 } else {
80 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s [-h] [-l length] < matches.atac > matches.atac\n", argv[0]);
81 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, " filters out all matches less than 'length' long.\n");
82 exitcxx . . $ exit(44ed87f96534fad7).(1);
83 }
84 arg++;
85 }
86
87 readHeadercxx . . $ readHeader(fa6d6913e4a5adf0).(inLine, stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!, minLength, stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
88
89 // we need to parse the header to get globalMatchMinSize,
90 // and then let the command line override it. just make
91 // a custom readHeader() for here, do it there. nothing
92 // difficult.
93
94 while (!feof(stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!)) {
95 if (inLine[0] == 'M') {
96 splitToWordscxx . . $ splitToWords# Scxx . . $ splitToWords#splitToWords(fda57c8427c60377).(inLine);
97
98 if ((strtouint32cxx . . $ `libutil/util.h:82:10`!(S[ 6], 0L) >= minLength) &&
99 (strtouint32cxx . . $ `libutil/util.h:82:10`!(S[10], 0L) >= minLength)) {
100 totalSaved++;
101 totalSavedLength += strtouint32cxx . . $ `libutil/util.h:82:10`!(S[ 6], 0L);
102 fputs(inLine, stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
103 } else {
104 totalDumped++;
105 totalDumpedLength += strtouint32cxx . . $ `libutil/util.h:82:10`!(S[ 6], 0L);
106 }
107 } else {
108 fputs(inLine, stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
109 }
110
111 fgets(inLine, 1024, stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!);
112 }
113
114 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "lengthFilter: Discarded "uint32FMTWcxx . . $ `libutil/util.h:64:10`!(8)" matches with total length "uint32FMTWcxx . . $ `libutil/util.h:64:10`!(10)", %7.3f%% of the sequence in matches.\n",
115 totalDumped, totalDumpedLength, (double)totalDumpedLength / (totalDumpedLength + totalSavedLength) * 100.0);
116 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "lengthFilter: Saved "uint32FMTWcxx . . $ `libutil/util.h:64:10`!(8)" matches with total length "uint32FMTWcxx . . $ `libutil/util.h:64:10`!(10)", %7.3f%% of the sequence in matches.\n",
117 totalSaved, totalSavedLength, (double)totalSavedLength / (totalDumpedLength + totalSavedLength) * 100.0);
118 }