Debian Codegraph @

sim4dbutils/mergePolishes.C

raw symbols SCIP
1 #cxx . . $ `<file>/sim4dbutils/mergePolishes.C`/include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4
5 #include "bio++.H"cxx . . $ `<file>/libbio/bio++.H`/
6 //#include "fasta.H"
7 #include "sim4.H"cxx . . $ `<file>/libsim4/sim4.H`/
8
9 // usage: mergeInput -m match1 cdna1 -m match2 cdna2 -m ... -o match cdna [-gff3]
10 //
11 // Merges the results from two ESTmapper runs. The runs MUST be on
12 // the same genomic sequence using DIFFERENT cDNA inputs.
13
14 static
15 void
16 loadNextcxx . . $ loadNext(54d4dd26c7c07731).(uint32cxx . . $ uint32# idx, sim4polishcxx . . $ sim4polish# **polishes, sim4polishReadercxx . . $ sim4polishReader# **inMatch, uint32cxx . . $ uint32# *numSeqs) {
17 if (inMatch[idx]->nextAlignmentcxx . . $ sim4polishReader#nextAlignment(da710bb2bbb3ccde).(polishes[idx]))
18 polishes[idx]->_estIDcxx . . $ sim4polish#_estID. += numSeqs[idx];
19 }
20
21 int
22 maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv) {
23 char **inMatchName = new char * [argc];
24 char **inSeqName = new char * [argc];
25 char *otMatchName = 0L;
26 char *otSeqName = 0L;
27
28 sim4polishReadercxx . . $ sim4polishReader# **inMatch = new sim4polishReadercxx . . $ sim4polishReader# * [argc];
29 sim4polishcxx . . $ sim4polish# **polishes = new sim4polishcxx . . $ sim4polish# * [argc];
30 sim4polishWritercxx . . $ sim4polishWriter# *otMatch = 0L;
31 uint32cxx . . $ uint32# *numSeqs = new uint32cxx . . $ uint32# [argc];
32
33 uint32cxx . . $ uint32# numIn = 0;
34
35 sim4polishStylecxx . . $ sim4polishStyle# style = sim4polishStyleDefaultcxx . . $ sim4polishStyleDefault.;
36
37 int arg = 1;
38 while (arg < argc) {
39 if (strcmp(argv[arg], "-m") == 0) {
40 arg++;
41 inMatchName[numIn] = (char *)argv[arg++];
42 inSeqName[numIn] = (char *)argv[arg++];
43
44 inMatch[numIn] = new sim4polishReadercxx . . $ sim4polishReader#sim4polishReader(4e2129de7e035ecf).(inMatchName[numIn]);
45 numIn++;
46
47 } else if (strcmp(argv[arg], "-o") == 0) {
48 arg++;
49 otMatchName = (char *)argv[arg++];
50 otSeqName = (char *)argv[arg++];
51
52 } else if (strcmp(argv[arg], "-gff3") == 0) {
53 style = sim4polishGFF3cxx . . $ sim4polishGFF3.;
54
55 }
56 }
57
58 if ((numIn < 1) || (otMatchName == 0L)) {
59 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "usage: %s -o match cdna -m match1 cdna1 -m match2 cdna2 -m ... [-gff3]\n", argv[0]);
60 exitcxx . . $ exit(44ed87f96534fad7).(1);
61 }
62
63 otMatch = new sim4polishWritercxx . . $ sim4polishWriter#sim4polishWriter(aa526814cdac5c89).(otMatchName, style);
64
65 for (uint32cxx . . $ uint32# i=0; i<numIn; i++)
66 if (inMatch[i]->getsim4polishStylecxx . . $ sim4polishReader#getsim4polishStyle(d210391ccb2ed472).() != style) {
67 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "warning: input format and output format may differ.\n");
68 break;
69 }
70
71 // Merge the input sequences into the output sequence. We also count the number of sequences
72 // here, so we don't need random-access of the input.
73 //
74 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Merging sequences.\n");
75
76 FILE *O = fopen(otSeqName, "w");
77 for (uint32cxx . . $ uint32# i=0; i<numIn; i++) {
78 seqCachecxx . . $ seqCache# *I = new seqCachecxx . . $ seqCache#seqCache(cc76bd1196c143a3).(inSeqName[i]);
79 seqInCorecxx . . $ seqInCore# *B = I->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(3b3b07432ed6dd5c).();
80
81 numSeqs[i] = 0;
82
83 while (B) {
84 fprintf(O, ">%s\n%s\n", B->headercxx . . $ seqInCore#header(e7e5aa338b9d5147).(), B->sequencecxx . . $ seqInCore#sequence(e7e5aa338b9d5147).());
85 numSeqs[i]++;
86
87 delete B;
88 B = I->getSequenceInCorecxx . . $ seqCache#getSequenceInCore(3b3b07432ed6dd5c).();
89 }
90
91 delete I;
92 }
93 fclose(O);
94
95
96 // Make numSeqs[] be the offset needed to convert a polish in each inMatch[] file into a polish
97 // in the merged file.
98 //
99 uint32cxx . . $ uint32# o = 0;
100 uint32cxx . . $ uint32# s = 0;
101 for (uint32cxx . . $ uint32# i=0; i<numIn; i++) {
102 o = numSeqs[i];
103 numSeqs[i] = s;
104 s += o;
105 }
106
107 // Load the initial polishes
108 //
109 for (uint32cxx . . $ uint32# i=0; i<numIn; i++)
110 loadNextcxx . . $ loadNext(54d4dd26c7c07731).(i, polishes, inMatch, numSeqs);
111
112 // Merge, until no more input is left. Each round we scan the list of loaded polishes[] and
113 // remember the lowest, which is then output and a new polish is loaded in its place.
114 //
115 bool keepGoing = true;
116 while (keepGoing) {
117
118 uint32cxx . . $ uint32# first = 0;
119 while ((polishes[first] == 0L) && (first < numIn))
120 first++;
121
122 if (polishes[first] == 0L) {
123 keepGoing = 0L;
124 continue;
125 }
126
127 for (uint32cxx . . $ uint32# i=first+1; i<numIn; i++)
128 if ((polishes[i]) &&
129 (s4p_genIDcomparecxx . . $ s4p_genIDcompare(9148c8c3ff42c9d8).(polishes + first, polishes + i) > 0))
130 first = i;
131
132 otMatch->writeAlignmentcxx . . $ sim4polishWriter#writeAlignment(e4476af38b2ba703).(polishes[first]);
133
134 loadNextcxx . . $ loadNext(54d4dd26c7c07731).(first, polishes, inMatch, numSeqs);
135 }
136
137 delete [] polishes;
138
139 delete inMatch;
140 delete otMatch;
141 }
142
143
144