1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.dbsources; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertFalse; |
25 |
|
import static org.testng.Assert.assertNotNull; |
26 |
|
import static org.testng.Assert.assertTrue; |
27 |
|
|
28 |
|
import jalview.analysis.AlignSeq; |
29 |
|
import jalview.bin.Cache; |
30 |
|
import jalview.datamodel.AlignmentI; |
31 |
|
import jalview.datamodel.DBRefSource; |
32 |
|
import jalview.datamodel.SequenceI; |
33 |
|
import jalview.ext.ensembl.EnsemblGenomes; |
34 |
|
import jalview.fts.api.FTSData; |
35 |
|
import jalview.fts.api.FTSDataColumnI; |
36 |
|
import jalview.fts.api.FTSRestClientI; |
37 |
|
import jalview.fts.core.FTSRestRequest; |
38 |
|
import jalview.fts.core.FTSRestResponse; |
39 |
|
import jalview.fts.service.uniprot.UniProtFTSRestClient; |
40 |
|
import jalview.ws.SequenceFetcher; |
41 |
|
import jalview.ws.seqfetcher.DbSourceProxy; |
42 |
|
|
43 |
|
import java.util.ArrayList; |
44 |
|
import java.util.List; |
45 |
|
|
46 |
|
import org.testng.annotations.BeforeTest; |
47 |
|
import org.testng.annotations.DataProvider; |
48 |
|
import org.testng.annotations.Test; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
|
|
| 12.8% |
Uncovered Elements: 34 (39) |
Complexity: 4 |
Complexity Density: 0.11 |
|
60 |
|
public class RemoteFormatTest |
61 |
|
{ |
62 |
|
SequenceFetcher sf; |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
64 |
4 |
@BeforeTest(alwaysRun = true)... |
65 |
|
public void setUp() throws Exception |
66 |
|
{ |
67 |
4 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
68 |
|
|
69 |
4 |
Cache.applicationProperties.setProperty("STRUCT_FROM_PDB", |
70 |
|
Boolean.TRUE.toString()); |
71 |
4 |
Cache.applicationProperties.setProperty("ADD_SS_ANN", |
72 |
|
Boolean.TRUE.toString()); |
73 |
|
|
74 |
4 |
sf = new SequenceFetcher(); |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
0 |
@DataProvider(name = "AccessionData")... |
78 |
|
protected Object[][] getAccessions() |
79 |
|
{ |
80 |
0 |
return new Object[][] { { DBRefSource.UNIPROT, "P30419" }, |
81 |
|
{ DBRefSource.PDB, "1QIP" }, |
82 |
|
{ DBRefSource.EMBL, "X53828" }, |
83 |
|
{ DBRefSource.EMBLCDS, "CAA37824" }, |
84 |
|
{ DBRefSource.ENSEMBL, "ENSG00000157764" }, |
85 |
|
{ new EnsemblGenomes().getDbSource(), "DDB_G0283883" }, |
86 |
|
{ new PfamFull().getDbSource(), "PF03760" }, |
87 |
|
{ new PfamSeed().getDbSource(), "PF03760" }, |
88 |
|
{ new RfamSeed().getDbSource(), "RF00014" } }; |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
4-
|
|
91 |
0 |
@Test(groups = "Network", dataProvider = "AccessionData")... |
92 |
|
public void testFetchAccession(String dbSource, String accessionId) |
93 |
|
throws Exception |
94 |
|
{ |
95 |
0 |
System.out.println("Fetching " + accessionId + " from " + dbSource); |
96 |
0 |
List<DbSourceProxy> sps = sf.getSourceProxy(dbSource); |
97 |
0 |
assertFalse(sps.isEmpty()); |
98 |
0 |
AlignmentI al = sps.get(0).getSequenceRecords(accessionId); |
99 |
0 |
assertNotNull(al); |
100 |
0 |
assertTrue(al.getHeight() > 0); |
101 |
0 |
SequenceI sq = al.getSequenceAt(0); |
102 |
|
|
103 |
|
|
104 |
0 |
assertTrue(sq.getDBRefs().size() > 0, "No DBRef on sequence."); |
105 |
|
|
106 |
|
|
107 |
0 |
int length = AlignSeq.extractGaps("-. ", sq.getSequenceAsString()) |
108 |
|
.length(); |
109 |
0 |
assertEquals(sq.getEnd() - sq.getStart() + 1, length, |
110 |
|
"Sequence start/end doesn't match number of residues in sequence"); |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
4-
|
|
113 |
0 |
@Test(groups = { "Network" })... |
114 |
|
public void testUniprotFreeTextSearch() throws Exception |
115 |
|
{ |
116 |
0 |
List<FTSDataColumnI> wantedFields = new ArrayList<>(); |
117 |
0 |
FTSRestClientI client = UniProtFTSRestClient.getInstance(); |
118 |
0 |
wantedFields.add(client.getDataColumnByNameOrCode("id")); |
119 |
0 |
wantedFields.add(client.getDataColumnByNameOrCode("entry name")); |
120 |
0 |
wantedFields.add(client.getDataColumnByNameOrCode("organism")); |
121 |
0 |
wantedFields.add(client.getDataColumnByNameOrCode("reviewed")); |
122 |
0 |
wantedFields.add(client.getDataColumnByNameOrCode("length")); |
123 |
|
|
124 |
0 |
FTSRestRequest request = new FTSRestRequest(); |
125 |
0 |
request.setAllowEmptySeq(false); |
126 |
0 |
request.setResponseSize(100); |
127 |
0 |
request.setFieldToSearchBy("Search All"); |
128 |
0 |
request.setSearchTerm("metanephrops"); |
129 |
0 |
request.setWantedFields(wantedFields); |
130 |
|
|
131 |
0 |
FTSRestResponse response; |
132 |
0 |
response = client.executeRequest(request); |
133 |
0 |
assertTrue(response.getNumberOfItemsFound() > 20); |
134 |
0 |
assertTrue(response.getSearchSummary() != null); |
135 |
0 |
assertTrue(response.getSearchSummary().size() > 20); |
136 |
|
|
137 |
0 |
FTSData header = response.getSearchSummary().iterator().next(); |
138 |
0 |
assertFalse( |
139 |
|
header.getSummaryData()[0].toString().equalsIgnoreCase("Entry"), |
140 |
|
"Failed to filter out summary header row"); |
141 |
|
} |
142 |
|
} |