1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.seqfetcher; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
import static org.testng.AssertJUnit.assertNotNull; |
26 |
|
import static org.testng.AssertJUnit.assertTrue; |
27 |
|
|
28 |
|
import jalview.analysis.CrossRef; |
29 |
|
import jalview.datamodel.AlignmentI; |
30 |
|
import jalview.datamodel.DBRefEntry; |
31 |
|
import jalview.datamodel.DBRefSource; |
32 |
|
import jalview.datamodel.FeatureProperties; |
33 |
|
import jalview.datamodel.SequenceFeature; |
34 |
|
import jalview.datamodel.SequenceI; |
35 |
|
import jalview.gui.JvOptionPane; |
36 |
|
import jalview.util.DBRefUtils; |
37 |
|
import jalview.ws.SequenceFetcher; |
38 |
|
import jalview.ws.dbsources.Pdb; |
39 |
|
import jalview.ws.dbsources.Uniprot; |
40 |
|
|
41 |
|
import java.util.ArrayList; |
42 |
|
import java.util.Arrays; |
43 |
|
import java.util.List; |
44 |
|
|
45 |
|
import org.testng.annotations.AfterClass; |
46 |
|
import org.testng.annotations.BeforeClass; |
47 |
|
import org.testng.annotations.Test; |
48 |
|
|
49 |
|
|
50 |
|
@author |
51 |
|
|
52 |
|
|
|
|
| 50% |
Uncovered Elements: 32 (64) |
Complexity: 11 |
Complexity Density: 0.22 |
|
53 |
|
public class DbRefFetcherTest |
54 |
|
{ |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
56 |
1 |
@BeforeClass(alwaysRun = true)... |
57 |
|
public void setUpJvOptionPane() |
58 |
|
{ |
59 |
1 |
JvOptionPane.setInteractiveMode(false); |
60 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
@throws |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
1 |
@BeforeClass(alwaysRun = true)... |
67 |
|
public static void setUpBeforeClass() throws Exception |
68 |
|
{ |
69 |
1 |
jalview.bin.Cache.initLogger(); |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
@throws |
74 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
75 |
1 |
@AfterClass(alwaysRun = true)... |
76 |
|
public static void tearDownAfterClass() throws Exception |
77 |
|
{ |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
|
|
| 96.2% |
Uncovered Elements: 1 (26) |
Complexity: 5 |
Complexity Density: 0.25 |
1PASS
|
|
85 |
1 |
@Test(groups = { "Functional" })... |
86 |
|
public void testStandardProtDbs() |
87 |
|
{ |
88 |
1 |
List<String> defdb = new ArrayList<String>(); |
89 |
1 |
defdb.addAll(Arrays.asList(DBRefSource.PROTEINDBS)); |
90 |
1 |
defdb.add(DBRefSource.PDB); |
91 |
1 |
List<DbSourceProxy> srces = new ArrayList<DbSourceProxy>(); |
92 |
1 |
SequenceFetcher sfetcher = new SequenceFetcher(); |
93 |
1 |
boolean pdbFound = false; |
94 |
|
|
95 |
1 |
for (String ddb : defdb) |
96 |
|
{ |
97 |
5 |
List<DbSourceProxy> srcesfordb = sfetcher.getSourceProxy(ddb); |
98 |
|
|
99 |
5 |
if (srcesfordb != null) |
100 |
|
{ |
101 |
|
|
102 |
5 |
srces.addAll(srcesfordb); |
103 |
|
} |
104 |
|
} |
105 |
|
|
106 |
1 |
int i = 0; |
107 |
1 |
int uniprotPos = -1; |
108 |
1 |
for (DbSourceProxy s : srces) |
109 |
|
{ |
110 |
4 |
if (s instanceof Uniprot && uniprotPos == -1) |
111 |
|
{ |
112 |
1 |
uniprotPos = i; |
113 |
|
} |
114 |
4 |
if (s instanceof Pdb) |
115 |
|
{ |
116 |
1 |
pdbFound = true; |
117 |
|
} |
118 |
4 |
i++; |
119 |
|
} |
120 |
|
|
121 |
1 |
assertTrue("Failed to find Uniprot source as first source amongst " |
122 |
|
+ srces.size() + " sources (source was at position " |
123 |
|
+ uniprotPos + ")", uniprotPos == 0); |
124 |
1 |
assertTrue("Failed to find PDB source amongst " + srces.size() |
125 |
|
+ " sources", pdbFound); |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
@throws |
133 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
134 |
0 |
@Test(groups = { "External" })... |
135 |
|
public void testEmblUniprotProductRecovery() throws Exception |
136 |
|
{ |
137 |
0 |
String retrievalId = "V00488"; |
138 |
0 |
DbSourceProxy embl = new SequenceFetcher().getSourceProxy( |
139 |
|
DBRefSource.EMBL).get(0); |
140 |
0 |
assertNotNull("Couldn't find the EMBL retrieval client", embl); |
141 |
0 |
verifyProteinNucleotideXref(retrievalId, embl); |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
@throws |
149 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
150 |
0 |
@Test(groups = { "External" })... |
151 |
|
public void testEmblCDSUniprotProductRecovery() throws Exception |
152 |
|
{ |
153 |
0 |
String retrievalId = "AAH29712"; |
154 |
0 |
DbSourceProxy embl = new SequenceFetcher().getSourceProxy( |
155 |
|
DBRefSource.EMBLCDS).get(0); |
156 |
0 |
assertNotNull("Couldn't find the EMBL retrieval client", embl); |
157 |
0 |
verifyProteinNucleotideXref(retrievalId, embl); |
158 |
|
} |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
@param |
164 |
|
@param |
165 |
|
@throws |
166 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
|
167 |
0 |
private void verifyProteinNucleotideXref(String retrievalId,... |
168 |
|
DbSourceProxy embl) throws Exception |
169 |
|
{ |
170 |
0 |
AlignmentI alsq = embl.getSequenceRecords(retrievalId); |
171 |
0 |
assertNotNull("Couldn't find the EMBL record " + retrievalId, alsq); |
172 |
0 |
assertEquals("Didn't retrieve right number of records", 1, |
173 |
|
alsq.getHeight()); |
174 |
0 |
SequenceI seq = alsq.getSequenceAt(0); |
175 |
0 |
assertEquals("Wrong sequence name", embl.getDbSource() + "|" |
176 |
|
+ retrievalId, seq.getName()); |
177 |
0 |
List<SequenceFeature> sfs = seq.getSequenceFeatures(); |
178 |
0 |
assertFalse("Sequence features missing", sfs.isEmpty()); |
179 |
0 |
assertTrue( |
180 |
|
"Feature not CDS", |
181 |
|
FeatureProperties.isCodingFeature(embl.getDbSource(), |
182 |
|
sfs.get(0).getType())); |
183 |
0 |
assertEquals(embl.getDbSource(), sfs.get(0).getFeatureGroup()); |
184 |
0 |
DBRefEntry[] dr = DBRefUtils.selectRefs(seq.getDBRefs(), |
185 |
|
new String[] { DBRefSource.UNIPROT }); |
186 |
0 |
assertNotNull(dr); |
187 |
0 |
assertEquals("Expected a single Uniprot cross reference", 1, dr.length); |
188 |
0 |
assertEquals("Expected cross reference map to be one amino acid", dr[0] |
189 |
|
.getMap().getMappedWidth(), 1); |
190 |
0 |
assertEquals("Expected local reference map to be 3 nucleotides", dr[0] |
191 |
|
.getMap().getWidth(), 3); |
192 |
0 |
AlignmentI sprods = new CrossRef(alsq.getSequencesArray(), alsq) |
193 |
|
.findXrefSequences(dr[0].getSource(), true); |
194 |
0 |
assertNotNull( |
195 |
|
"Couldn't recover cross reference sequence from dataset. Was it ever added ?", |
196 |
|
sprods); |
197 |
0 |
assertEquals("Didn't xref right number of records", 1, |
198 |
|
sprods.getHeight()); |
199 |
0 |
SequenceI proteinSeq = sprods.getSequenceAt(0); |
200 |
0 |
assertEquals(proteinSeq.getSequenceAsString(), dr[0].getMap().getTo() |
201 |
|
.getSequenceAsString()); |
202 |
0 |
assertEquals(dr[0].getSource() + "|" + dr[0].getAccessionId(), |
203 |
|
proteinSeq.getName()); |
204 |
|
} |
205 |
|
} |