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.datamodel.SequenceI; |
24 |
|
import jalview.gui.Desktop; |
25 |
|
import jalview.gui.JvOptionPane; |
26 |
|
import jalview.viewmodel.AlignmentViewport; |
27 |
|
|
28 |
|
import java.util.Hashtable; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 7 |
Complexity Density: 0.32 |
|
34 |
|
public class Connectivity |
35 |
|
{ |
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
36 |
0 |
public static Hashtable<SequenceI, Integer> getConnectivityForAlignmentView(... |
37 |
|
AlignmentViewport av, float[][] scores, byte dim) |
38 |
|
{ |
39 |
0 |
boolean isSelection = av.getSelectionGroup() != null |
40 |
|
&& av.getSelectionGroup().getSize() > 0; |
41 |
0 |
SequenceI[] sequences; |
42 |
0 |
if (isSelection) |
43 |
|
{ |
44 |
0 |
sequences = (SequenceI[]) av.getAlignmentView(isSelection) |
45 |
|
.getAlignmentAndHiddenColumns(av.getGapCharacter())[0]; |
46 |
|
} |
47 |
|
else |
48 |
|
{ |
49 |
0 |
sequences = av.getAlignment().getSequencesArray(); |
50 |
|
} |
51 |
|
|
52 |
0 |
return Connectivity.getConnectivity(sequences, scores, dim); |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
@param |
60 |
|
|
61 |
|
@param |
62 |
|
|
63 |
|
|
64 |
|
@return |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 5 |
Complexity Density: 0.31 |
|
66 |
0 |
public static Hashtable<SequenceI, Integer> getConnectivity(... |
67 |
|
SequenceI[] sequences, float[][] scores, byte dim) |
68 |
|
throws RuntimeException |
69 |
|
{ |
70 |
0 |
Hashtable<SequenceI, Integer> connectivity = new Hashtable<SequenceI, Integer>(); |
71 |
|
|
72 |
0 |
for (int i = 0; i < sequences.length; i++) |
73 |
|
{ |
74 |
0 |
connectivity.putIfAbsent(sequences[i], 0); |
75 |
0 |
for (int j = 0; j < i; j++) |
76 |
|
{ |
77 |
0 |
connectivity.putIfAbsent(sequences[j], 0); |
78 |
0 |
int iOld = connectivity.get(sequences[i]); |
79 |
0 |
int jOld = connectivity.get(sequences[j]); |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
0 |
if (!Float.isNaN(scores[i][j])) |
84 |
|
{ |
85 |
0 |
connectivity.put(sequences[i], ++iOld); |
86 |
0 |
connectivity.put(sequences[j], ++jOld); |
87 |
|
} |
88 |
|
} |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
0 |
connectivity.forEach((sequence, connection) -> { |
93 |
0 |
System.out.println( |
94 |
|
String.format("%s: %d", sequence.getName(), connection)); |
95 |
0 |
if (connection < dim) |
96 |
|
{ |
97 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.desktop, |
98 |
|
String.format( |
99 |
|
"Insufficient number of connections for %s (%d, should be %d or more)", |
100 |
|
sequence.getName(), connection, dim), |
101 |
|
"Connectivity Error", JvOptionPane.WARNING_MESSAGE); |
102 |
0 |
throw new ConnectivityException(sequence.getName(), connection, |
103 |
|
dim); |
104 |
|
} |
105 |
|
}); |
106 |
|
|
107 |
0 |
return connectivity; |
108 |
|
} |
109 |
|
|
110 |
|
} |