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 java.util.Locale; |
24 |
|
|
25 |
|
import java.io.File; |
26 |
|
import java.io.IOException; |
27 |
|
|
28 |
|
import com.stevesoft.pat.Regex; |
29 |
|
|
30 |
|
import jalview.bin.Console; |
31 |
|
import jalview.datamodel.Alignment; |
32 |
|
import jalview.datamodel.AlignmentI; |
33 |
|
import jalview.datamodel.SequenceI; |
34 |
|
import jalview.io.DataSourceType; |
35 |
|
import jalview.io.EmblFlatFile; |
36 |
|
import jalview.io.FileParse; |
37 |
|
import jalview.ws.ebi.EBIFetchClient; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@author |
43 |
|
|
44 |
|
|
|
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 16 |
Complexity Density: 0.55 |
|
45 |
|
public abstract class EmblFlatfileSource extends EbiFileRetrievedProxy |
46 |
|
{ |
47 |
|
private static final Regex ACCESSION_REGEX = new Regex("^[A-Z]+[0-9]+"); |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
0 |
@Override... |
50 |
|
public String getDbVersion() |
51 |
|
{ |
52 |
0 |
return "0"; |
53 |
|
} |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
0 |
@Override... |
56 |
|
public String getAccessionSeparator() |
57 |
|
{ |
58 |
0 |
return null; |
59 |
|
} |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
0 |
@Override... |
62 |
|
public Regex getAccessionValidator() |
63 |
|
{ |
64 |
0 |
return ACCESSION_REGEX; |
65 |
|
} |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
67 |
0 |
@Override... |
68 |
|
public boolean isValidReference(String accession) |
69 |
|
{ |
70 |
0 |
if (accession == null || accession.length() < 2) |
71 |
|
{ |
72 |
0 |
return false; |
73 |
|
} |
74 |
0 |
return getAccessionValidator().search(accession); |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
0 |
@Override... |
78 |
|
public AlignmentI getSequenceRecords(String queries) throws Exception |
79 |
|
{ |
80 |
0 |
return null; |
81 |
|
} |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
83 |
0 |
@Override... |
84 |
|
public int getTier() |
85 |
|
{ |
86 |
0 |
return 0; |
87 |
|
} |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
89 |
0 |
protected AlignmentI getEmblSequenceRecords(String dbName, String query)... |
90 |
|
throws Exception |
91 |
|
{ |
92 |
0 |
startQuery(); |
93 |
0 |
EBIFetchClient dbFetch = new EBIFetchClient(); |
94 |
0 |
File reply; |
95 |
0 |
try |
96 |
|
{ |
97 |
0 |
reply = dbFetch.fetchDataAsFile( |
98 |
|
dbName.toLowerCase(Locale.ROOT) + ":" + query.trim(), null, |
99 |
|
"gz"); |
100 |
|
} catch (Exception e) |
101 |
|
{ |
102 |
0 |
stopQuery(); |
103 |
0 |
throw new Exception( |
104 |
|
String.format("EBI EMBL retrieval failed for %s:%s", |
105 |
|
dbName.toLowerCase(Locale.ROOT), query.trim()), |
106 |
|
e); |
107 |
|
} |
108 |
0 |
return getEmblSequenceRecords(dbName, query, reply); |
109 |
|
} |
110 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.42 |
|
111 |
0 |
private AlignmentI getEmblSequenceRecords(String dbName, String query,... |
112 |
|
File reply) throws IOException |
113 |
|
{ |
114 |
0 |
AlignmentI al = null; |
115 |
|
|
116 |
0 |
if (reply != null && reply.exists()) |
117 |
|
{ |
118 |
0 |
file = reply.getAbsolutePath(); |
119 |
0 |
FileParse fp = new FileParse(file, DataSourceType.FILE); |
120 |
0 |
EmblFlatFile emblParser = new EmblFlatFile(fp, getDbSource()); |
121 |
0 |
SequenceI[] seqs = emblParser.getSeqsAsArray(); |
122 |
0 |
if (seqs.length > 0) |
123 |
|
{ |
124 |
0 |
al = new Alignment(seqs); |
125 |
|
} |
126 |
|
|
127 |
0 |
if (al == null) |
128 |
|
{ |
129 |
0 |
Console.error("No record found for '" + dbName + ":" + query + "'"); |
130 |
|
} |
131 |
|
} |
132 |
|
|
133 |
0 |
stopQuery(); |
134 |
0 |
return al; |
135 |
|
} |
136 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
137 |
0 |
@Override... |
138 |
|
public boolean isDnaCoding() |
139 |
|
{ |
140 |
0 |
return true; |
141 |
|
} |
142 |
|
} |