| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.io; |
| 22 |
|
|
| 23 |
|
import java.io.IOException; |
| 24 |
|
|
| 25 |
|
import jalview.bin.Console; |
| 26 |
|
import jalview.datamodel.DBRefEntry; |
| 27 |
|
import jalview.util.DBRefUtils; |
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@author |
| 45 |
|
@see |
| 46 |
|
@see |
| 47 |
|
|
| |
|
| 89.2% |
Uncovered Elements: 10 (93) |
Complexity: 24 |
Complexity Density: 0.45 |
|
| 48 |
|
public class EmblFlatFile extends EMBLLikeFlatFile |
| 49 |
|
{ |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
@param |
| 54 |
|
@param |
| 55 |
|
@throws |
| 56 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 57 |
3 |
public EmblFlatFile(FileParse fp, String sourceId) throws IOException... |
| 58 |
|
{ |
| 59 |
3 |
super(fp, sourceId); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
@throws |
| 67 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 7 |
Complexity Density: 0.5 |
|
| 68 |
3 |
@Override... |
| 69 |
|
public void parse() throws IOException |
| 70 |
|
{ |
| 71 |
3 |
String line = nextLine(); |
| 72 |
121 |
while (line != null) |
| 73 |
|
{ |
| 74 |
118 |
if (line.startsWith("ID")) |
| 75 |
|
{ |
| 76 |
3 |
line = parseID(line); |
| 77 |
|
} |
| 78 |
115 |
else if (line.startsWith("DE")) |
| 79 |
|
{ |
| 80 |
3 |
line = parseDE(line); |
| 81 |
|
} |
| 82 |
112 |
else if (line.startsWith("DR")) |
| 83 |
|
{ |
| 84 |
8 |
line = parseDR(line); |
| 85 |
|
} |
| 86 |
104 |
else if (line.startsWith("SQ")) |
| 87 |
|
{ |
| 88 |
3 |
line = parseSequence(); |
| 89 |
|
} |
| 90 |
101 |
else if (line.startsWith("FT")) |
| 91 |
|
{ |
| 92 |
23 |
line = parseFeature(line.substring(2)); |
| 93 |
|
} |
| 94 |
|
else |
| 95 |
|
{ |
| 96 |
78 |
line = nextLine(); |
| 97 |
|
} |
| 98 |
|
} |
| 99 |
3 |
buildSequence(); |
| 100 |
|
} |
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
@param |
| 107 |
|
@throws |
| 108 |
|
|
| |
|
| 79.2% |
Uncovered Elements: 5 (24) |
Complexity: 6 |
Complexity Density: 0.38 |
|
| 109 |
3 |
String parseID(String line) throws IOException... |
| 110 |
|
{ |
| 111 |
3 |
String[] tokens = line.substring(2).split(";"); |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
3 |
String token = tokens[0].trim(); |
| 117 |
3 |
if (!token.isEmpty()) |
| 118 |
|
{ |
| 119 |
3 |
this.accession = token; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
3 |
if (tokens.length > 1) |
| 126 |
|
{ |
| 127 |
3 |
token = tokens[1].trim(); |
| 128 |
3 |
if (token.startsWith("SV")) |
| 129 |
|
{ |
| 130 |
3 |
String[] bits = token.trim().split(WHITESPACE); |
| 131 |
3 |
this.version = bits[bits.length - 1]; |
| 132 |
|
} |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
3 |
if (tokens.length > 6) |
| 139 |
|
{ |
| 140 |
3 |
token = tokens[6].trim(); |
| 141 |
3 |
String[] bits = token.trim().split(WHITESPACE); |
| 142 |
3 |
try |
| 143 |
|
{ |
| 144 |
3 |
this.length = Integer.valueOf(bits[0]); |
| 145 |
|
} catch (NumberFormatException e) |
| 146 |
|
{ |
| 147 |
0 |
Console.error("bad length read in flatfile, line: " + line); |
| 148 |
|
} |
| 149 |
|
} |
| 150 |
|
|
| 151 |
3 |
return nextLine(); |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
@param |
| 160 |
|
@return |
| 161 |
|
@throws |
| 162 |
|
|
| |
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 163 |
3 |
String parseDE(String line) throws IOException... |
| 164 |
|
{ |
| 165 |
3 |
String desc = line.substring(2).trim(); |
| 166 |
3 |
if (desc.endsWith(".")) |
| 167 |
|
{ |
| 168 |
2 |
desc = desc.substring(0, desc.length() - 1); |
| 169 |
|
} |
| 170 |
3 |
this.description = desc; |
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
? |
while ((line = nextLine()) != null) |
| 176 |
|
{ |
| 177 |
3 |
if (!line.startsWith("DE")) |
| 178 |
|
{ |
| 179 |
3 |
break; |
| 180 |
|
} |
| 181 |
|
} |
| 182 |
|
|
| 183 |
3 |
return line; |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
@param |
| 191 |
|
@throws |
| 192 |
|
|
| |
|
| 90.5% |
Uncovered Elements: 2 (21) |
Complexity: 5 |
Complexity Density: 0.38 |
|
| 193 |
8 |
String parseDR(String line) throws IOException... |
| 194 |
|
{ |
| 195 |
8 |
String[] tokens = line.substring(2).split(";"); |
| 196 |
8 |
if (tokens.length > 1) |
| 197 |
|
{ |
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
8 |
String db = tokens[0].trim(); |
| 202 |
8 |
db = DBRefUtils.getCanonicalName(db); |
| 203 |
8 |
String acc = tokens[1].trim(); |
| 204 |
8 |
if (acc.endsWith(".")) |
| 205 |
|
{ |
| 206 |
4 |
acc = acc.substring(0, acc.length() - 1); |
| 207 |
|
} |
| 208 |
8 |
String version = "0"; |
| 209 |
8 |
if (tokens.length > 2) |
| 210 |
|
{ |
| 211 |
4 |
String secondaryId = tokens[2].trim(); |
| 212 |
4 |
if (!secondaryId.isEmpty()) |
| 213 |
|
{ |
| 214 |
|
|
| 215 |
|
|
| 216 |
|
} |
| 217 |
|
} |
| 218 |
8 |
this.dbrefs.add(new DBRefEntry(db, version, acc)); |
| 219 |
|
} |
| 220 |
|
|
| 221 |
8 |
return nextLine(); |
| 222 |
|
} |
| 223 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 224 |
447 |
@Override... |
| 225 |
|
protected boolean isFeatureContinuationLine(String line) |
| 226 |
|
{ |
| 227 |
447 |
return line.startsWith("FT "); |
| 228 |
|
} |
| 229 |
|
} |