Debian Codegraph @

atac-driver/chainer/localalign/localAlignerInterfacemodule.C

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 // This file is part of A2Amapper.cxx . . $ `<file>/atac-driver/chainer/localalign/localAlignerInterfacemodule.C`/
2 // Copyright (c) 2004 Applera Corporation
3 // Author: Clark Mobarry
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 <stdlib.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include <assert.h>
23
24 #include <Python.h>
25
26 #include "GF_ALN_local.H"cxx . . $ `<file>/atac-driver/chainer/localalign/GF_ALN_local.H`/
27
28 static Local_Overlapcxx . . $ Local_Overlap# *desccxx . . $ desc. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
29
30
31 // This should be in the "library" not in the client. Sigh.
32
33 void
34 syntenicSegmentscxx . . $ syntenicSegments(4eee9581e5f2cca5).(char const * const Aseq, int const Astart, int const Astop,
35 char const * const Bseq, int const Bstart, int const Bstop,
36 double const erate) {
37
38 desccxx . . $ desc. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; // In case an early exit happens!
39
40 // Key data types ("Local_Segment" and "Local_Overlap") are defined
41 // in "CA_ALN_local.H"
42
43 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(Astop >= Astart);
44 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(Bstop >= Bstart);
45
46 // Step 1: get local segments:
47 char const * const Ausable = Aseq + Astart;
48 char const * const Busable = Bseq + Bstart;
49
50 int const alen = Astop - Astart;
51 int const blen = Bstop - Bstart;
52
53 int NumSegs = 0; /* number of local matches returned */
54
55 Local_Segmentcxx . . $ Local_Segment# *local_results = Find_Local_Segmentscxx . . $ Find_Local_Segments(37817bc7f7be279f).(Ausable, /* sequence A */
56 alen,
57 Busable,
58 blen,
59 LOCAL_FORWcxx . . $ `atac-driver/chainer/localalign/GF_ALN_local.H:86:9`!, /* whether to compute a forward search , reverse, or both */
60 16, /* minimum length of a reportable match */
61 erate, /* maximum error for a match to be returned */
62 &NumSegs); /* number of local matches returned */
63
64 if(NumSegs==0)
65 return;
66
67 // Step 2: get a chain of local segments:
68
69 Local_Overlapcxx . . $ Local_Overlap# *Ov = Find_Local_Overlapcxx . . $ Find_Local_Overlap(fddbc6197bc940a1).(alen, /* length of sequence A */
70 blen, /* length of sequence B */
71 0, /* comp==0 -> fwd orientation */
72 0, /* nextbest==0 -> find best overlap*/
73 local_results, /* the input set of local segments */
74 NumSegs, /* number of input local segments */
75 20 - 6, /* shortest "overlap" to report" */
76 1.0); /* fraction of overlap not in a match -- needs to be large to allow substantial mismatches */
77
78 if(Ov == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
79 return;
80
81 // Step 3 (optional):
82 //
83 // NOT optional! AS_Local_Trace seems to have been extended to
84 // clean up segments.
85 //
86 // a) fix the chain of segments so that the segments don't overlap.
87 // It must be a 1-1 mapping. (can either trim or delete segments--or
88 // leave them completely alone)
89 //
90 // b) construct an alignment "trace"
91 //
92 // The "trace" is the standard "AS" encoding of an alignment.
93
94 // coordinate munge between Gene's local aligner and
95 // DP_Compare()-related routines coordinates from Find_Local
96 // routines will be one off from those expected by the trace
97 // routines, so adjust them!
98
99 for(int i=0;i<=Ov->num_piecescxx . . $ $anonymous_type_48ac8bda34bc2e3_2#num_pieces.;i++){
100 if(i<Ov->num_piecescxx . . $ $anonymous_type_48ac8bda34bc2e3_2#num_pieces.){
101 Ov->chaincxx . . $ $anonymous_type_48ac8bda34bc2e3_2#chain.[i].piececxx . . $ $anonymous_type_48ac8bda34bc2e3_1#piece..abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.++;
102 Ov->chaincxx . . $ $anonymous_type_48ac8bda34bc2e3_2#chain.[i].piececxx . . $ $anonymous_type_48ac8bda34bc2e3_1#piece..bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.++;
103 Ov->chaincxx . . $ $anonymous_type_48ac8bda34bc2e3_2#chain.[i].piececxx . . $ $anonymous_type_48ac8bda34bc2e3_1#piece..aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos.++;
104 Ov->chaincxx . . $ $anonymous_type_48ac8bda34bc2e3_2#chain.[i].piececxx . . $ $anonymous_type_48ac8bda34bc2e3_1#piece..beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.++;
105 }
106 }
107
108 // AS_Local_Trace assumes string pointer one before start of string!
109 //
110 // The original used to complain if no trace was returned, but we
111 // don't care...and, in fact, we disabled trace generation anyway!
112 //
113 AS_Local_Tracecxx . . $ AS_Local_Trace(75136a09a3587559).(Ov, Ausable - 1, Busable - 1);
114
115 for(int i=0;i<=Ov->num_piecescxx . . $ $anonymous_type_48ac8bda34bc2e3_2#num_pieces.;i++){
116 if(i<Ov->num_piecescxx . . $ $anonymous_type_48ac8bda34bc2e3_2#num_pieces.){
117 Ov->chaincxx . . $ $anonymous_type_48ac8bda34bc2e3_2#chain.[i].piececxx . . $ $anonymous_type_48ac8bda34bc2e3_1#piece..abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.--;
118 Ov->chaincxx . . $ $anonymous_type_48ac8bda34bc2e3_2#chain.[i].piececxx . . $ $anonymous_type_48ac8bda34bc2e3_1#piece..bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.--;
119 Ov->chaincxx . . $ $anonymous_type_48ac8bda34bc2e3_2#chain.[i].piececxx . . $ $anonymous_type_48ac8bda34bc2e3_1#piece..aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos.--;
120 Ov->chaincxx . . $ $anonymous_type_48ac8bda34bc2e3_2#chain.[i].piececxx . . $ $anonymous_type_48ac8bda34bc2e3_1#piece..beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos.--;
121 }
122 }
123
124 Ov->nextcxx . . $ $anonymous_type_48ac8bda34bc2e3_2#next. = 0;
125
126 desccxx . . $ desc. = Ov;
127 }
128
129
130
131
132 int iterate_Local_Overlapcxx . . $ iterate_Local_Overlap(693a9a68a9d27e7).(int &seg_abpos, int &seg_bbpos,
133 int &seg_alen, int &seg_blen,
134 double &seg_error) {
135
136 if (desccxx . . $ desc. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
137 return(0);
138
139 Local_Chaincxx . . $ Local_Chain# *chain = desccxx . . $ desc.->chaincxx . . $ $anonymous_type_48ac8bda34bc2e3_2#chain.;
140
141 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! != desc->chain);
142
143 for(; 0 <= desccxx . . $ desc.->nextcxx . . $ $anonymous_type_48ac8bda34bc2e3_2#next. && desccxx . . $ desc.->nextcxx . . $ $anonymous_type_48ac8bda34bc2e3_2#next. < desccxx . . $ desc.->num_piecescxx . . $ $anonymous_type_48ac8bda34bc2e3_2#num_pieces.; ) {
144 int the_piece = (desccxx . . $ desc.->nextcxx . . $ $anonymous_type_48ac8bda34bc2e3_2#next.)++;
145
146 Local_Segmentcxx . . $ Local_Segment# *seg = &(chain[the_piece].piececxx . . $ $anonymous_type_48ac8bda34bc2e3_1#piece.);
147
148 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! != seg);
149 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(!chain[the_piece].reversed);
150
151 // Set the return data
152
153 seg_abpos = seg->abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.;
154 seg_alen = seg->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos. - seg->abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.;
155 seg_bbpos = seg->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.;
156 seg_blen = seg->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos. - seg->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.;
157 seg_error = seg->errorcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#error.;
158
159 // Skip over the "deleted in-place" segments.
160 if((seg->aeposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#aepos. <= seg->abposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#abpos.)&&(seg->beposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bepos. <= seg->bbposcxx . . $ $anonymous_type_48ac8bda34bc2e3_0#bbpos.))
161 continue;
162
163 // the data is valid
164 return(1);
165 }
166
167 // Nothing left.
168 return(0);
169 }
170
171
172
173
174 static PyObject *
175 spam_syntenicSegmentscxx . . $ spam_syntenicSegments(134650f196314f84).(PyObject *self, PyObject *args) {
176 char *Aseq = "undefined";
177 int Astart = -1;
178 int Astop = -1; // substring of Aseq
179 char *Bseq = "undefined";
180 int Bstart = -1;
181 int Bstop = -1; // substring of Bseq
182 double erate = 1.0 / 3.0;
183
184 PyObject *py_outfile = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
185
186 if (!PyArg_ParseTuple(args, "Osiisiid", &py_outfile, &Aseq, &Astart, &Astop, &Bseq, &Bstart, &Bstop, &erate))
187 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
188
189 try {
190 syntenicSegmentscxx . . $ syntenicSegments(4eee9581e5f2cca5).(Aseq, Astart, Astop, // substring of Aseq
191 Bseq, Bstart, Bstop, // substring of Bseq
192 erate);
193 } catch (...) {
194 PyErr_SetString(PyExc_RuntimeError,"sytenicSegments failed");
195 return(Py_Nonecxx . . $ `<external>/6627276626932786099/object.h:657:11`!);
196 }
197
198 Py_INCREFcxx . . $ `<external>/7473908782214011092/refcount.h:306:11`!(Py_Nonecxx . . $ `<external>/6627276626932786099/object.h:657:11`!); // This is a module function returning void.
199 return(Py_Nonecxx . . $ `<external>/6627276626932786099/object.h:657:11`!);
200 }
201
202
203
204 static PyObject *
205 spam_iterateSegmentscxx . . $ spam_iterateSegments(134650f196314f84).(PyObject *self, PyObject *args) {
206 int seg_bgn1 = 0;
207 int seg_bgn2 = 0;
208 int seg_len1 = 0;
209 int seg_len2 = 0;
210 double seg_error = 0.0;
211
212 if (iterate_Local_Overlapcxx . . $ iterate_Local_Overlap(693a9a68a9d27e7).(seg_bgn1, seg_bgn2, seg_len1, seg_len2, seg_error))
213 return(Py_BuildValue("(iiiid)", seg_bgn1, seg_bgn2, seg_len1, seg_len2, seg_error));
214
215 Py_INCREFcxx . . $ `<external>/7473908782214011092/refcount.h:306:11`!(Py_Nonecxx . . $ `<external>/6627276626932786099/object.h:657:11`!); // This is a module function returning void.
216 return(Py_Nonecxx . . $ `<external>/6627276626932786099/object.h:657:11`!);
217 }
218
219
220
221 static
222 PyMethodDef
223 registration_tablecxx . . $ registration_table.[] = {
224 {"syntenicSegments", spam_syntenicSegmentscxx . . $ spam_syntenicSegments(134650f196314f84)., METH_VARARGScxx . . $ `<external>/903168847229296630/methodobject.h:95:9`!, "Compute syntenic segments"},
225 {"iterateSegments", spam_iterateSegmentscxx . . $ spam_iterateSegments(134650f196314f84)., METH_VARARGScxx . . $ `<external>/903168847229296630/methodobject.h:95:9`!, "Iterator returning syntenic segments"},
226 {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!}
227 };
228
229
•230 static struct PyModuleDefcxx . . $ PyModuleDef# cModMethodscxx . . $ cModMethods. =
231 {
232 PyModuleDef_HEAD_INITcxx . . $ `<external>/4056669176282104304/moduleobject.h:60:9`!,
233 "localAlignerInterface", /* name of module */
234 "", /* module documentation, may be NULL */
235 -1, /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */
236 registration_tablecxx . . $ registration_table.
237 };
238
239 extern "C"
•240 void PyInit_localAlignerInterface() {
241 PyModule_Createcxx . . $ `<external>/16057173111770042419/modsupport.h:117:9`!(&cModMethods);
242 }
243