1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io; |
22 |
|
|
23 |
|
import jalview.datamodel.Alignment; |
24 |
|
import jalview.datamodel.AlignmentI; |
25 |
|
|
26 |
|
import java.io.PrintWriter; |
27 |
|
import java.io.StringWriter; |
28 |
|
import java.util.Enumeration; |
29 |
|
import java.util.Hashtable; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
|
|
| 0% |
Uncovered Elements: 76 (76) |
Complexity: 16 |
Complexity Density: 0.33 |
|
38 |
|
public class AlignmentProperties |
39 |
|
{ |
40 |
|
AlignmentI alignment; |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
0 |
public AlignmentProperties(AlignmentI alignment)... |
43 |
|
{ |
44 |
0 |
this.alignment = alignment; |
45 |
|
} |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
@param |
51 |
|
@param |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 65 (65) |
Complexity: 12 |
Complexity Density: 0.28 |
|
53 |
0 |
public void writeProperties(PrintWriter pw, boolean html)... |
54 |
|
{ |
55 |
0 |
final String nl = html ? "<br>" : System.getProperty("line.separator"); |
56 |
0 |
float avg = 0; |
57 |
0 |
int min = Integer.MAX_VALUE, max = 0; |
58 |
0 |
for (int i = 0; i < alignment.getHeight(); i++) |
59 |
|
{ |
60 |
0 |
int size = 1 + alignment.getSequenceAt(i).getEnd() |
61 |
|
- alignment.getSequenceAt(i).getStart(); |
62 |
0 |
avg += size; |
63 |
0 |
if (size > max) |
64 |
|
{ |
65 |
0 |
max = size; |
66 |
|
} |
67 |
0 |
if (size < min) |
68 |
|
{ |
69 |
0 |
min = size; |
70 |
|
} |
71 |
|
} |
72 |
0 |
avg = avg / alignment.getHeight(); |
73 |
0 |
pw.print(nl); |
74 |
0 |
pw.print("Sequences: " + alignment.getHeight()); |
75 |
0 |
pw.print(nl); |
76 |
0 |
pw.print("Minimum Sequence Length: " + min); |
77 |
0 |
pw.print(nl); |
78 |
0 |
pw.print("Maximum Sequence Length: " + max); |
79 |
0 |
pw.print(nl); |
80 |
0 |
pw.print("Average Length: " + (int) avg); |
81 |
|
|
82 |
0 |
if (((Alignment) alignment).alignmentProperties != null) |
83 |
|
{ |
84 |
0 |
pw.print(nl); |
85 |
0 |
pw.print(nl); |
86 |
0 |
if (html) |
87 |
|
{ |
88 |
0 |
pw.print("<table border=\"1\">"); |
89 |
|
} |
90 |
0 |
Hashtable props = ((Alignment) alignment).alignmentProperties; |
91 |
0 |
Enumeration en = props.keys(); |
92 |
0 |
while (en.hasMoreElements()) |
93 |
|
{ |
94 |
0 |
String key = en.nextElement().toString(); |
95 |
0 |
String vals = props.get(key).toString(); |
96 |
0 |
if (html) |
97 |
|
{ |
98 |
|
|
99 |
0 |
StringBuffer val = new StringBuffer(); |
100 |
0 |
int pos = 0, npos; |
101 |
0 |
do |
102 |
|
{ |
103 |
0 |
npos = vals.indexOf("\n", pos); |
104 |
0 |
if (npos == -1) |
105 |
|
{ |
106 |
0 |
val.append(vals.substring(pos)); |
107 |
|
} |
108 |
|
else |
109 |
|
{ |
110 |
0 |
val.append(vals.substring(pos, npos)); |
111 |
0 |
val.append("<br>"); |
112 |
|
} |
113 |
0 |
pos = npos + 1; |
114 |
0 |
} while (npos != -1); |
115 |
0 |
pw.print("<tr><td>" + key + "</td><td>" + val + "</td></tr>"); |
116 |
|
} |
117 |
|
else |
118 |
|
{ |
119 |
0 |
pw.print(nl + key + "\t" + vals); |
120 |
|
} |
121 |
|
} |
122 |
0 |
if (html) |
123 |
|
{ |
124 |
0 |
pw.print("</table>"); |
125 |
|
} |
126 |
|
} |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
@return |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
134 |
0 |
public StringBuffer formatAsString()... |
135 |
|
{ |
136 |
0 |
return formatReport(false); |
137 |
|
} |
138 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
139 |
0 |
protected StringBuffer formatReport(boolean html)... |
140 |
|
{ |
141 |
0 |
StringWriter content = new StringWriter(); |
142 |
0 |
writeProperties(new PrintWriter(content), html); |
143 |
0 |
return content.getBuffer(); |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
@return |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
0 |
public StringBuffer formatAsHtml()... |
152 |
|
{ |
153 |
0 |
return formatReport(true); |
154 |
|
} |
155 |
|
|
156 |
|
} |