1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertTrue; |
25 |
|
|
26 |
|
import jalview.bin.Cache; |
27 |
|
import jalview.datamodel.AlignmentI; |
28 |
|
import jalview.datamodel.SequenceFeature; |
29 |
|
import jalview.datamodel.SequenceI; |
30 |
|
import jalview.gui.JvOptionPane; |
31 |
|
import jalview.structure.StructureImportSettings; |
32 |
|
import jalview.structure.StructureImportSettings.StructureParser; |
33 |
|
import jalview.ws.seqfetcher.DbSourceProxy; |
34 |
|
|
35 |
|
import java.util.Arrays; |
36 |
|
import java.util.List; |
37 |
|
|
38 |
|
import org.testng.Assert; |
39 |
|
import org.testng.annotations.BeforeClass; |
40 |
|
import org.testng.annotations.BeforeMethod; |
41 |
|
import org.testng.annotations.Test; |
42 |
|
|
|
|
| 0% |
Uncovered Elements: 57 (57) |
Complexity: 10 |
Complexity Density: 0.23 |
|
43 |
|
public class PDBSequenceFetcherTest |
44 |
|
{ |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
46 |
0 |
@BeforeClass(alwaysRun = true)... |
47 |
|
public void setUpJvOptionPane() |
48 |
|
{ |
49 |
0 |
JvOptionPane.setInteractiveMode(false); |
50 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
51 |
|
} |
52 |
|
|
53 |
|
SequenceFetcher sf; |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
55 |
0 |
@BeforeMethod(alwaysRun = true)... |
56 |
|
public void setUp() throws Exception |
57 |
|
{ |
58 |
0 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
59 |
|
|
60 |
0 |
Cache.applicationProperties.setProperty("STRUCT_FROM_PDB", |
61 |
|
Boolean.TRUE.toString()); |
62 |
0 |
Cache.applicationProperties.setProperty("ADD_SS_ANN", |
63 |
|
Boolean.TRUE.toString()); |
64 |
|
|
65 |
0 |
sf = new SequenceFetcher(); |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@throws |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
4-
|
|
76 |
0 |
@Test(groups = { "Network" }, enabled = true)... |
77 |
|
public void testRnaSeqRetrieve() throws Exception |
78 |
|
{ |
79 |
0 |
Cache.applicationProperties.setProperty("PDB_DOWNLOAD_FORMAT", "PDB"); |
80 |
0 |
List<DbSourceProxy> sps = sf.getSourceProxy("PDB"); |
81 |
0 |
AlignmentI response = sps.get(0).getSequenceRecords("2GIS"); |
82 |
0 |
assertTrue(response != null); |
83 |
0 |
assertTrue(response.getHeight() == 1); |
84 |
0 |
for (SequenceI sq : response.getSequences()) |
85 |
|
{ |
86 |
0 |
assertTrue("No annotation transfered to sequence.", |
87 |
|
sq.getAnnotation().length > 0); |
88 |
0 |
assertTrue("No PDBEntry on sequence.", |
89 |
|
sq.getAllPDBEntries().size() > 0); |
90 |
0 |
assertTrue( |
91 |
|
"No RNA annotation on sequence, possibly http://arn-ibmc.in2p3.fr/api/compute/2d not available?", |
92 |
|
sq.getRNA() != null); |
93 |
|
} |
94 |
|
} |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
4-
|
|
96 |
0 |
@Test(groups = { "Network" }, enabled = true)... |
97 |
|
public void testPdbSeqRetrieve() throws Exception |
98 |
|
{ |
99 |
0 |
StructureImportSettings.setDefaultStructureFileFormat("PDB"); |
100 |
0 |
StructureImportSettings |
101 |
|
.setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER); |
102 |
|
|
103 |
0 |
testRetrieveProteinSeqFromPDB(); |
104 |
|
} |
105 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
4-
|
|
106 |
0 |
@Test(groups = { "Network" }, enabled = true)... |
107 |
|
public void testmmCifSeqRetrieve() throws Exception |
108 |
|
{ |
109 |
0 |
StructureImportSettings.setDefaultStructureFileFormat("mmCIF"); |
110 |
0 |
testRetrieveProteinSeqFromPDB(); |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.33 |
|
113 |
|
private class TestRetrieveObject |
114 |
|
{ |
115 |
|
String id; |
116 |
|
|
117 |
|
int expectedHeight; |
118 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
119 |
0 |
public TestRetrieveObject(String id, int expectedHeight)... |
120 |
|
{ |
121 |
0 |
super(); |
122 |
0 |
this.id = id; |
123 |
0 |
this.expectedHeight = expectedHeight; |
124 |
|
} |
125 |
|
|
126 |
|
} |
127 |
|
|
128 |
|
private List<TestRetrieveObject> toRetrieve = Arrays.asList( |
129 |
|
new TestRetrieveObject("1QIP", 4), |
130 |
|
new TestRetrieveObject("4IM2", 1)); |
131 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 5 |
Complexity Density: 0.22 |
|
132 |
0 |
private void testRetrieveProteinSeqFromPDB() throws Exception... |
133 |
|
{ |
134 |
0 |
List<DbSourceProxy> sps = sf.getSourceProxy("PDB"); |
135 |
0 |
StringBuilder errors = new StringBuilder(); |
136 |
0 |
for (TestRetrieveObject str : toRetrieve) |
137 |
|
{ |
138 |
0 |
AlignmentI response = sps.get(0).getSequenceRecords(str.id); |
139 |
0 |
assertTrue("No aligment for " + str.id, response != null); |
140 |
0 |
assertEquals(response.getHeight(), str.expectedHeight, |
141 |
|
"Number of chains for " + str.id); |
142 |
0 |
for (SequenceI sq : response.getSequences()) |
143 |
|
{ |
144 |
0 |
assertTrue("No annotation transfered to sequence " + sq.getName(), |
145 |
|
sq.getAnnotation().length > 0); |
146 |
0 |
assertTrue("No PDBEntry on sequence " + sq.getName(), |
147 |
|
sq.getAllPDBEntries().size() > 0); |
148 |
|
|
149 |
|
|
150 |
0 |
List<SequenceFeature> prev = null; |
151 |
0 |
int lastp = -1; |
152 |
0 |
for (int col = 1; col <= sq.getLength(); col++) |
153 |
|
{ |
154 |
0 |
List<SequenceFeature> sf = sq.findFeatures(col, col, "RESNUM"); |
155 |
0 |
if (sf.size() != 1) |
156 |
|
{ |
157 |
0 |
errors.append(str.id + ": " |
158 |
|
+ "Expected one feature at column (position): " |
159 |
|
+ (col - 1) + " (" + sq.findPosition(col - 1) + ")" |
160 |
|
+ ": saw " + sf.size()); |
161 |
0 |
errors.append("\n"); |
162 |
0 |
if (prev != null) |
163 |
|
{ |
164 |
0 |
errors.append("Last Feature was at position " + lastp + ": " |
165 |
|
+ prev.get(0).toString()); |
166 |
0 |
errors.append("\n"); |
167 |
|
} |
168 |
|
} |
169 |
|
else |
170 |
|
{ |
171 |
0 |
prev = sf; |
172 |
0 |
lastp = sq.findPosition(col - 1); |
173 |
|
} |
174 |
|
} |
175 |
|
} |
176 |
|
} |
177 |
0 |
if (errors.length() > 0) |
178 |
|
{ |
179 |
0 |
Assert.fail(errors.toString()); |
180 |
|
} |
181 |
|
} |
182 |
|
} |