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 jalview.api.AlignExportSettingsI; |
24 |
|
import jalview.api.AlignmentViewPanel; |
25 |
|
import jalview.datamodel.Alignment; |
26 |
|
import jalview.datamodel.AlignmentAnnotation; |
27 |
|
import jalview.datamodel.AlignmentI; |
28 |
|
import jalview.datamodel.AlignmentView; |
29 |
|
import jalview.datamodel.PDBEntry.Type; |
30 |
|
import jalview.datamodel.SequenceI; |
31 |
|
import jalview.ext.jmol.JmolParser; |
32 |
|
import jalview.structure.StructureImportSettings; |
33 |
|
|
34 |
|
import java.io.File; |
35 |
|
import java.io.IOException; |
36 |
|
import java.io.InputStream; |
37 |
|
import java.util.List; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
@author |
46 |
|
@version |
47 |
|
|
|
|
| 28% |
Uncovered Elements: 229 (318) |
Complexity: 84 |
Complexity Density: 0.41 |
|
48 |
|
public class AppletFormatAdapter |
49 |
|
{ |
50 |
|
private AlignmentViewPanel viewpanel; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
boolean annotFromStructure = false; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
boolean localSecondaryStruct = false; |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
boolean serviceSecondaryStruct = false; |
66 |
|
|
67 |
|
private AlignmentFileReaderI alignFile = null; |
68 |
|
|
69 |
|
String inFile; |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
protected String newline = System.getProperty("line.separator"); |
75 |
|
|
76 |
|
private AlignExportSettingsI exportSettings; |
77 |
|
|
78 |
|
private File selectedFile; |
79 |
|
|
80 |
|
public static String INVALID_CHARACTERS = "Contains invalid characters"; |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
@return |
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
69 |
public static String getSupportedFormats()... |
88 |
|
{ |
89 |
69 |
return "Formats currently supported are\n" |
90 |
|
+ prettyPrint(FileFormats.getInstance().getReadableFormats()); |
91 |
|
} |
92 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
93 |
269 |
public AppletFormatAdapter()... |
94 |
|
{ |
95 |
|
} |
96 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
2 |
public AppletFormatAdapter(AlignmentViewPanel viewpanel)... |
98 |
|
{ |
99 |
2 |
this.viewpanel = viewpanel; |
100 |
|
} |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
102 |
2 |
public AppletFormatAdapter(AlignmentViewPanel alignPanel,... |
103 |
|
AlignExportSettingsI settings) |
104 |
|
{ |
105 |
2 |
viewpanel = alignPanel; |
106 |
2 |
exportSettings = settings; |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
@param |
113 |
|
@return |
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
115 |
69 |
public static String prettyPrint(List<? extends Object> things)... |
116 |
|
{ |
117 |
69 |
StringBuffer list = new StringBuffer(); |
118 |
1173 |
for (int i = 0, iSize = things.size() - 1; i < iSize; i++) |
119 |
|
{ |
120 |
1104 |
list.append(things.get(i).toString()); |
121 |
1104 |
list.append(", "); |
122 |
|
} |
123 |
|
|
124 |
69 |
list.append(" and " + things.get(things.size() - 1).toString() + "."); |
125 |
69 |
return list.toString(); |
126 |
|
} |
127 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
128 |
0 |
public void setNewlineString(String nl)... |
129 |
|
{ |
130 |
0 |
newline = nl; |
131 |
|
} |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0 |
public String getNewlineString()... |
134 |
|
{ |
135 |
0 |
return newline; |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
@param |
142 |
|
|
143 |
|
@param |
144 |
|
|
145 |
|
@param |
146 |
|
|
147 |
|
@return |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
149 |
227 |
public AlignmentI readFile(String file, DataSourceType sourceType,... |
150 |
|
FileFormatI fileFormat) throws IOException |
151 |
|
{ |
152 |
227 |
return readFile(null, file, sourceType, fileFormat); |
153 |
|
} |
154 |
|
|
|
|
| 40.4% |
Uncovered Elements: 31 (52) |
Complexity: 14 |
Complexity Density: 0.44 |
|
155 |
227 |
public AlignmentI readFile(File selectedFile, String file, DataSourceType sourceType,... |
156 |
|
FileFormatI fileFormat) throws IOException |
157 |
|
{ |
158 |
|
|
159 |
227 |
this.selectedFile = selectedFile; |
160 |
227 |
if (selectedFile != null) |
161 |
0 |
this.inFile = selectedFile.getPath(); |
162 |
227 |
this.inFile = file; |
163 |
227 |
try |
164 |
|
{ |
165 |
227 |
if (fileFormat.isStructureFile()) |
166 |
|
{ |
167 |
11 |
String structureParser = StructureImportSettings |
168 |
|
.getDefaultPDBFileParser(); |
169 |
11 |
boolean isParseWithJMOL = structureParser.equalsIgnoreCase( |
170 |
|
StructureImportSettings.StructureParser.JMOL_PARSER |
171 |
|
.toString()); |
172 |
11 |
StructureImportSettings.addSettings(annotFromStructure, |
173 |
|
localSecondaryStruct, serviceSecondaryStruct); |
174 |
11 |
if (isParseWithJMOL) |
175 |
|
{ |
176 |
|
|
177 |
11 |
alignFile = new JmolParser(selectedFile == null ? inFile : selectedFile, sourceType); |
178 |
|
} |
179 |
|
else |
180 |
|
{ |
181 |
|
|
182 |
0 |
StructureImportSettings.setShowSeqFeatures(true); |
183 |
0 |
alignFile = new mc_view.PDBfile(annotFromStructure, |
184 |
|
localSecondaryStruct, serviceSecondaryStruct, inFile, |
185 |
|
sourceType); |
186 |
|
} |
187 |
11 |
((StructureFile) alignFile).setDbRefType( |
188 |
11 |
FileFormat.PDB.equals(fileFormat) ? Type.PDB : Type.MMCIF); |
189 |
|
} |
190 |
216 |
else if (selectedFile != null) { |
191 |
0 |
alignFile = fileFormat.getReader(new FileParse(selectedFile, sourceType)); |
192 |
|
} else |
193 |
|
{ |
194 |
|
|
195 |
216 |
alignFile = fileFormat.getReader(new FileParse(inFile, sourceType)); |
196 |
|
} |
197 |
227 |
return buildAlignmentFromFile(); |
198 |
|
} catch (Exception e) |
199 |
|
{ |
200 |
0 |
e.printStackTrace(); |
201 |
0 |
System.err.println("Failed to read alignment using the '" + fileFormat |
202 |
|
+ "' reader.\n" + e); |
203 |
|
|
204 |
0 |
if (e.getMessage() != null |
205 |
|
&& e.getMessage().startsWith(INVALID_CHARACTERS)) |
206 |
|
{ |
207 |
0 |
throw new IOException(e.getMessage()); |
208 |
|
} |
209 |
|
|
210 |
|
|
211 |
0 |
if (sourceType == DataSourceType.PASTE) |
212 |
|
{ |
213 |
0 |
try |
214 |
|
{ |
215 |
|
|
216 |
0 |
alignFile = new FastaFile(">UNKNOWN\n" + inFile, |
217 |
|
DataSourceType.PASTE); |
218 |
0 |
return buildAlignmentFromFile(); |
219 |
|
|
220 |
|
} catch (Exception ex) |
221 |
|
{ |
222 |
0 |
if (ex.toString().startsWith(INVALID_CHARACTERS)) |
223 |
|
{ |
224 |
0 |
throw new IOException(e.getMessage()); |
225 |
|
} |
226 |
|
|
227 |
0 |
ex.printStackTrace(); |
228 |
|
} |
229 |
|
} |
230 |
0 |
if (FileFormat.Html.equals(fileFormat)) |
231 |
|
{ |
232 |
0 |
throw new IOException(e.getMessage()); |
233 |
|
} |
234 |
|
} |
235 |
0 |
throw new FileFormatException(getSupportedFormats()); |
236 |
|
} |
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
@param |
242 |
|
|
243 |
|
@param |
244 |
|
|
245 |
|
|
246 |
|
@return |
247 |
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 10 |
Complexity Density: 0.4 |
|
248 |
0 |
public AlignmentI readFromFile(FileParse source, FileFormatI format)... |
249 |
|
throws IOException |
250 |
|
{ |
251 |
0 |
this.inFile = source.getInFile(); |
252 |
0 |
DataSourceType type = source.dataSourceType; |
253 |
0 |
try |
254 |
|
{ |
255 |
0 |
if (FileFormat.PDB.equals(format) || FileFormat.MMCif.equals(format)) |
256 |
|
{ |
257 |
|
|
258 |
0 |
boolean isParseWithJMOL = false; |
259 |
0 |
if (isParseWithJMOL) |
260 |
|
{ |
261 |
0 |
StructureImportSettings.addSettings(annotFromStructure, |
262 |
|
localSecondaryStruct, serviceSecondaryStruct); |
263 |
0 |
alignFile = new JmolParser(source); |
264 |
|
} |
265 |
|
else |
266 |
|
{ |
267 |
0 |
StructureImportSettings.setShowSeqFeatures(true); |
268 |
0 |
alignFile = new mc_view.PDBfile(annotFromStructure, |
269 |
|
localSecondaryStruct, serviceSecondaryStruct, source); |
270 |
|
} |
271 |
0 |
((StructureFile) alignFile).setDbRefType(Type.PDB); |
272 |
|
} |
273 |
|
else |
274 |
|
{ |
275 |
0 |
alignFile = format.getReader(source); |
276 |
|
} |
277 |
|
|
278 |
0 |
return buildAlignmentFromFile(); |
279 |
|
|
280 |
|
} catch (Exception e) |
281 |
|
{ |
282 |
0 |
e.printStackTrace(); |
283 |
0 |
System.err.println("Failed to read alignment using the '" + format |
284 |
|
+ "' reader.\n" + e); |
285 |
|
|
286 |
0 |
if (e.getMessage() != null |
287 |
|
&& e.getMessage().startsWith(INVALID_CHARACTERS)) |
288 |
|
{ |
289 |
0 |
throw new FileFormatException(e.getMessage()); |
290 |
|
} |
291 |
|
|
292 |
|
|
293 |
0 |
if (type == DataSourceType.PASTE) |
294 |
|
{ |
295 |
0 |
try |
296 |
|
{ |
297 |
|
|
298 |
0 |
alignFile = new FastaFile(">UNKNOWN\n" + inFile, |
299 |
|
DataSourceType.PASTE); |
300 |
0 |
return buildAlignmentFromFile(); |
301 |
|
|
302 |
|
} catch (Exception ex) |
303 |
|
{ |
304 |
0 |
if (ex.toString().startsWith(INVALID_CHARACTERS)) |
305 |
|
{ |
306 |
0 |
throw new IOException(e.getMessage()); |
307 |
|
} |
308 |
|
|
309 |
0 |
ex.printStackTrace(); |
310 |
|
} |
311 |
|
} |
312 |
|
|
313 |
|
|
314 |
0 |
throw new FileFormatException(getSupportedFormats()); |
315 |
|
} |
316 |
|
} |
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
@return |
323 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
324 |
227 |
private AlignmentI buildAlignmentFromFile()... |
325 |
|
{ |
326 |
|
|
327 |
|
|
328 |
|
|
329 |
227 |
AlignmentI al = new Alignment(alignFile.getSeqsAsArray()); |
330 |
|
|
331 |
227 |
alignFile.addAnnotations(al); |
332 |
|
|
333 |
227 |
alignFile.addGroups(al); |
334 |
|
|
335 |
227 |
return al; |
336 |
|
} |
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
@param |
342 |
|
@param |
343 |
|
@param |
344 |
|
@param |
345 |
|
@return |
346 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
347 |
1 |
public String formatSequences(FileFormatI format, boolean jvsuffix,... |
348 |
|
AlignmentViewPanel ap, boolean selectedOnly) |
349 |
|
{ |
350 |
|
|
351 |
1 |
AlignmentView selvew = ap.getAlignViewport() |
352 |
|
.getAlignmentView(selectedOnly, false); |
353 |
1 |
AlignmentI aselview = selvew |
354 |
|
.getVisibleAlignment(ap.getAlignViewport().getGapCharacter()); |
355 |
1 |
List<AlignmentAnnotation> ala = (ap.getAlignViewport() |
356 |
|
.getVisibleAlignmentAnnotation(selectedOnly)); |
357 |
1 |
if (ala != null) |
358 |
|
{ |
359 |
1 |
for (AlignmentAnnotation aa : ala) |
360 |
|
{ |
361 |
4 |
aselview.addAnnotation(aa); |
362 |
|
} |
363 |
|
} |
364 |
1 |
viewpanel = ap; |
365 |
1 |
return formatSequences(format, aselview, jvsuffix); |
366 |
|
} |
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
|
372 |
|
|
373 |
|
@param |
374 |
|
|
375 |
|
@param |
376 |
|
|
377 |
|
@param |
378 |
|
|
379 |
|
|
380 |
|
|
381 |
|
@return |
382 |
|
|
|
|
| 75% |
Uncovered Elements: 5 (20) |
Complexity: 6 |
Complexity Density: 0.38 |
|
383 |
51 |
public String formatSequences(FileFormatI format, AlignmentI alignment,... |
384 |
|
boolean jvsuffix) |
385 |
|
{ |
386 |
51 |
try |
387 |
|
{ |
388 |
51 |
AlignmentFileWriterI afile = format.getWriter(alignment); |
389 |
|
|
390 |
51 |
afile.setNewlineString(newline); |
391 |
51 |
afile.setExportSettings(exportSettings); |
392 |
51 |
afile.configureForView(viewpanel); |
393 |
|
|
394 |
|
|
395 |
|
|
396 |
51 |
SequenceI[] seqs = null; |
397 |
51 |
if (viewpanel == null || viewpanel.getAlignment() == null |
398 |
|
|| viewpanel.getAlignment() != alignment) |
399 |
|
{ |
400 |
48 |
seqs = alignment.getSequencesArray(); |
401 |
|
} |
402 |
|
else |
403 |
|
{ |
404 |
3 |
seqs = viewpanel.getAlignment().getSequencesArray(); |
405 |
|
} |
406 |
|
|
407 |
51 |
String afileresp = afile.print(seqs, jvsuffix); |
408 |
51 |
if (afile.hasWarningMessage()) |
409 |
|
{ |
410 |
0 |
System.err.println("Warning raised when writing as " + format |
411 |
|
+ " : " + afile.getWarningMessage()); |
412 |
|
} |
413 |
51 |
return afileresp; |
414 |
|
} catch (Exception e) |
415 |
|
{ |
416 |
0 |
System.err.println("Failed to write alignment as a '" |
417 |
|
+ format.getName() + "' file\n"); |
418 |
0 |
e.printStackTrace(); |
419 |
|
} |
420 |
|
|
421 |
0 |
return null; |
422 |
|
} |
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
@param |
432 |
|
@return |
433 |
|
|
|
|
| 70% |
Uncovered Elements: 6 (20) |
Complexity: 7 |
Complexity Density: 0.58 |
|
434 |
76 |
public static DataSourceType checkProtocol(Object dataObject)... |
435 |
|
{ |
436 |
76 |
if(dataObject instanceof File) |
437 |
0 |
return DataSourceType.FILE; |
438 |
|
|
439 |
76 |
String data = dataObject.toString(); |
440 |
76 |
DataSourceType protocol = DataSourceType.PASTE; |
441 |
76 |
String ft = data.toLowerCase().trim(); |
442 |
76 |
if (ft.indexOf("http:") == 0 || ft.indexOf("https:") == 0 |
443 |
|
|| ft.indexOf("file:") == 0) |
444 |
|
{ |
445 |
0 |
protocol = DataSourceType.URL; |
446 |
|
} |
447 |
76 |
else if (jalview.bin.Jalview.isJS()) |
448 |
|
{ |
449 |
0 |
protocol = DataSourceType.RELATIVE_URL; |
450 |
|
} |
451 |
76 |
else if (new File(data).exists()) |
452 |
|
{ |
453 |
67 |
protocol = DataSourceType.FILE; |
454 |
|
} |
455 |
76 |
return protocol; |
456 |
|
} |
457 |
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 6 |
Complexity Density: 0.22 |
|
458 |
0 |
public static void main(String[] args)... |
459 |
|
{ |
460 |
0 |
int i = 0; |
461 |
0 |
while (i < args.length) |
462 |
|
{ |
463 |
0 |
File f = new File(args[i]); |
464 |
0 |
if (f.exists()) |
465 |
|
{ |
466 |
0 |
try |
467 |
|
{ |
468 |
0 |
System.out.println("Reading file: " + f); |
469 |
0 |
AppletFormatAdapter afa = new AppletFormatAdapter(); |
470 |
0 |
Runtime r = Runtime.getRuntime(); |
471 |
0 |
System.gc(); |
472 |
0 |
long memf = -r.totalMemory() + r.freeMemory(); |
473 |
0 |
long t1 = -System.currentTimeMillis(); |
474 |
0 |
AlignmentI al = afa.readFile(args[i], DataSourceType.FILE, |
475 |
|
new IdentifyFile().identify(args[i], |
476 |
|
DataSourceType.FILE)); |
477 |
0 |
t1 += System.currentTimeMillis(); |
478 |
0 |
System.gc(); |
479 |
0 |
memf += r.totalMemory() - r.freeMemory(); |
480 |
0 |
if (al != null) |
481 |
|
{ |
482 |
0 |
System.out.println("Alignment contains " + al.getHeight() |
483 |
|
+ " sequences and " + al.getWidth() + " columns."); |
484 |
0 |
try |
485 |
|
{ |
486 |
0 |
System.out.println(new AppletFormatAdapter() |
487 |
|
.formatSequences(FileFormat.Fasta, al, true)); |
488 |
|
} catch (Exception e) |
489 |
|
{ |
490 |
0 |
System.err.println( |
491 |
|
"Couln't format the alignment for output as a FASTA file."); |
492 |
0 |
e.printStackTrace(System.err); |
493 |
|
} |
494 |
|
} |
495 |
|
else |
496 |
|
{ |
497 |
0 |
System.out.println("Couldn't read alignment"); |
498 |
|
} |
499 |
0 |
System.out.println("Read took " + (t1 / 1000.0) + " seconds."); |
500 |
0 |
System.out.println( |
501 |
|
"Difference between free memory now and before is " |
502 |
|
+ (memf / (1024.0 * 1024.0) * 1.0) + " MB"); |
503 |
|
} catch (Exception e) |
504 |
|
{ |
505 |
0 |
System.err.println("Exception when dealing with " + i |
506 |
|
+ "'th argument: " + args[i] + "\n" + e); |
507 |
|
} |
508 |
|
} |
509 |
|
else |
510 |
|
{ |
511 |
0 |
System.err.println("Ignoring argument '" + args[i] + "' (" + i |
512 |
|
+ "'th)- not a readable file."); |
513 |
|
} |
514 |
0 |
i++; |
515 |
|
} |
516 |
|
} |
517 |
|
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
@param |
523 |
|
@param |
524 |
|
@return |
525 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
526 |
0 |
public static DataSourceType resolveProtocol(String file,... |
527 |
|
FileFormatI format) |
528 |
|
{ |
529 |
0 |
return resolveProtocol(file, format, false); |
530 |
|
} |
531 |
|
|
|
|
| 0% |
Uncovered Elements: 109 (109) |
Complexity: 27 |
Complexity Density: 0.42 |
|
532 |
0 |
public static DataSourceType resolveProtocol(String file,... |
533 |
|
FileFormatI format, boolean debug) |
534 |
|
{ |
535 |
|
|
536 |
0 |
DataSourceType protocol = null; |
537 |
0 |
if (debug) |
538 |
|
{ |
539 |
0 |
System.out.println("resolving datasource started with:\n>>file\n" |
540 |
|
+ file + ">>endfile"); |
541 |
|
} |
542 |
|
|
543 |
|
|
544 |
|
|
545 |
0 |
try |
546 |
|
{ |
547 |
0 |
boolean rtn = false; |
548 |
0 |
InputStream is = System.getSecurityManager().getClass() |
549 |
|
.getResourceAsStream("/" + file); |
550 |
0 |
if (is != null) |
551 |
|
{ |
552 |
0 |
rtn = true; |
553 |
0 |
is.close(); |
554 |
|
} |
555 |
0 |
if (debug) |
556 |
|
{ |
557 |
0 |
System.err.println("Resource '" + file + "' was " |
558 |
0 |
+ (rtn ? "" : "not") + " located by classloader."); |
559 |
|
} |
560 |
0 |
if (rtn) |
561 |
|
{ |
562 |
0 |
protocol = DataSourceType.CLASSLOADER; |
563 |
|
} |
564 |
|
|
565 |
|
} catch (Exception ex) |
566 |
|
{ |
567 |
0 |
System.err |
568 |
|
.println("Exception checking resources: " + file + " " + ex); |
569 |
|
} |
570 |
|
|
571 |
0 |
if (file.indexOf("://") > -1) |
572 |
|
{ |
573 |
0 |
protocol = DataSourceType.URL; |
574 |
|
} |
575 |
|
else |
576 |
|
{ |
577 |
|
|
578 |
0 |
protocol = DataSourceType.FILE; |
579 |
|
} |
580 |
0 |
FileParse fp = null; |
581 |
0 |
try |
582 |
|
{ |
583 |
0 |
if (debug) |
584 |
|
{ |
585 |
0 |
System.out.println( |
586 |
|
"Trying to get contents of resource as " + protocol + ":"); |
587 |
|
} |
588 |
0 |
fp = new FileParse(file, protocol); |
589 |
0 |
if (!fp.isValid()) |
590 |
|
{ |
591 |
0 |
fp = null; |
592 |
|
} |
593 |
|
else |
594 |
|
{ |
595 |
0 |
if (debug) |
596 |
|
{ |
597 |
0 |
System.out.println("Successful."); |
598 |
|
} |
599 |
|
} |
600 |
|
} catch (Exception e) |
601 |
|
{ |
602 |
0 |
if (debug) |
603 |
|
{ |
604 |
0 |
System.err.println("Exception when accessing content: " + e); |
605 |
|
} |
606 |
0 |
fp = null; |
607 |
|
} |
608 |
0 |
if (fp == null) |
609 |
|
{ |
610 |
0 |
if (debug) |
611 |
|
{ |
612 |
0 |
System.out.println("Accessing as paste."); |
613 |
|
} |
614 |
0 |
protocol = DataSourceType.PASTE; |
615 |
0 |
fp = null; |
616 |
0 |
try |
617 |
|
{ |
618 |
0 |
fp = new FileParse(file, protocol); |
619 |
0 |
if (!fp.isValid()) |
620 |
|
{ |
621 |
0 |
fp = null; |
622 |
|
} |
623 |
|
} catch (Exception e) |
624 |
|
{ |
625 |
0 |
System.err.println("Failed to access content as paste!"); |
626 |
0 |
e.printStackTrace(); |
627 |
0 |
fp = null; |
628 |
|
} |
629 |
|
} |
630 |
0 |
if (fp == null) |
631 |
|
{ |
632 |
0 |
return null; |
633 |
|
} |
634 |
0 |
if (format == null) |
635 |
|
{ |
636 |
0 |
return protocol; |
637 |
|
} |
638 |
|
else |
639 |
|
{ |
640 |
0 |
try |
641 |
|
{ |
642 |
0 |
FileFormatI idformat = new IdentifyFile().identify(file, protocol); |
643 |
0 |
if (idformat == null) |
644 |
|
{ |
645 |
0 |
if (debug) |
646 |
|
{ |
647 |
0 |
System.out.println("Format not identified. Inaccessible file."); |
648 |
|
} |
649 |
0 |
return null; |
650 |
|
} |
651 |
0 |
if (debug) |
652 |
|
{ |
653 |
0 |
System.out.println("Format identified as " + idformat |
654 |
|
+ "and expected as " + format); |
655 |
|
} |
656 |
0 |
if (idformat.equals(format)) |
657 |
|
{ |
658 |
0 |
if (debug) |
659 |
|
{ |
660 |
0 |
System.out.println("Protocol identified as " + protocol); |
661 |
|
} |
662 |
0 |
return protocol; |
663 |
|
} |
664 |
|
else |
665 |
|
{ |
666 |
0 |
if (debug) |
667 |
|
{ |
668 |
0 |
System.out |
669 |
|
.println("File deemed not accessible via " + protocol); |
670 |
|
} |
671 |
0 |
fp.close(); |
672 |
0 |
return null; |
673 |
|
} |
674 |
|
} catch (Exception e) |
675 |
|
{ |
676 |
0 |
if (debug) |
677 |
|
{ |
678 |
0 |
System.err.println("File deemed not accessible via " + protocol); |
679 |
0 |
e.printStackTrace(); |
680 |
|
} |
681 |
|
} |
682 |
|
} |
683 |
0 |
return null; |
684 |
|
} |
685 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
686 |
73 |
public AlignmentFileReaderI getAlignFile()... |
687 |
|
{ |
688 |
73 |
return alignFile; |
689 |
|
} |
690 |
|
} |