Debian Codegraph @

seatac/heavychains.C

raw symbols SCIP
1 // This file is part of A2Amapper.cxx . . $ `<file>/seatac/heavychains.C`/
2 // Copyright (c) 2004 Applera Corporation
3 // Copyright (c) 2005 The J. Craig Venter Institute
4 // Author: Clark Mobarry
5 // Author: Brian Walenz
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received (LICENSE.txt) a copy of the GNU General Public
18 // License along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 #include <errno.h>
22 #include "heavychains.H"cxx . . $ `<file>/seatac/heavychains.H`/
23
24
25
26 // The following would need to parameterized for a general kD tree.
27 // Could we use one function with a static variable to remember the
28 // sorting direction?
29 //
30 int x_comparcxx . . $ x_compar(9148c8c3ff42c9d8).(const void *x,const void *y) {
31 const Matchcxx . . $ Match# &p1=*((const Matchcxx . . $ Match#*)x);
32 const Matchcxx . . $ Match# &p2=*((const Matchcxx . . $ Match#*)y);
33 if (p1.xhicxx . . $ Match#xhi. < p2.xhicxx . . $ Match#xhi.) return -1;
34 if (p1.xhicxx . . $ Match#xhi. > p2.xhicxx . . $ Match#xhi.) return 1;
35 return 0;
36 }
37
38 int y_comparcxx . . $ y_compar(9148c8c3ff42c9d8).(const void *x,const void *y) {
39 const Matchcxx . . $ Match# &p1=*((const Matchcxx . . $ Match#*)x);
40 const Matchcxx . . $ Match# &p2=*((const Matchcxx . . $ Match#*)y);
41 if (p1.yhicxx . . $ Match#yhi. < p2.yhicxx . . $ Match#yhi.) return -1;
42 if (p1.yhicxx . . $ Match#yhi. > p2.yhicxx . . $ Match#yhi.) return 1;
43 return 0;
44 }
45
46
47
48 void StrandPaircxx . . $ StrandPair#::addHitcxx . . $ StrandPair#addHit(a209694d0a1a92e0).(char direction,
49 uint32cxx . . $ uint32# id1,
50 uint32cxx . . $ uint32# xlo,
51 uint32cxx . . $ uint32# xln,
52 uint32cxx . . $ uint32# id2,
53 uint32cxx . . $ uint32# ylo,
54 uint32cxx . . $ uint32# yln,
55 uint32cxx . . $ uint32# filled) {
56 Matchcxx . . $ Match# tmp;
57
58 tmp.xlocxx . . $ Match#xlo. = xlo;
59 tmp.ylocxx . . $ Match#ylo. = ylo;
60
61 tmp.xhicxx . . $ Match#xhi. = xlo + xln;
62 tmp.yhicxx . . $ Match#yhi. = ylo + yln;
63
64 // Use the match lengths to initialize the self scores.
65 tmp.selfScxx . . $ Match#selfS. = xln;
66 if (yln < xln)
67 tmp.selfScxx . . $ Match#selfS. = yln;
68
69 tmp.Scxx . . $ Match#S. = 0.0;
70 tmp.neScxx . . $ Match#neS. = 0;
71 tmp.nwScxx . . $ Match#nwS. = 0;
72 tmp.seScxx . . $ Match#seS. = 0;
73 tmp.swScxx . . $ Match#swS. = 0;
74
75 tmp.filledcxx . . $ Match#filled. = filled;
76 tmp.oricxx . . $ Match#ori. = direction;
77
78 iid1cxx . . $ StrandPair#iid1. = id1;
79 iid2cxx . . $ StrandPair#iid2. = id2;
80
81 if (beVerbosecxx . . $ StrandPair#beVerbose. > 1)
82 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "heavychains: add %8d %8d %8d -- %8d %8d %8d\n", id1, tmp.xlocxx . . $ Match#xlo., tmp.xhicxx . . $ Match#xhi., id2, tmp.ylocxx . . $ Match#ylo., tmp.yhicxx . . $ Match#yhi.);
83
84 Paddcxx . . $ StrandPair#Padd(d067a0977a49f5a6).(&tmp);
85 }
86
87
88
89 // new strand pair: begin processing data for the strand pair
90 //
91 void StrandPaircxx . . $ StrandPair#::processcxx . . $ StrandPair#process(49f6e7a06ebc5aa8).(void) {
92 int swapi;
93
94 if (Plencxx . . $ StrandPair#Plen. > 0) {
95 if (beVerbosecxx . . $ StrandPair#beVerbose. > 0)
96 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"HeavyChains: filtering strands "uint32FMTcxx . . $ `libutil/util.h:65:10`!" "uint32FMTcxx . . $ `libutil/util.h:65:10`!" "uint32FMTcxx . . $ `libutil/util.h:65:10`!"\n", iid1cxx . . $ StrandPair#iid1., iid2cxx . . $ StrandPair#iid2., Plencxx . . $ StrandPair#Plen.);
97
98 DPTreecxx . . $ DPTree# *dp = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
99 dp = new DPTreecxx . . $ DPTree#(Plencxx . . $ StrandPair#Plen., Pcxx . . $ StrandPair#P.);
100 dp->setParamscxx . . $ DPTree#setParams(d4f767463ce0a6b3).(maxJumpcxx . . $ StrandPair#maxJump.);
101
102 for(int quadrant=0; quadrant < 4; ++quadrant) {
103 if (beVerbosecxx . . $ StrandPair#beVerbose. > 1)
104 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"HeavyChains: arranging process quadrant %d\n", quadrant);
105
106 if ((quadrant == 0) || (quadrant == 2)) {
107 for (int i=0; i<Plencxx . . $ StrandPair#Plen.; ++i) {
108 swapi = -Pcxx . . $ StrandPair#P.[i].xlocxx . . $ Match#xlo.;
109 Pcxx . . $ StrandPair#P.[i].xlocxx . . $ Match#xlo. = -Pcxx . . $ StrandPair#P.[i].xhicxx . . $ Match#xhi.;
110 Pcxx . . $ StrandPair#P.[i].xhicxx . . $ Match#xhi. = swapi;
111 }
112 } else {
113 for (int i=0; i<Plencxx . . $ StrandPair#Plen.; ++i) {
114 swapi = -Pcxx . . $ StrandPair#P.[i].ylocxx . . $ Match#ylo.;
115 Pcxx . . $ StrandPair#P.[i].ylocxx . . $ Match#ylo. = -Pcxx . . $ StrandPair#P.[i].yhicxx . . $ Match#yhi.;
116 Pcxx . . $ StrandPair#P.[i].yhicxx . . $ Match#yhi. = swapi;
117 }
118 }
119
120 if (beVerbosecxx . . $ StrandPair#beVerbose. > 1)
121 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"HeavyChains: scoring quadrant\n");
122
123 dp->treeScorecxx . . $ DPTree#treeScore(31fa7155c10fdd13).();
124
125 if (beVerbosecxx . . $ StrandPair#beVerbose.>1)
126 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"HeavyChains: recording scores\n");
127
128 switch(quadrant) {
129 case 0: for (int i=0; i < Plencxx . . $ StrandPair#Plen.; ++i) Pcxx . . $ StrandPair#P.[i].nwScxx . . $ Match#nwS. = Pcxx . . $ StrandPair#P.[i].Scxx . . $ Match#S.; break;
130 case 1: for (int i=0; i < Plencxx . . $ StrandPair#Plen.; ++i) Pcxx . . $ StrandPair#P.[i].swScxx . . $ Match#swS. = Pcxx . . $ StrandPair#P.[i].Scxx . . $ Match#S.; break;
131 case 2: for (int i=0; i < Plencxx . . $ StrandPair#Plen.; ++i) Pcxx . . $ StrandPair#P.[i].seScxx . . $ Match#seS. = Pcxx . . $ StrandPair#P.[i].Scxx . . $ Match#S.; break;
132 case 3: for (int i=0; i < Plencxx . . $ StrandPair#Plen.; ++i) Pcxx . . $ StrandPair#P.[i].neScxx . . $ Match#neS. = Pcxx . . $ StrandPair#P.[i].Scxx . . $ Match#S.; break;
133 }
134
135 if (beVerbosecxx . . $ StrandPair#beVerbose. > 1)
136 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,"HeavyChains: done quadrant\n");
137 }
138
139 // All output information is now in the match records of P.
140 delete dp;
141 }
142 }
143
144
145
146 uint64cxx . . $ uint64#
147 StrandPaircxx . . $ StrandPair#::printcxx . . $ StrandPair#print(9bd1d5b934681de1).(FILE *outF,
148 uint64cxx . . $ uint64# matchid) {
149
150 for (int i=0; i<Plencxx . . $ StrandPair#Plen.; ++i) {
151
152 // symmetrize the forward and backward scores
153 double inc = Pcxx . . $ StrandPair#P.[i].neScxx . . $ Match#neS. + Pcxx . . $ StrandPair#P.[i].swScxx . . $ Match#swS. - Pcxx . . $ StrandPair#P.[i].selfScxx . . $ Match#selfS.; // forward complement orientations
154 double dec = Pcxx . . $ StrandPair#P.[i].seScxx . . $ Match#seS. + Pcxx . . $ StrandPair#P.[i].nwScxx . . $ Match#nwS. - Pcxx . . $ StrandPair#P.[i].selfScxx . . $ Match#selfS.; // reverse complement orientations
155
156 // Each score already contains the self score
157
158 if ((inc >= minScorecxx . . $ StrandPair#minScore.) || (dec >= minScorecxx . . $ StrandPair#minScore.)) {
159 int len1 = (Pcxx . . $ StrandPair#P.[i].xhicxx . . $ Match#xhi.-Pcxx . . $ StrandPair#P.[i].xlocxx . . $ Match#xlo.);
160 int len2 = (Pcxx . . $ StrandPair#P.[i].yhicxx . . $ Match#yhi.-Pcxx . . $ StrandPair#P.[i].ylocxx . . $ Match#ylo.);
161 matchid++;
162
163 if (beVerbosecxx . . $ StrandPair#beVerbose. > 1)
164 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "heavychains: out "uint32FMTWcxx . . $ `libutil/util.h:64:10`!(8)" %8d %8d -- "uint32FMTWcxx . . $ `libutil/util.h:64:10`!(8)" %8d %8d\n",
165 iid1cxx . . $ StrandPair#iid1., Pcxx . . $ StrandPair#P.[i].xlocxx . . $ Match#xlo., Pcxx . . $ StrandPair#P.[i].xhicxx . . $ Match#xhi.,
166 iid2cxx . . $ StrandPair#iid2., Pcxx . . $ StrandPair#P.[i].ylocxx . . $ Match#ylo., Pcxx . . $ StrandPair#P.[i].yhicxx . . $ Match#yhi.);
167
168 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
169 fprintf(outF, "M x H"uint64FMTcxx . . $ `libutil/util.h:55:10`!" . %s:"uint32FMTcxx . . $ `libutil/util.h:65:10`!" %d %d %d %s:"uint32FMTcxx . . $ `libutil/util.h:65:10`!" %d %d %d > /hf=%.1f /hr=%.1f\n",
170 matchid,
171 assemblyId1cxx . . $ StrandPair#assemblyId1., iid1cxx . . $ StrandPair#iid1., Pcxx . . $ StrandPair#P.[i].xlocxx . . $ Match#xlo., len1, 1,
172 assemblyId2cxx . . $ StrandPair#assemblyId2., iid2cxx . . $ StrandPair#iid2., Pcxx . . $ StrandPair#P.[i].ylocxx . . $ Match#ylo., len2, (Pcxx . . $ StrandPair#P.[i].oricxx . . $ Match#ori. == 'f'? 1 : -1),
173 inc, dec);
174 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)
175 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "StrandPair::print()-- write failed: %s\n", strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
176
177 sumlen1cxx . . $ StrandPair#sumlen1. += len1;
178 sumlen2cxx . . $ StrandPair#sumlen2. += len2;
179 maxlen1cxx . . $ StrandPair#maxlen1. = (maxlen1cxx . . $ StrandPair#maxlen1. > len1) ? maxlen1cxx . . $ StrandPair#maxlen1. : len1;
180 maxlen2cxx . . $ StrandPair#maxlen2. = (maxlen2cxx . . $ StrandPair#maxlen2. > len2) ? maxlen2cxx . . $ StrandPair#maxlen2. : len2;
181 maxScoreFwdcxx . . $ StrandPair#maxScoreFwd. = (maxScoreFwdcxx . . $ StrandPair#maxScoreFwd. > inc) ? maxScoreFwdcxx . . $ StrandPair#maxScoreFwd. : inc;
182 maxScoreRevcxx . . $ StrandPair#maxScoreRev. = (maxScoreRevcxx . . $ StrandPair#maxScoreRev. > dec) ? maxScoreRevcxx . . $ StrandPair#maxScoreRev. : dec;
183 }
184
185 if (beVerbosecxx . . $ StrandPair#beVerbose. > 0)
186 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "HeavyChains: finished strands "uint32FMTWcxx . . $ `libutil/util.h:64:10`!(8)" "uint32FMTWcxx . . $ `libutil/util.h:64:10`!(8)" maxlen1=%f maxlen2=%f maxScoreFwd=%f maxScoreRef=%f\n",
187 iid1cxx . . $ StrandPair#iid1., iid2cxx . . $ StrandPair#iid2., maxlen1cxx . . $ StrandPair#maxlen1., maxlen2cxx . . $ StrandPair#maxlen2., maxScoreFwdcxx . . $ StrandPair#maxScoreFwd., maxScoreRevcxx . . $ StrandPair#maxScoreRev.);
188 }
189
190 return(matchid);
191 }