1 | // ----------------------------------------------------------------------------- |
---|
2 | // Include-Dateien |
---|
3 | // ----------------------------------------------------------------------------- |
---|
4 | |
---|
5 | #include <string.h> |
---|
6 | #include <fstream.h> |
---|
7 | |
---|
8 | #include "a3_ali.hxx" |
---|
9 | |
---|
10 | // ----------------------------------------------------------------------------- |
---|
11 | int psolcmp ( const void *a, |
---|
12 | const void *b ) |
---|
13 | // ----------------------------------------------------------------------------- |
---|
14 | { |
---|
15 | int res = 0, |
---|
16 | diff = (*(PSolution**)a)->score - (*(PSolution**)b)->score; |
---|
17 | |
---|
18 | if (diff < 0) res = -1; |
---|
19 | else if (diff > 0) res = 1; |
---|
20 | |
---|
21 | return res; |
---|
22 | } |
---|
23 | |
---|
24 | // ----------------------------------------------------------------------------- |
---|
25 | void psoldump ( vp val ) |
---|
26 | // ----------------------------------------------------------------------------- |
---|
27 | { |
---|
28 | PSolution *psol = (PSolution*)val; |
---|
29 | |
---|
30 | if (psol) |
---|
31 | { |
---|
32 | cout << psol->score << "\n"; |
---|
33 | |
---|
34 | psol->match.Dump(hmatchdump); |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | // ----------------------------------------------------------------------------- |
---|
39 | void PSolution::Dump ( void ) |
---|
40 | // ----------------------------------------------------------------------------- |
---|
41 | { |
---|
42 | psoldump((vp)this); |
---|
43 | } |
---|
44 | |
---|
45 | // ----------------------------------------------------------------------------- |
---|
46 | Aligner::Aligner ( void ) : postree(), prealigned(), helix() |
---|
47 | // ----------------------------------------------------------------------------- |
---|
48 | { |
---|
49 | prealigned.Sort(intcmp); |
---|
50 | } |
---|
51 | |
---|
52 | // ----------------------------------------------------------------------------- |
---|
53 | Aligner::Aligner ( str seq, |
---|
54 | str hel, |
---|
55 | str kon, |
---|
56 | DArray &pre ) : postree(seq), |
---|
57 | prealigned(pre), |
---|
58 | helix(hel,kon, |
---|
59 | ((PSolution*)pre[pre.Elements() - 1])->match) |
---|
60 | // ----------------------------------------------------------------------------- |
---|
61 | { |
---|
62 | } |
---|
63 | |
---|
64 | // ----------------------------------------------------------------------------- |
---|
65 | void Aligner::Set ( str seq, |
---|
66 | str hel, |
---|
67 | str kon, |
---|
68 | DArray &pre ) |
---|
69 | // ----------------------------------------------------------------------------- |
---|
70 | { |
---|
71 | postree.Set(seq); |
---|
72 | |
---|
73 | prealigned.Clear(); |
---|
74 | prealigned = pre; |
---|
75 | } |
---|
76 | |
---|
77 | // ----------------------------------------------------------------------------- |
---|
78 | DArray &Aligner::Align ( void ) |
---|
79 | // ----------------------------------------------------------------------------- |
---|
80 | { |
---|
81 | DArray *array = new DArray; |
---|
82 | int anz = prealigned.Elements(); |
---|
83 | |
---|
84 | helix.Set(((PSolution*)prealigned[anz - 1])->match); |
---|
85 | |
---|
86 | { |
---|
87 | DArray &tmp = helix.Helices(1,10); |
---|
88 | |
---|
89 | delete &tmp; |
---|
90 | } |
---|
91 | |
---|
92 | return *array; |
---|
93 | } |
---|
94 | |
---|
95 | // ----------------------------------------------------------------------------- |
---|
96 | void Aligner::Dump ( void ) |
---|
97 | // ----------------------------------------------------------------------------- |
---|
98 | { |
---|
99 | postree.Show(2); |
---|
100 | prealigned.Dump(psoldump); |
---|
101 | helix.Dump(1); |
---|
102 | } |
---|