Debian Codegraph @

sim4dbutils/s4p_overlap.C

raw
1 #include "util++.H"
2 #include "sim4.H"
3
4 // Build an interval list with all exons (from both guys), merge
5 // overlapping regions, compute the length, subtract from the total.
6 // Result: the number of bp that the two matches overlap in the
7 // genomic.
8 //
9 uint32
10 findOverlap(sim4polish *A, sim4polish *B) {
11
12 if ((A->_genID != B->_genID) || (A->_matchOrientation != B->_matchOrientation))
13 return(0);
14
15 uint32 length = 0;
16 uint32 total = 0;
17 intervalList<uint64> IL;
18
19 for (uint32 i=0; i<A->_numExons; i++) {
20 length = A->_exons[i]._genTo - A->_exons[i]._genFrom + 1;
21 total += length;
22 IL.add(A->_exons[i]._genFrom, length);
23 }
24
25 for (uint32 i=0; i<B->_numExons; i++) {
26 length = B->_exons[i]._genTo - B->_exons[i]._genFrom + 1;
27 total += length;
28 IL.add(B->_exons[i]._genFrom, length);
29 }
30
31 IL.merge();
32
33 #ifdef OLAP_IS_SHORT
34 if (total - IL.sumOfLengths() > 65536) {
35 fprintf(stderr, "findOverlap()-- ERROR! The overlap is larger than the return type!\n");
36 fprintf(stderr, "findOverlap()-- Switch to 32-bit ints in s4p_overlap.H.\n");
37 }
38 #endif
39
40 return(total - IL.sumOfLengths());
41 }