1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.analysis; |
22 |
|
|
23 |
|
import jalview.api.analysis.ScoreModelI; |
24 |
|
import jalview.api.analysis.SimilarityParamsI; |
25 |
|
import jalview.datamodel.BinaryNode; |
26 |
|
import jalview.viewmodel.AlignmentViewport; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
|
|
| 0% |
Uncovered Elements: 54 (54) |
Complexity: 15 |
Complexity Density: 0.47 |
|
32 |
|
public class AverageDistanceTree extends TreeBuilder |
33 |
|
{ |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@param |
38 |
|
@param |
39 |
|
@param |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
41 |
0 |
public AverageDistanceTree(AlignmentViewport av, ScoreModelI sm,... |
42 |
|
SimilarityParamsI scoreParameters) |
43 |
|
{ |
44 |
0 |
super(av, sm, scoreParameters); |
45 |
|
} |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@param |
54 |
|
@param |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
56 |
0 |
@Override... |
57 |
|
protected void findClusterDistance(int i, int j) |
58 |
|
{ |
59 |
0 |
int noi = clusters.elementAt(i).cardinality(); |
60 |
0 |
int noj = clusters.elementAt(j).cardinality(); |
61 |
|
|
62 |
|
|
63 |
0 |
double[] newdist = new double[noseqs]; |
64 |
|
|
65 |
0 |
for (int l = 0; l < noseqs; l++) |
66 |
|
{ |
67 |
0 |
if ((l != i) && (l != j)) |
68 |
|
{ |
69 |
0 |
newdist[l] = ((distances.getValue(i, l) * noi) |
70 |
|
+ (distances.getValue(j, l) * noj)) / (noi + noj); |
71 |
|
} |
72 |
|
else |
73 |
|
{ |
74 |
0 |
newdist[l] = 0; |
75 |
|
} |
76 |
|
} |
77 |
|
|
78 |
0 |
for (int ii = 0; ii < noseqs; ii++) |
79 |
|
{ |
80 |
0 |
distances.setValue(i, ii, newdist[ii]); |
81 |
0 |
distances.setValue(ii, i, newdist[ii]); |
82 |
|
} |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
|
@inheritDoc |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.67 |
|
88 |
0 |
@Override... |
89 |
|
protected double findMinDistance() |
90 |
|
{ |
91 |
0 |
double min = Double.MAX_VALUE; |
92 |
|
|
93 |
0 |
for (int i = 0; i < (noseqs - 1); i++) |
94 |
|
{ |
95 |
0 |
for (int j = i + 1; j < noseqs; j++) |
96 |
|
{ |
97 |
0 |
if (!done.get(i) && !done.get(j)) |
98 |
|
{ |
99 |
0 |
if (distances.getValue(i, j) < min) |
100 |
|
{ |
101 |
0 |
mini = i; |
102 |
0 |
minj = j; |
103 |
|
|
104 |
0 |
min = distances.getValue(i, j); |
105 |
|
} |
106 |
|
} |
107 |
|
} |
108 |
|
} |
109 |
0 |
return min; |
110 |
|
} |
111 |
|
|
112 |
|
|
113 |
|
@inheritDoc |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.25 |
|
115 |
0 |
@Override... |
116 |
|
protected void findNewDistances(BinaryNode nodei, BinaryNode nodej, |
117 |
|
double dist) |
118 |
|
{ |
119 |
0 |
double ih = 0; |
120 |
0 |
double jh = 0; |
121 |
|
|
122 |
0 |
BinaryNode sni = nodei; |
123 |
0 |
BinaryNode snj = nodej; |
124 |
|
|
125 |
0 |
while (sni != null) |
126 |
|
{ |
127 |
0 |
ih = ih + sni.dist; |
128 |
0 |
sni = (BinaryNode) sni.left(); |
129 |
|
} |
130 |
|
|
131 |
0 |
while (snj != null) |
132 |
|
{ |
133 |
0 |
jh = jh + snj.dist; |
134 |
0 |
snj = (BinaryNode) snj.left(); |
135 |
|
} |
136 |
|
|
137 |
0 |
nodei.dist = ((dist / 2) - ih); |
138 |
0 |
nodej.dist = ((dist / 2) - jh); |
139 |
|
} |
140 |
|
|
141 |
|
} |