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 static org.testng.AssertJUnit.assertFalse; |
24 |
|
import static org.testng.AssertJUnit.assertSame; |
25 |
|
import static org.testng.AssertJUnit.assertTrue; |
26 |
|
|
27 |
|
import jalview.gui.JvOptionPane; |
28 |
|
|
29 |
|
import org.testng.Assert; |
30 |
|
import org.testng.annotations.BeforeClass; |
31 |
|
import org.testng.annotations.DataProvider; |
32 |
|
import org.testng.annotations.Test; |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 5 |
Complexity Density: 0.23 |
|
34 |
|
public class IdentifyFileTest |
35 |
|
{ |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
37 |
1 |
@BeforeClass(alwaysRun = true)... |
38 |
|
public void setUpJvOptionPane() |
39 |
|
{ |
40 |
1 |
JvOptionPane.setInteractiveMode(false); |
41 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
42 |
|
} |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
44 |
20 |
@Test(groups = { "Functional" }, dataProvider = "identifyFiles")... |
45 |
|
public void testIdentify(String data, FileFormatI expectedFileType) |
46 |
|
throws FileFormatException |
47 |
|
{ |
48 |
20 |
DataSourceType protocol = DataSourceType.FILE; |
49 |
20 |
IdentifyFile ider = new IdentifyFile(); |
50 |
20 |
FileFormatI actualFiletype = ider.identify(data, protocol); |
51 |
19 |
Assert.assertSame(actualFiletype, expectedFileType, |
52 |
|
"File identification Failed!"); |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
@throws |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
60 |
1 |
@Test(groups = "Functional")... |
61 |
|
public void testIdentify_featureFile() throws FileFormatException |
62 |
|
{ |
63 |
1 |
IdentifyFile ider = new IdentifyFile(); |
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
1 |
String data = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n" |
69 |
|
+ "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n"; |
70 |
1 |
assertSame(FileFormat.Features, |
71 |
|
ider.identify(data, DataSourceType.PASTE)); |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
1 |
data = "METAL\tcc9900\n" + "GFF\n" |
77 |
|
+ "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\n"; |
78 |
1 |
assertSame(FileFormat.Features, |
79 |
|
ider.identify(data, DataSourceType.PASTE)); |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
1 |
data = "kD < 3\tred\n" + "Low kD\tFER_CAPAA\t-1\t39\t39\tkD < 3\n"; |
85 |
1 |
assertSame(FileFormat.Features, |
86 |
|
ider.identify(data, DataSourceType.PASTE)); |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
1 |
@DataProvider(name = "identifyFiles")... |
90 |
|
public Object[][] IdentifyFileDP() |
91 |
|
{ |
92 |
1 |
return new Object[][] { |
93 |
|
{ "examples/example.json", FileFormat.Json }, |
94 |
|
{ "examples/plantfdx.fa", FileFormat.Fasta }, |
95 |
|
{ "examples/dna_interleaved.phy", FileFormat.Phylip }, |
96 |
|
{ "examples/2GIS.pdb", FileFormat.PDB }, |
97 |
|
{ "examples/rf00031_folded.stk", FileFormat.Stockholm }, |
98 |
|
{ "examples/testdata/test.rnaml", FileFormat.Rnaml }, |
99 |
|
{ "examples/testdata/test.aln", FileFormat.Clustal }, |
100 |
|
{ "examples/testdata/test.pfam", FileFormat.Pfam }, |
101 |
|
{ "examples/testdata/test.msf", FileFormat.MSF }, |
102 |
|
{ "examples/testdata/test.pir", FileFormat.PIR }, |
103 |
|
{ "examples/testdata/test.html", FileFormat.Html }, |
104 |
|
{ "examples/testdata/test.pileup", FileFormat.Pileup }, |
105 |
|
{ "examples/testdata/test.blc", FileFormat.BLC }, |
106 |
|
{ "examples/exampleFeatures.txt", FileFormat.Features }, |
107 |
|
{ "examples/testdata/simpleGff3.gff", FileFormat.Features }, |
108 |
|
{ "examples/testdata/test.jvp", FileFormat.Jalview }, |
109 |
|
{ "examples/testdata/test.cif", FileFormat.MMCif }, |
110 |
|
{ |
111 |
|
"examples/testdata/cullpdb_pc25_res3.0_R0.3_d150729_chains9361.fasta.15316", |
112 |
|
FileFormat.Fasta }, |
113 |
|
{ "resources/scoreModel/pam250.scm", FileFormat.ScoreMatrix }, |
114 |
|
{ "resources/scoreModel/blosum80.scm", FileFormat.ScoreMatrix } |
115 |
|
|
116 |
|
|
117 |
|
}; |
118 |
|
} |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
120 |
1 |
@Test(groups = "Functional")... |
121 |
|
public void testLooksLikeFeatureData() |
122 |
|
{ |
123 |
1 |
IdentifyFile id = new IdentifyFile(); |
124 |
1 |
assertFalse(id.looksLikeFeatureData(null)); |
125 |
1 |
assertFalse(id.looksLikeFeatureData("")); |
126 |
|
|
127 |
1 |
assertFalse(id.looksLikeFeatureData("1 \t 2 \t 3 \t 4 \t 5")); |
128 |
|
|
129 |
1 |
assertTrue(id |
130 |
|
.looksLikeFeatureData("Seq1\tlocal\tHelix\t2456\t2462\tss")); |
131 |
|
|
132 |
1 |
assertTrue(id.looksLikeFeatureData("Helix\tSeq1\t-1\t2456\t2462\tss")); |
133 |
|
|
134 |
1 |
assertFalse(id.looksLikeFeatureData("Helix\tSeq1\t-1\t.\t2462\tss")); |
135 |
|
|
136 |
1 |
assertFalse(id.looksLikeFeatureData("Helix\tSeq1\t-1\t2456\t.\tss")); |
137 |
|
} |
138 |
|
} |