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.gui.JvOptionPane; |
24 |
|
import jalview.io.TCoffeeScoreFile.Block; |
25 |
|
import jalview.io.TCoffeeScoreFile.Header; |
26 |
|
|
27 |
|
import java.io.File; |
28 |
|
import java.io.FileNotFoundException; |
29 |
|
import java.io.IOException; |
30 |
|
import java.util.List; |
31 |
|
|
32 |
|
import org.testng.AssertJUnit; |
33 |
|
import org.testng.annotations.BeforeClass; |
34 |
|
import org.testng.annotations.Test; |
35 |
|
|
|
|
| 98.9% |
Uncovered Elements: 1 (95) |
Complexity: 10 |
Complexity Density: 0.12 |
|
36 |
|
public class TCoffeeScoreFileTest |
37 |
|
{ |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
39 |
1 |
@BeforeClass(alwaysRun = true)... |
40 |
|
public void setUpJvOptionPane() |
41 |
|
{ |
42 |
1 |
JvOptionPane.setInteractiveMode(false); |
43 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
44 |
|
} |
45 |
|
|
46 |
|
final static File SCORE_FILE = new File( |
47 |
|
"test/jalview/io/tcoffee.score_ascii"); |
48 |
|
|
49 |
|
final static File ALIGN_FILE = new File( |
50 |
|
"test/jalview/io/tcoffee.fasta_aln"); |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
52 |
1 |
@Test(groups = { "Functional" })... |
53 |
|
public void testReadHeader() throws IOException |
54 |
|
{ |
55 |
|
|
56 |
1 |
TCoffeeScoreFile scoreFile = new TCoffeeScoreFile(SCORE_FILE.getPath(), |
57 |
|
DataSourceType.FILE); |
58 |
1 |
AssertJUnit.assertTrue(scoreFile.getWarningMessage(), |
59 |
|
scoreFile.isValid()); |
60 |
|
|
61 |
1 |
Header header = scoreFile.header; |
62 |
1 |
AssertJUnit.assertNotNull(header); |
63 |
1 |
AssertJUnit.assertEquals( |
64 |
|
"T-COFFEE, Version_9.02.r1228 (2012-02-16 18:15:12 - Revision 1228 - Build 336)", |
65 |
|
header.head); |
66 |
1 |
AssertJUnit.assertEquals(90, header.score); |
67 |
1 |
AssertJUnit.assertEquals(89, header.getScoreFor("1PHT")); |
68 |
1 |
AssertJUnit.assertEquals(90, header.getScoreFor("1BB9")); |
69 |
1 |
AssertJUnit.assertEquals(94, header.getScoreFor("1UHC")); |
70 |
1 |
AssertJUnit.assertEquals(94, header.getScoreFor("1YCS")); |
71 |
1 |
AssertJUnit.assertEquals(93, header.getScoreFor("1OOT")); |
72 |
1 |
AssertJUnit.assertEquals(94, header.getScoreFor("1ABO")); |
73 |
1 |
AssertJUnit.assertEquals(94, header.getScoreFor("1FYN")); |
74 |
1 |
AssertJUnit.assertEquals(94, header.getScoreFor("1QCF")); |
75 |
1 |
AssertJUnit.assertEquals(90, header.getScoreFor("cons")); |
76 |
|
} |
77 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1PASS
|
|
78 |
1 |
@Test(groups = { "Functional" })... |
79 |
|
public void testWrongFile() |
80 |
|
{ |
81 |
1 |
try |
82 |
|
{ |
83 |
1 |
TCoffeeScoreFile result = new TCoffeeScoreFile(ALIGN_FILE.getPath(), |
84 |
|
DataSourceType.FILE); |
85 |
1 |
AssertJUnit.assertFalse(result.isValid()); |
86 |
|
} catch (IOException x) |
87 |
|
{ |
88 |
0 |
AssertJUnit.assertTrue("File not found exception thrown", |
89 |
|
x instanceof FileNotFoundException); |
90 |
|
} |
91 |
|
} |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
93 |
1 |
@Test(groups = { "Functional" })... |
94 |
|
public void testHeightAndWidth() throws IOException |
95 |
|
{ |
96 |
1 |
TCoffeeScoreFile result = new TCoffeeScoreFile(SCORE_FILE.getPath(), |
97 |
|
DataSourceType.FILE); |
98 |
1 |
AssertJUnit.assertTrue(result.isValid()); |
99 |
1 |
AssertJUnit.assertEquals(8, result.getHeight()); |
100 |
1 |
AssertJUnit.assertEquals(83, result.getWidth()); |
101 |
|
} |
102 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
103 |
1 |
@Test(groups = { "Functional" })... |
104 |
|
public void testReadBlock() throws IOException |
105 |
|
{ |
106 |
|
|
107 |
1 |
String BLOCK = "\n" + "\n" + "\n" |
108 |
|
+ "1PHT 999999999999999999999999998762112222543211112134\n" |
109 |
|
+ "1BB9 99999999999999999999999999987-------4322----2234 \n" |
110 |
|
+ "1UHC 99999999999999999999999999987-------5321----2246\n" |
111 |
|
+ "1YCS 99999999999999999999999999986-------4321----1-35\n" |
112 |
|
+ "1OOT 999999999999999999999999999861-------3------1135 \n" |
113 |
|
+ "1ABO 99999999999999999999999999986-------422-------34\n" |
114 |
|
+ "1FYN 99999999999999999999999999985-------32--------35\n" |
115 |
|
+ "1QCF 99999999999999999999999999974-------2---------24\n" |
116 |
|
+ "cons 999999999999999999999999999851000110321100001134\n" |
117 |
|
+ "\n" + "\n"; |
118 |
1 |
FileParse source = new FileParse(BLOCK, DataSourceType.PASTE); |
119 |
1 |
Block block = TCoffeeScoreFile.readBlock(source, 0); |
120 |
|
|
121 |
1 |
AssertJUnit.assertNotNull(block); |
122 |
1 |
AssertJUnit.assertEquals( |
123 |
|
"999999999999999999999999998762112222543211112134", |
124 |
|
block.getScoresFor("1PHT")); |
125 |
1 |
AssertJUnit.assertEquals( |
126 |
|
"99999999999999999999999999987-------4322----2234", |
127 |
|
block.getScoresFor("1BB9")); |
128 |
1 |
AssertJUnit.assertEquals( |
129 |
|
"99999999999999999999999999987-------5321----2246", |
130 |
|
block.getScoresFor("1UHC")); |
131 |
1 |
AssertJUnit.assertEquals( |
132 |
|
"99999999999999999999999999986-------4321----1-35", |
133 |
|
block.getScoresFor("1YCS")); |
134 |
1 |
AssertJUnit.assertEquals( |
135 |
|
"999999999999999999999999999861-------3------1135", |
136 |
|
block.getScoresFor("1OOT")); |
137 |
1 |
AssertJUnit.assertEquals( |
138 |
|
"99999999999999999999999999986-------422-------34", |
139 |
|
block.getScoresFor("1ABO")); |
140 |
1 |
AssertJUnit.assertEquals( |
141 |
|
"99999999999999999999999999985-------32--------35", |
142 |
|
block.getScoresFor("1FYN")); |
143 |
1 |
AssertJUnit.assertEquals( |
144 |
|
"99999999999999999999999999974-------2---------24", |
145 |
|
block.getScoresFor("1QCF")); |
146 |
1 |
AssertJUnit.assertEquals( |
147 |
|
"999999999999999999999999999851000110321100001134", |
148 |
|
block.getConsensus()); |
149 |
|
} |
150 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
151 |
1 |
@Test(groups = { "Functional" })... |
152 |
|
public void testParse() throws IOException |
153 |
|
{ |
154 |
|
|
155 |
1 |
TCoffeeScoreFile parser = new TCoffeeScoreFile(SCORE_FILE.getPath(), |
156 |
|
DataSourceType.FILE); |
157 |
|
|
158 |
1 |
AssertJUnit.assertEquals( |
159 |
|
"999999999999999999999999998762112222543211112134----------5666642367889999999999889", |
160 |
|
parser.getScoresFor("1PHT")); |
161 |
1 |
AssertJUnit.assertEquals( |
162 |
|
"99999999999999999999999999987-------4322----22341111111111676653-355679999999999889", |
163 |
|
parser.getScoresFor("1BB9")); |
164 |
1 |
AssertJUnit.assertEquals( |
165 |
|
"99999999999999999999999999987-------5321----2246----------788774--66789999999999889", |
166 |
|
parser.getScoresFor("1UHC")); |
167 |
1 |
AssertJUnit.assertEquals( |
168 |
|
"99999999999999999999999999986-------4321----1-35----------78777--356789999999999889", |
169 |
|
parser.getScoresFor("1YCS")); |
170 |
1 |
AssertJUnit.assertEquals( |
171 |
|
"999999999999999999999999999861-------3------1135----------78877--356789999999997-67", |
172 |
|
parser.getScoresFor("1OOT")); |
173 |
1 |
AssertJUnit.assertEquals( |
174 |
|
"99999999999999999999999999986-------422-------34----------687774--56779999999999889", |
175 |
|
parser.getScoresFor("1ABO")); |
176 |
1 |
AssertJUnit.assertEquals( |
177 |
|
"99999999999999999999999999985-------32--------35----------6888842356789999999999889", |
178 |
|
parser.getScoresFor("1FYN")); |
179 |
1 |
AssertJUnit.assertEquals( |
180 |
|
"99999999999999999999999999974-------2---------24----------6878742356789999999999889", |
181 |
|
parser.getScoresFor("1QCF")); |
182 |
1 |
AssertJUnit.assertEquals( |
183 |
|
"99999999999999999999999999985100011032110000113400100000006877641356789999999999889", |
184 |
|
parser.getScoresFor("cons")); |
185 |
|
} |
186 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
187 |
1 |
@Test(groups = { "Functional" })... |
188 |
|
public void testGetAsList() throws IOException |
189 |
|
{ |
190 |
|
|
191 |
1 |
TCoffeeScoreFile parser = new TCoffeeScoreFile(SCORE_FILE.getPath(), |
192 |
|
DataSourceType.FILE); |
193 |
1 |
AssertJUnit.assertTrue(parser.getWarningMessage(), parser.isValid()); |
194 |
1 |
List<String> scores = parser.getScoresList(); |
195 |
1 |
AssertJUnit.assertEquals( |
196 |
|
"999999999999999999999999998762112222543211112134----------5666642367889999999999889", |
197 |
|
scores.get(0)); |
198 |
1 |
AssertJUnit.assertEquals( |
199 |
|
"99999999999999999999999999987-------4322----22341111111111676653-355679999999999889", |
200 |
|
scores.get(1)); |
201 |
1 |
AssertJUnit.assertEquals( |
202 |
|
"99999999999999999999999999987-------5321----2246----------788774--66789999999999889", |
203 |
|
scores.get(2)); |
204 |
1 |
AssertJUnit.assertEquals( |
205 |
|
"99999999999999999999999999986-------4321----1-35----------78777--356789999999999889", |
206 |
|
scores.get(3)); |
207 |
1 |
AssertJUnit.assertEquals( |
208 |
|
"999999999999999999999999999861-------3------1135----------78877--356789999999997-67", |
209 |
|
scores.get(4)); |
210 |
1 |
AssertJUnit.assertEquals( |
211 |
|
"99999999999999999999999999986-------422-------34----------687774--56779999999999889", |
212 |
|
scores.get(5)); |
213 |
1 |
AssertJUnit.assertEquals( |
214 |
|
"99999999999999999999999999985-------32--------35----------6888842356789999999999889", |
215 |
|
scores.get(6)); |
216 |
1 |
AssertJUnit.assertEquals( |
217 |
|
"99999999999999999999999999974-------2---------24----------6878742356789999999999889", |
218 |
|
scores.get(7)); |
219 |
1 |
AssertJUnit.assertEquals( |
220 |
|
"99999999999999999999999999985100011032110000113400100000006877641356789999999999889", |
221 |
|
scores.get(8)); |
222 |
|
|
223 |
|
} |
224 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
225 |
1 |
@Test(groups = { "Functional" })... |
226 |
|
public void testGetAsArray() throws IOException |
227 |
|
{ |
228 |
|
|
229 |
1 |
TCoffeeScoreFile parser = new TCoffeeScoreFile(SCORE_FILE.getPath(), |
230 |
|
DataSourceType.FILE); |
231 |
1 |
AssertJUnit.assertTrue(parser.getWarningMessage(), parser.isValid()); |
232 |
1 |
byte[][] scores = parser.getScoresArray(); |
233 |
|
|
234 |
1 |
AssertJUnit.assertEquals(9, scores[0][0]); |
235 |
1 |
AssertJUnit.assertEquals(9, scores[1][0]); |
236 |
1 |
AssertJUnit.assertEquals(9, scores[2][0]); |
237 |
1 |
AssertJUnit.assertEquals(9, scores[3][0]); |
238 |
1 |
AssertJUnit.assertEquals(9, scores[4][0]); |
239 |
1 |
AssertJUnit.assertEquals(9, scores[5][0]); |
240 |
1 |
AssertJUnit.assertEquals(9, scores[6][0]); |
241 |
1 |
AssertJUnit.assertEquals(9, scores[7][0]); |
242 |
1 |
AssertJUnit.assertEquals(9, scores[8][0]); |
243 |
|
|
244 |
1 |
AssertJUnit.assertEquals(5, scores[0][36]); |
245 |
1 |
AssertJUnit.assertEquals(4, scores[1][36]); |
246 |
1 |
AssertJUnit.assertEquals(5, scores[2][36]); |
247 |
1 |
AssertJUnit.assertEquals(4, scores[3][36]); |
248 |
1 |
AssertJUnit.assertEquals(-1, scores[4][36]); |
249 |
1 |
AssertJUnit.assertEquals(4, scores[5][36]); |
250 |
1 |
AssertJUnit.assertEquals(3, scores[6][36]); |
251 |
1 |
AssertJUnit.assertEquals(2, scores[7][36]); |
252 |
1 |
AssertJUnit.assertEquals(3, scores[8][36]); |
253 |
|
|
254 |
|
} |
255 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
256 |
1 |
@Test(groups = { "Functional" })... |
257 |
|
public void testHeightAndWidthWithResidueNumbers() throws Exception |
258 |
|
{ |
259 |
1 |
String file = "test/jalview/io/tcoffee.score_ascii_with_residue_numbers"; |
260 |
1 |
TCoffeeScoreFile result = new TCoffeeScoreFile(file, |
261 |
|
DataSourceType.FILE); |
262 |
1 |
AssertJUnit.assertTrue(result.isValid()); |
263 |
1 |
AssertJUnit.assertEquals(5, result.getHeight()); |
264 |
1 |
AssertJUnit.assertEquals(84, result.getWidth()); |
265 |
|
} |
266 |
|
|
267 |
|
} |