Debian Codegraph @

sim4dbutils/uniqPolishes.C

raw symbols SCIP
1 #cxx . . $ `<file>/sim4dbutils/uniqPolishes.C`/include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5
6 #include "sim4.H"cxx . . $ `<file>/libsim4/sim4.H`/
7
8
9 void
10 pickBestcxx . . $ pickBest(edbc739458abaecd).(sim4polishWritercxx . . $ sim4polishWriter# *W, sim4polishcxx . . $ sim4polish# **p, int pNum, int uniq) {
11 int i;
12
13 if (pNum == 1) {
14 if (uniq)
15 W->writeAlignmentcxx . . $ sim4polishWriter#writeAlignment(e4476af38b2ba703).(p[0]);
16 } else {
17 if (!uniq)
18 for (i=0; i<pNum; i++)
19 W->writeAlignmentcxx . . $ sim4polishWriter#writeAlignment(e4476af38b2ba703).(p[0]);
20 }
21
22 for (i=0; i<pNum; i++)
23 delete p[i];
24 }
25
26
27
28
29 int
30 maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) {
31 uint32cxx . . $ uint32# pNum = 0;
32 uint32cxx . . $ uint32# pAlloc = 8388608;
33 uint32cxx . . $ uint32# estID = ~uint32ZEROcxx . . $ `libutil/util.h:60:10`!;
34
35 uint32cxx . . $ uint32# uniq = 1;
36
37 sim4polishStylecxx . . $ sim4polishStyle# style = sim4polishStyleDefaultcxx . . $ sim4polishStyleDefault.;
38
39 int arg = 1;
40 while (arg < argc) {
41 if (strncmp(argv[arg], "-uniq", 2) == 0) {
42 uniq = 1;
43 } else if (strncmp(argv[arg], "-dupl", 2) == 0) {
44 uniq = 0;
45 } else if (strcmp(argv[arg], "-gff3") == 0) {
46 style = sim4polishGFF3cxx . . $ sim4polishGFF3.;
47 } else {
48 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "unknown option: %s\n", argv[arg]);
49 }
50 arg++;
51 }
52
53 if (isatty(fileno(stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!))) {
54 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s [-uniq | -dupl] [-gff3] < file > file\n", argv[0]);
55
56 if (isatty(fileno(stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!)))
57 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "error: I cannot read polishes from the terminal!\n\n");
58
59 exitcxx . . $ exit(44ed87f96534fad7).(1);
60 }
61
62 // Read polishes, picking the best when we see a change in
63 // the estID.
64
65 sim4polishWritercxx . . $ sim4polishWriter# *W = new sim4polishWritercxx . . $ sim4polishWriter#sim4polishWriter(aa526814cdac5c89).("-", style);
66 sim4polishReadercxx . . $ sim4polishReader# *R = new sim4polishReadercxx . . $ sim4polishReader#sim4polishReader(4e2129de7e035ecf).("-");
67 sim4polishcxx . . $ sim4polish# **p = new sim4polishcxx . . $ sim4polish# * [pAlloc];
68 sim4polishcxx . . $ sim4polish# *q = 0L;
69
70 if (R->getsim4polishStylecxx . . $ sim4polishReader#getsim4polishStyle(d210391ccb2ed472).() != style)
71 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "warning: input format and output format differ.\n");
72
73 while (R->nextAlignmentcxx . . $ sim4polishReader#nextAlignment(da710bb2bbb3ccde).(q)) {
74 if ((q->_estIDcxx . . $ sim4polish#_estID. != estID) && (pNum > 0)) {
75 pickBestcxx . . $ pickBest(edbc739458abaecd).(W, p, pNum, uniq);
76 pNum = 0;
77 }
78
79 if (pNum >= pAlloc) {
80 sim4polishcxx . . $ sim4polish# **P = new sim4polishcxx . . $ sim4polish# * [pAlloc * 2];
81 memcpy(p, P, sizeof(sim4polishcxx . . $ sim4polish# *) * pAlloc);
82 delete [] p;
83 p = P;
84 pAlloc *= 2;
85 }
86
87 p[pNum++] = q;
88 estID = q->_estIDcxx . . $ sim4polish#_estID.;
89
90 q = 0L; // Else we'll delete the polish we just saved!
91 }
92
93 if (pNum > 0)
94 pickBestcxx . . $ pickBest(edbc739458abaecd).(W, p, pNum, uniq);
95
96 delete [] p;
97 delete R;
98 delete W;
99
100 return(0);
101 }
102