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