Debian Codegraph @

atac-driver/alignOverlap/overlap-process.C

raw
1 // This file is part of A2Amapper.
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 "overlap.H"
20
21 // I really wanted this to be parameterized with two macros, but the
22 // preprocessor merges, then replaces:
23 // #define INDEXA 1
24 // #define INDEXB 2
25 // #define NODE node ## INDEXA
26 // results in 'nodeINDEXA' not 'node1'
27
28 void
29 NAME(FILE *outfile,
30 spanTree *S,
31 atacMatchList *M1,
32 atacMatchList *M2,
33 overlapStats &stats,
34 annoList *AL,
35 uint32 &ALlen,
36 uint32 &ALmax) {
37
38 dnode_t *node = dict_first(S->_tree);
39
40 while (node) {
41 span_t *span = (span_t *)dnode_getkey(node);
42 uint32 spanLen = span->_end - span->_beg;
43
44 if (span->_matchesLen == 0) {
45 stats.unmapped += spanLen;
46 printAnno(outfile, AL, ALlen, 'U', INDEX, span);
47 } else if (span->_matchesLen == 1) {
48 uint32 match = span->_matches[0];
49 atacMatch *m;
50
51 if (match >> COLORSHIFT) {
52 m = M2->getMatch(match & COLORMASK);
53 stats.map2unique += spanLen;
54 } else {
55 m = M1->getMatch(match & COLORMASK);
56 stats.map1unique += spanLen;
57 }
58
59 printAnno(outfile, AL, ALlen, '1', INDEX, span, match, m);
60 } else if ((span->_matchesLen == 2) &&
61 ((span->_matches[0] >> COLORSHIFT) == (span->_matches[1] >> COLORSHIFT))) {
62 stats.inconsistent += spanLen;
63 printAnno(outfile, AL, ALlen, '?', INDEX, span);
64 } else if (span->_matchesLen == 2) {
65 uint32 match1 = span->_matches[0];
66 uint32 match2 = span->_matches[1];
67
68 if (match1 >> COLORSHIFT) {
69 match1 = span->_matches[1];
70 match2 = span->_matches[0];
71 }
72
73 atacMatch *m1 = M1->getMatch(match1 & COLORMASK);
74 atacMatch *m2 = M2->getMatch(match2 & COLORMASK);
75
76 if (m1->iid2 == m2->iid2) {
77 uint32 off1 = span->_beg - m1->POS1;
78 uint32 pos1l = m1->POS2 + off1;
79 uint32 pos1r = m1->POS2 + m1->LEN2 - off1;
80
81 uint32 off2 = span->_beg - m2->POS1;
82 uint32 pos2l = m2->POS2 + off2;
83 uint32 pos2r = m2->POS2 + m2->LEN2 - off2;
84
85 if ((pos1l == pos2l) || (pos1r == pos2r)) {
86 stats.same += spanLen;
87 printAnno(outfile, AL, ALlen, 'Y', INDEX, span, match1, m1, match2, m2);
88 } else {
89 stats.different += spanLen;
90 printAnno(outfile, AL, ALlen, 'N', INDEX, span, match1, m1, match2, m2);
91 }
92 } else {
93 // Wildly different matches! Mapped to different scaffolds!
94 stats.wilddiff += spanLen;
95 printAnno(outfile, AL, ALlen, '!', INDEX, span, match1, m1, match2, m2);
96 }
97 } else {
98 stats.inconsistent += spanLen;
99 printAnno(outfile, AL, ALlen, '?', INDEX, span);
100 }
101
102 node = dict_next(S->_tree, node);
103 }
104 }
105