Debian Codegraph @

seatac/hitMatrix.H

raw symbols SCIP
1 #cxx . . $ `<file>/seatac/hitMatrix.H`/ifndef HITMATRIX_H
2 #define HITMATRIX_Hcxx . . $ `seatac/hitMatrix.H:2:9`!
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <new>
7
8 #include "bio++.H"cxx . . $ `<file>/libbio/bio++.H`/
9 #include "positionDB.H"cxx . . $ `<file>/libkmer/positionDB.H`/
10 #include "filterObj.H"cxx . . $ `<file>/seatac/filterObj.H`/
11
12 // Define this to cut the space required for storing hits by 1/3 --
13 // from 12 byyes to 8 bytes -- at a slight computational expense --
14 // negligible on real hardware, I hope.
15 //
16 // The original definition of diagonalID was
17 // qsLen - qsPos - 1 + dsPos
18 // but qsLen is fixed for everyone, so we could reduce it to
19 // dsPos - qsPos
20 // but that's not unsigned.
21 //
22 // Results: on a human mapping, using chromosomes as the stream and
23 // the whole human as the table (so we need to actually store a large
24 // number of hits), we see a savings of 2GB and a small drop in
25 // runtime. Process size went from 20.7GB to 18.7GB, CPU time from
26 // 20578 to 20193 seconds (833MHz EV6.8AL (21264B)).
27 //
28 #define WITHOUT_DIAGONALIDcxx . . $ `seatac/hitMatrix.H:28:9`!
29
30
31 struct diagonalLinecxx . . $ diagonalLine# {
32 uint32cxx . . $ uint32# _qsPoscxx . . $ diagonalLine#_qsPos.;
33 uint32cxx . . $ uint32# _dsPoscxx . . $ diagonalLine#_dsPos.;
34 #ifndef WITHOUT_DIAGONALIDcxx . . $ `seatac/hitMatrix.H:28:9`!
35 uint32 _diagonalID;
36 #endif
37 };
38
39
40 class hitMatrixcxx . . $ hitMatrix# {
41 public:
42 hitMatrixcxx . . $ hitMatrix#hitMatrix(b4d55b1286ff73e8).(uint32cxx . . $ uint32# qsLen,
43 uint32cxx . . $ uint32# qsIdx);
44 ~cxx . . $ hitMatrix#`~hitMatrix`(49f6e7a06ebc5aa8).hitMatrixcxx . . $ hitMatrix#();
45
46 void addHitscxx . . $ hitMatrix#addHits(19fbb4f67f92d147).(uint32cxx . . $ uint32# qi,
47 uint64cxx . . $ uint64# *ps,
48 uint64cxx . . $ uint64# cn);
49
50 void sort_diagonalcxx . . $ hitMatrix#sort_diagonal(49f6e7a06ebc5aa8).(void);
51 void sort_dsPoscxx . . $ hitMatrix#sort_dsPos(49f6e7a06ebc5aa8).(void);
52
53 void processMatrixcxx . . $ hitMatrix#processMatrix(b2e8704fc2713a96).(char direction, filterObjcxx . . $ filterObj# *FO);
54
55 private:
56 uint32cxx . . $ uint32# _qsLencxx . . $ hitMatrix#_qsLen.; // Seq Len of Q
57 uint32cxx . . $ uint32# _qsIdxcxx . . $ hitMatrix#_qsIdx.; // Index of Q in the FastA
58
59 // Instead of building the lines during add(), we store
60 // the information used to build lines, and then build them
61 // in chain(). This was done to reduce simultaneous memory
62 // usage, as the lineArrayMap and etc take up considerable space.
63 //
64 uint32cxx . . $ uint32# _hitsLencxx . . $ hitMatrix#_hitsLen.;
65 uint32cxx . . $ uint32# _hitsMaxcxx . . $ hitMatrix#_hitsMax.;
66 diagonalLinecxx . . $ diagonalLine# *_hitscxx . . $ hitMatrix#_hits.;
67 };
68
69
70 inline
71 void
72 hitMatrixcxx . . $ hitMatrix#::addHitscxx . . $ hitMatrix#addHits(19fbb4f67f92d147).(uint32cxx . . $ uint32# qi,
73 uint64cxx . . $ uint64# *ps,
74 uint64cxx . . $ uint64# cn) {
75
76 if ((_hitsLencxx . . $ hitMatrix#_hitsLen. + cn) >= _hitsMaxcxx . . $ hitMatrix#_hitsMax.) {
77 _hitsMaxcxx . . $ hitMatrix#_hitsMax. = _hitsMaxcxx . . $ hitMatrix#_hitsMax. + _hitsMaxcxx . . $ hitMatrix#_hitsMax. + (uint32cxx . . $ uint32#)cn;
78
79 diagonalLinecxx . . $ diagonalLine# *h;
80 try {
81 h = new diagonalLinecxx . . $ diagonalLine# [_hitsMaxcxx . . $ hitMatrix#_hitsMax.];
82 } catch (stdcxx . . $ std/::bad_alloccxx . . $ std/bad_alloc#)cxx . . $ std/bad_alloc#bad_alloc(f0898f11383ce75e). {
83 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "hitMatrix::addHits()-- caught std::bad_alloc in %s at line %d.\n", __FILE__, __LINE__);
84 fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "hitMatrix::addHits()-- have "uint32FMTcxx . . $ `libutil/util.h:65:10`!" hits, tried to add "uint64FMTcxx . . $ `libutil/util.h:55:10`!" more\n", _hitsLencxx . . $ hitMatrix#_hitsLen., cn);
85 exitcxx . . $ exit(44ed87f96534fad7).(1);
86 }
87
88 for (uint32cxx . . $ uint32# z=_hitsLencxx . . $ hitMatrix#_hitsLen.; z--; ) {
89 h[z]._qsPoscxx . . $ diagonalLine#_qsPos. = _hitscxx . . $ hitMatrix#_hits.[z]._qsPoscxx . . $ diagonalLine#_qsPos.;
90 h[z]._dsPoscxx . . $ diagonalLine#_dsPos. = _hitscxx . . $ hitMatrix#_hits.[z]._dsPoscxx . . $ diagonalLine#_dsPos.;
91 #ifndef WITHOUT_DIAGONALIDcxx . . $ `seatac/hitMatrix.H:28:9`!
92 h[z]._diagonalID = _hits[z]._diagonalID;
93 #endif
94 }
95
96 delete [] _hitscxx . . $ hitMatrix#_hits.;
97
98 _hitscxx . . $ hitMatrix#_hits. = h;
99 }
100
101 for (uint64cxx . . $ uint64# i=0; i<cn; i++) {
102 _hitscxx . . $ hitMatrix#_hits.[_hitsLencxx . . $ hitMatrix#_hitsLen.]._qsPoscxx . . $ diagonalLine#_qsPos. = (uint32cxx . . $ uint32#)(qi);
103 _hitscxx . . $ hitMatrix#_hits.[_hitsLencxx . . $ hitMatrix#_hitsLen.]._dsPoscxx . . $ diagonalLine#_dsPos. = (uint32cxx . . $ uint32#)(ps[i]);
104 #ifndef WITHOUT_DIAGONALIDcxx . . $ `seatac/hitMatrix.H:28:9`!
105 _hits[_hitsLen]._diagonalID = (uint32)(_qsLen - qi - 1 + ps[i]);
106 #endif
107 _hitsLencxx . . $ hitMatrix#_hitsLen.++;
108 }
109 }
110
111
112 #endif // HITMATRIX_H