1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertNotNull; |
25 |
|
import static org.testng.AssertJUnit.assertTrue; |
26 |
|
|
27 |
|
import jalview.datamodel.DBRefEntry; |
28 |
|
import jalview.datamodel.DBRefSource; |
29 |
|
import jalview.datamodel.PDBEntry; |
30 |
|
import jalview.datamodel.Sequence; |
31 |
|
import jalview.datamodel.SequenceI; |
32 |
|
import jalview.fts.api.FTSData; |
33 |
|
import jalview.jbgui.GStructureChooser.FilterOption; |
34 |
|
|
35 |
|
import java.util.Collection; |
36 |
|
import java.util.Vector; |
37 |
|
|
38 |
|
import org.testng.annotations.AfterMethod; |
39 |
|
import org.testng.annotations.BeforeClass; |
40 |
|
import org.testng.annotations.BeforeMethod; |
41 |
|
import org.testng.annotations.Test; |
42 |
|
|
43 |
|
import junit.extensions.PA; |
44 |
|
|
|
|
| 90.5% |
Uncovered Elements: 7 (74) |
Complexity: 9 |
Complexity Density: 0.14 |
|
45 |
|
public class StructureChooserTest |
46 |
|
{ |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
48 |
1 |
@BeforeClass(alwaysRun = true)... |
49 |
|
public void setUpJvOptionPane() |
50 |
|
{ |
51 |
1 |
JvOptionPane.setInteractiveMode(false); |
52 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
53 |
|
} |
54 |
|
|
55 |
|
Sequence seq; |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 2 |
Complexity Density: 0.18 |
|
57 |
3 |
@BeforeMethod(alwaysRun = true)... |
58 |
|
public void setUp() throws Exception |
59 |
|
{ |
60 |
3 |
seq = new Sequence("PDB|4kqy|4KQY|A", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1, |
61 |
|
26); |
62 |
3 |
seq.createDatasetSequence(); |
63 |
15 |
for (int x = 1; x < 5; x++) |
64 |
|
{ |
65 |
12 |
DBRefEntry dbRef = new DBRefEntry(); |
66 |
12 |
dbRef.setAccessionId("XYZ_" + x); |
67 |
12 |
seq.addDBRef(dbRef); |
68 |
|
} |
69 |
|
|
70 |
3 |
PDBEntry dbRef = new PDBEntry(); |
71 |
3 |
dbRef.setId("1tim"); |
72 |
|
|
73 |
3 |
Vector<PDBEntry> pdbIds = new Vector<>(); |
74 |
3 |
pdbIds.add(dbRef); |
75 |
|
|
76 |
3 |
seq.setPDBId(pdbIds); |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
3 |
@AfterMethod(alwaysRun = true)... |
80 |
|
public void tearDown() throws Exception |
81 |
|
{ |
82 |
3 |
seq = null; |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 2 |
Complexity Density: 0.09 |
1PASS
|
|
85 |
1 |
@Test(groups = { "Functional" })... |
86 |
|
public void buildQueryTest() |
87 |
|
{ |
88 |
1 |
String query = StructureChooser.buildQuery(seq); |
89 |
1 |
assertEquals("pdb_id:1tim", query); |
90 |
1 |
System.out.println("seq >>>> " + seq); |
91 |
1 |
seq.getAllPDBEntries().clear(); |
92 |
1 |
query = StructureChooser.buildQuery(seq); |
93 |
1 |
assertEquals( |
94 |
|
"text:XYZ_1 OR text:XYZ_2 OR text:XYZ_3 OR text:XYZ_4 OR text:4kqy", |
95 |
|
query); |
96 |
1 |
seq.setDBRefs(null); |
97 |
1 |
query = StructureChooser.buildQuery(seq); |
98 |
1 |
assertEquals("text:4kqy", query); |
99 |
|
|
100 |
1 |
DBRefEntry uniprotDBRef = new DBRefEntry(); |
101 |
1 |
uniprotDBRef.setAccessionId("P12345"); |
102 |
1 |
uniprotDBRef.setSource(DBRefSource.UNIPROT); |
103 |
1 |
seq.addDBRef(uniprotDBRef); |
104 |
|
|
105 |
1 |
DBRefEntry pdbDBRef = new DBRefEntry(); |
106 |
1 |
pdbDBRef.setAccessionId("1XYZ"); |
107 |
1 |
pdbDBRef.setSource(DBRefSource.PDB); |
108 |
1 |
seq.addDBRef(pdbDBRef); |
109 |
|
|
110 |
5 |
for (int x = 1; x < 5; x++) |
111 |
|
{ |
112 |
4 |
DBRefEntry dbRef = new DBRefEntry(); |
113 |
4 |
dbRef.setAccessionId("XYZ_" + x); |
114 |
4 |
seq.addDBRef(dbRef); |
115 |
|
} |
116 |
1 |
query = StructureChooser.buildQuery(seq); |
117 |
1 |
assertEquals( |
118 |
|
"uniprot_accession:P12345 OR uniprot_id:P12345 OR pdb_id:1xyz", |
119 |
|
query); |
120 |
|
} |
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
122 |
1 |
@Test(groups = { "Functional" })... |
123 |
|
public void populateFilterComboBoxTest() throws InterruptedException |
124 |
|
{ |
125 |
1 |
SequenceI[] selectedSeqs = new SequenceI[] { seq }; |
126 |
1 |
StructureChooser sc = new StructureChooser(selectedSeqs, seq, null); |
127 |
1 |
sc.populateFilterComboBox(false, false); |
128 |
1 |
int optionsSize = sc.getCmbFilterOption().getItemCount(); |
129 |
1 |
assertEquals(2, optionsSize); |
130 |
|
|
131 |
|
|
132 |
1 |
sc.populateFilterComboBox(true, false); |
133 |
1 |
optionsSize = sc.getCmbFilterOption().getItemCount(); |
134 |
1 |
assertTrue(optionsSize > 3); |
135 |
|
|
136 |
|
|
137 |
1 |
sc.populateFilterComboBox(true, true); |
138 |
1 |
assertTrue(sc.getCmbFilterOption().getSelectedItem() != null); |
139 |
1 |
FilterOption filterOpt = (FilterOption) sc.getCmbFilterOption() |
140 |
|
.getSelectedItem(); |
141 |
1 |
assertEquals("Cached Structures", filterOpt.getName()); |
142 |
|
} |
143 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
144 |
0 |
@Test(groups = { "Network" })... |
145 |
|
public void fetchStructuresInfoTest() |
146 |
|
{ |
147 |
0 |
SequenceI[] selectedSeqs = new SequenceI[] { seq }; |
148 |
0 |
StructureChooser sc = new StructureChooser(selectedSeqs, seq, null); |
149 |
0 |
sc.fetchStructuresMetaData(); |
150 |
0 |
Collection<FTSData> ss = (Collection<FTSData>) PA.getValue(sc, |
151 |
|
"discoveredStructuresSet"); |
152 |
0 |
assertNotNull(ss); |
153 |
0 |
assertTrue(ss.size() > 0); |
154 |
|
|
155 |
|
} |
156 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
157 |
1 |
@Test(groups = { "Functional" })... |
158 |
|
public void sanitizeSeqNameTest() |
159 |
|
{ |
160 |
1 |
String name = "ab_cdEF|fwxyz012349"; |
161 |
1 |
assertEquals(name, StructureChooser.sanitizeSeqName(name)); |
162 |
|
|
163 |
|
|
164 |
1 |
name = "abcde12[345]fg"; |
165 |
1 |
assertEquals("abcde12fg", StructureChooser.sanitizeSeqName(name)); |
166 |
|
|
167 |
|
|
168 |
1 |
name = "ab[cd],.\t£$*!- \\\"@:e"; |
169 |
1 |
assertEquals("abcde", StructureChooser.sanitizeSeqName(name)); |
170 |
|
|
171 |
1 |
name = "abcde12[345a]fg"; |
172 |
1 |
assertEquals("abcde12345afg", StructureChooser.sanitizeSeqName(name)); |
173 |
|
} |
174 |
|
} |