| 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.awt.Dimension; |
| 24 |
|
import java.io.File; |
| 25 |
|
import java.io.IOException; |
| 26 |
|
import java.util.StringTokenizer; |
| 27 |
|
import java.util.Vector; |
| 28 |
|
|
| 29 |
|
import javax.swing.SwingUtilities; |
| 30 |
|
|
| 31 |
|
import jalview.api.ComplexAlignFile; |
| 32 |
|
import jalview.api.FeatureSettingsModelI; |
| 33 |
|
import jalview.api.FeaturesDisplayedI; |
| 34 |
|
import jalview.api.FeaturesSourceI; |
| 35 |
|
import jalview.bin.Cache; |
| 36 |
|
import jalview.bin.Jalview; |
| 37 |
|
import jalview.datamodel.AlignmentI; |
| 38 |
|
import jalview.datamodel.HiddenColumns; |
| 39 |
|
import jalview.datamodel.PDBEntry; |
| 40 |
|
import jalview.datamodel.SequenceI; |
| 41 |
|
import jalview.gui.AlignFrame; |
| 42 |
|
import jalview.gui.AlignViewport; |
| 43 |
|
import jalview.gui.Desktop; |
| 44 |
|
import jalview.gui.JvOptionPane; |
| 45 |
|
import jalview.gui.QuitHandler; |
| 46 |
|
import jalview.json.binding.biojson.v1.ColourSchemeMapper; |
| 47 |
|
import jalview.project.Jalview2XML; |
| 48 |
|
import jalview.schemes.ColourSchemeI; |
| 49 |
|
import jalview.structure.StructureSelectionManager; |
| 50 |
|
import jalview.util.MessageManager; |
| 51 |
|
import jalview.util.Platform; |
| 52 |
|
import jalview.ws.utils.UrlDownloadClient; |
| 53 |
|
|
| 54 |
|
import java.util.ArrayList; |
| 55 |
|
import java.util.List; |
| |
|
| 64.3% |
Uncovered Elements: 117 (328) |
Complexity: 90 |
Complexity Density: 0.44 |
|
| 56 |
|
public class FileLoader implements Runnable |
| 57 |
|
{ |
| 58 |
|
private static final String TAB = "\t"; |
| 59 |
|
String file; |
| 60 |
|
|
| 61 |
|
DataSourceType protocol; |
| 62 |
|
|
| 63 |
|
FileFormatI format; |
| 64 |
|
|
| 65 |
|
AlignmentFileReaderI source = null; |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
AlignViewport viewport; |
| 71 |
|
|
| 72 |
|
AlignFrame alignFrame; |
| 73 |
|
|
| 74 |
|
long loadtime; |
| 75 |
|
|
| 76 |
|
long memused; |
| 77 |
|
|
| 78 |
|
boolean raiseGUI = true; |
| 79 |
|
|
| 80 |
|
private File selectedFile; |
| 81 |
|
|
| 82 |
|
private static boolean useDefaultFileFormat = false; |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 87 |
133 |
public FileLoader()... |
| 88 |
|
{ |
| 89 |
133 |
this(true); |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
@param |
| 96 |
|
|
| 97 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 98 |
457 |
public FileLoader(boolean raiseGUI)... |
| 99 |
|
{ |
| 100 |
457 |
this.raiseGUI = raiseGUI; |
| 101 |
|
} |
| 102 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 103 |
1 |
public void LoadFile(AlignViewport viewport, Object file,... |
| 104 |
|
DataSourceType protocol, FileFormatI format) |
| 105 |
|
{ |
| 106 |
1 |
LoadFile(viewport, file, protocol, format, true); |
| 107 |
|
} |
| 108 |
|
|
| |
|
| 57.1% |
Uncovered Elements: 3 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 109 |
19 |
public void LoadFile(AlignViewport viewport, Object file,... |
| 110 |
|
DataSourceType protocol, FileFormatI format, boolean async) |
| 111 |
|
{ |
| 112 |
19 |
this.viewport = viewport; |
| 113 |
19 |
if (file instanceof File) |
| 114 |
|
{ |
| 115 |
0 |
this.selectedFile = (File) file; |
| 116 |
0 |
file = selectedFile.getPath(); |
| 117 |
|
} |
| 118 |
19 |
LoadFile(file.toString(), protocol, format, async); |
| 119 |
|
} |
| 120 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 121 |
0 |
public void LoadFile(String file, DataSourceType protocol,... |
| 122 |
|
FileFormatI format) |
| 123 |
|
{ |
| 124 |
0 |
LoadFile(file, protocol, format, true); |
| 125 |
|
} |
| 126 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 127 |
19 |
public void LoadFile(String file, DataSourceType protocol,... |
| 128 |
|
FileFormatI format, boolean async) |
| 129 |
|
{ |
| 130 |
19 |
this.file = file; |
| 131 |
19 |
this.protocol = protocol; |
| 132 |
19 |
this.format = format; |
| 133 |
|
|
| 134 |
19 |
if (async) |
| 135 |
|
{ |
| 136 |
1 |
final Thread loader = new Thread(this); |
| 137 |
|
|
| 138 |
1 |
SwingUtilities.invokeLater(new Runnable() |
| 139 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 140 |
1 |
@Override... |
| 141 |
|
public void run() |
| 142 |
|
{ |
| 143 |
1 |
loader.start(); |
| 144 |
|
} |
| 145 |
|
}); |
| 146 |
|
} |
| 147 |
|
else |
| 148 |
|
{ |
| 149 |
18 |
this.run(); |
| 150 |
|
} |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
@param |
| 157 |
|
@param |
| 158 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 159 |
0 |
public void LoadFile(String file, DataSourceType protocol)... |
| 160 |
|
{ |
| 161 |
0 |
LoadFile(file, protocol, null); |
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
@param |
| 168 |
|
@param |
| 169 |
|
@return |
| 170 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 171 |
153 |
public AlignFrame LoadFileWaitTillLoaded(String file,... |
| 172 |
|
DataSourceType sourceType) |
| 173 |
|
{ |
| 174 |
153 |
return LoadFileWaitTillLoaded(file, sourceType, null); |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
@param |
| 181 |
|
@param |
| 182 |
|
@param |
| 183 |
|
@return |
| 184 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 185 |
326 |
public AlignFrame LoadFileWaitTillLoaded(String file,... |
| 186 |
|
DataSourceType sourceType, FileFormatI format) |
| 187 |
|
{ |
| 188 |
326 |
this.file = file; |
| 189 |
326 |
this.protocol = sourceType; |
| 190 |
326 |
this.format = format; |
| 191 |
326 |
return _LoadFileWaitTillLoaded(); |
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
@param |
| 198 |
|
@param |
| 199 |
|
@param |
| 200 |
|
@return |
| 201 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 202 |
6 |
public AlignFrame LoadFileWaitTillLoaded(File file,... |
| 203 |
|
DataSourceType sourceType, FileFormatI format) |
| 204 |
|
{ |
| 205 |
6 |
this.selectedFile = file; |
| 206 |
6 |
this.file = file.getPath(); |
| 207 |
6 |
this.protocol = sourceType; |
| 208 |
6 |
this.format = format; |
| 209 |
6 |
return _LoadFileWaitTillLoaded(); |
| 210 |
|
} |
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
@param |
| 216 |
|
@param |
| 217 |
|
@return |
| 218 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 219 |
0 |
public AlignFrame LoadFileWaitTillLoaded(AlignmentFileReaderI source,... |
| 220 |
|
FileFormatI format) |
| 221 |
|
{ |
| 222 |
0 |
this.source = source; |
| 223 |
|
|
| 224 |
0 |
file = source.getInFile(); |
| 225 |
0 |
protocol = source.getDataSourceType(); |
| 226 |
0 |
this.format = format; |
| 227 |
0 |
return _LoadFileWaitTillLoaded(); |
| 228 |
|
} |
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
@return |
| 235 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 236 |
332 |
protected AlignFrame _LoadFileWaitTillLoaded()... |
| 237 |
|
{ |
| 238 |
332 |
this.run(); |
| 239 |
|
|
| 240 |
332 |
return alignFrame; |
| 241 |
|
} |
| 242 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 243 |
0 |
public void LoadFileOntoAlignmentWaitTillLoaded(AlignViewport viewport,... |
| 244 |
|
String file, DataSourceType sourceType, FileFormatI format) |
| 245 |
|
{ |
| 246 |
0 |
Vector<String> recent = new Vector<>(); |
| 247 |
0 |
if (protocol == DataSourceType.PASTE) |
| 248 |
0 |
this.viewport = viewport; |
| 249 |
0 |
this.file = file; |
| 250 |
0 |
this.protocol = sourceType; |
| 251 |
0 |
this.format = format; |
| 252 |
0 |
_LoadFileWaitTillLoaded(); |
| 253 |
|
} |
| 254 |
|
|
| 255 |
|
|
| 256 |
|
|
| 257 |
|
|
| 258 |
|
|
| 259 |
|
|
| 260 |
|
|
| 261 |
|
|
| 262 |
|
@param |
| 263 |
|
@param |
| 264 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 11 |
Complexity Density: 0.52 |
|
| 265 |
355 |
public static String updateRecentlyOpened(String filePath,... |
| 266 |
|
DataSourceType sourceType) |
| 267 |
|
{ |
| 268 |
355 |
if (sourceType != DataSourceType.FILE |
| 269 |
|
&& sourceType != DataSourceType.URL) |
| 270 |
|
{ |
| 271 |
47 |
return null; |
| 272 |
|
} |
| 273 |
308 |
String propertyName = sourceType == DataSourceType.FILE ? "RECENT_FILE" |
| 274 |
|
: "RECENT_URL"; |
| 275 |
308 |
String historyItems = Cache.getProperty(propertyName); |
| 276 |
308 |
if (filePath != null |
| 277 |
|
&& filePath.indexOf(System.getProperty("java.io.tmpdir")) > -1) |
| 278 |
|
{ |
| 279 |
|
|
| 280 |
22 |
return null; |
| 281 |
|
} |
| 282 |
|
|
| 283 |
286 |
List<String> recent = new ArrayList<>(); |
| 284 |
|
|
| 285 |
286 |
if (historyItems != null) |
| 286 |
|
{ |
| 287 |
266 |
StringTokenizer st = new StringTokenizer(historyItems, TAB); |
| 288 |
|
|
| 289 |
2125 |
while (st.hasMoreTokens()) |
| 290 |
|
{ |
| 291 |
1859 |
String trimmed = st.nextToken().trim(); |
| 292 |
1859 |
recent.add(trimmed); |
| 293 |
|
} |
| 294 |
|
} |
| 295 |
|
|
| 296 |
|
|
| 297 |
|
|
| 298 |
|
|
| 299 |
286 |
if (recent.contains(filePath)) |
| 300 |
|
{ |
| 301 |
163 |
recent.remove(filePath); |
| 302 |
|
} |
| 303 |
|
|
| 304 |
286 |
StringBuilder newHistory = new StringBuilder(filePath); |
| 305 |
1945 |
for (int i = 0; i < recent.size() && i < 10; i++) |
| 306 |
|
{ |
| 307 |
1659 |
newHistory.append(TAB); |
| 308 |
1659 |
newHistory.append(recent.get(i)); |
| 309 |
|
} |
| 310 |
|
|
| 311 |
286 |
String newProperty = newHistory.toString(); |
| 312 |
286 |
Cache.setProperty(propertyName, newProperty); |
| 313 |
|
|
| 314 |
286 |
return newProperty; |
| 315 |
|
} |
| 316 |
|
|
| |
|
| 59.4% |
Uncovered Elements: 78 (192) |
Complexity: 50 |
Complexity Density: 0.41 |
|
| 317 |
351 |
@Override... |
| 318 |
|
public void run() |
| 319 |
|
{ |
| 320 |
351 |
String title = protocol == DataSourceType.PASTE |
| 321 |
|
? "Copied From Clipboard" |
| 322 |
|
: file; |
| 323 |
351 |
Runtime rt = Runtime.getRuntime(); |
| 324 |
|
|
| 325 |
351 |
try |
| 326 |
|
{ |
| 327 |
351 |
if (Desktop.getInstance() != null) |
| 328 |
|
{ |
| 329 |
303 |
Desktop.getInstance().startLoading(file); |
| 330 |
|
} |
| 331 |
351 |
if (format == null) |
| 332 |
|
{ |
| 333 |
|
|
| 334 |
171 |
if (source != null) |
| 335 |
|
{ |
| 336 |
0 |
format = new IdentifyFile().identify(source, false); |
| 337 |
|
|
| 338 |
|
} |
| 339 |
171 |
else if (selectedFile != null) |
| 340 |
|
{ |
| 341 |
0 |
format = new IdentifyFile().identify(selectedFile, protocol); |
| 342 |
|
} |
| 343 |
|
else |
| 344 |
|
{ |
| 345 |
171 |
format = new IdentifyFile().identify(file, protocol); |
| 346 |
|
} |
| 347 |
|
|
| 348 |
|
} |
| 349 |
|
|
| 350 |
351 |
if (format == null) |
| 351 |
|
{ |
| 352 |
0 |
Desktop.getInstance().stopLoading(); |
| 353 |
0 |
jalview.bin.Console.errPrintln("The input file \"" + file |
| 354 |
|
+ "\" has null or unidentifiable data content!"); |
| 355 |
0 |
if (!Jalview.isHeadlessMode() && !Jalview.isBatchMode()) |
| 356 |
|
{ |
| 357 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(), |
| 358 |
|
MessageManager.getString("label.couldnt_read_data") |
| 359 |
|
+ " in " + file + "\n" |
| 360 |
|
+ AppletFormatAdapter.getSupportedFormats(), |
| 361 |
|
MessageManager.getString("label.couldnt_read_data"), |
| 362 |
|
JvOptionPane.WARNING_MESSAGE); |
| 363 |
|
} |
| 364 |
|
|
| 365 |
|
|
| 366 |
0 |
return; |
| 367 |
|
} |
| 368 |
|
|
| 369 |
|
|
| 370 |
351 |
if (Desktop.getDesktopPane() != null && Desktop.getDesktopPane().isShowMemoryUsage()) |
| 371 |
|
{ |
| 372 |
0 |
System.gc(); |
| 373 |
0 |
memused = (rt.maxMemory() - rt.totalMemory() + rt.freeMemory()); |
| 374 |
|
|
| 375 |
|
|
| 376 |
|
|
| 377 |
|
} |
| 378 |
351 |
loadtime = -System.currentTimeMillis(); |
| 379 |
351 |
AlignmentI al = null; |
| 380 |
|
|
| 381 |
351 |
if (FileFormat.Jalview.equals(format)) |
| 382 |
|
{ |
| 383 |
40 |
if (source != null) |
| 384 |
|
{ |
| 385 |
|
|
| 386 |
0 |
jalview.bin.Console.errPrintln( |
| 387 |
|
"IMPLEMENTATION ERROR: Cannot read consecutive Jalview XML projects from a stream."); |
| 388 |
|
|
| 389 |
|
} |
| 390 |
|
|
| 391 |
40 |
alignFrame = new Jalview2XML(raiseGUI && !Jalview.isBatchMode()) |
| 392 |
|
.loadJalviewAlign( |
| 393 |
40 |
selectedFile == null ? file : selectedFile); |
| 394 |
|
} |
| 395 |
|
else |
| 396 |
|
{ |
| 397 |
311 |
String error = AppletFormatAdapter.getSupportedFormats(); |
| 398 |
311 |
try |
| 399 |
|
{ |
| 400 |
311 |
if (source != null) |
| 401 |
|
{ |
| 402 |
|
|
| 403 |
0 |
al = new FormatAdapter().readFromFile(source, format); |
| 404 |
|
} |
| 405 |
|
else |
| 406 |
|
{ |
| 407 |
|
|
| 408 |
|
|
| 409 |
311 |
FormatAdapter fa = new FormatAdapter(); |
| 410 |
311 |
boolean downloadStructureFile = format.isStructureFile() |
| 411 |
|
&& protocol.equals(DataSourceType.URL); |
| 412 |
311 |
if (downloadStructureFile) |
| 413 |
|
{ |
| 414 |
|
|
| 415 |
|
|
| 416 |
|
|
| 417 |
0 |
String structExt = format.getExtensions().split(",")[0]; |
| 418 |
0 |
String urlLeafName = file.substring( |
| 419 |
|
file.lastIndexOf( |
| 420 |
|
System.getProperty("file.separator")), |
| 421 |
|
file.lastIndexOf(".")); |
| 422 |
0 |
String tempStructureFileStr = createNamedJvTempFile( |
| 423 |
|
urlLeafName, structExt); |
| 424 |
|
|
| 425 |
|
|
| 426 |
|
|
| 427 |
0 |
File tempFile = new File(tempStructureFileStr); |
| 428 |
0 |
UrlDownloadClient.download(file, tempFile); |
| 429 |
|
|
| 430 |
0 |
al = fa.readFile(tempFile, DataSourceType.FILE, format); |
| 431 |
0 |
source = fa.getAlignFile(); |
| 432 |
|
} |
| 433 |
|
else |
| 434 |
|
{ |
| 435 |
311 |
if (selectedFile == null) |
| 436 |
|
{ |
| 437 |
305 |
al = fa.readFile(null, file, protocol, format); |
| 438 |
|
|
| 439 |
|
} |
| 440 |
|
else |
| 441 |
|
{ |
| 442 |
6 |
al = fa.readFile(selectedFile, null, protocol, format); |
| 443 |
|
} |
| 444 |
311 |
source = fa.getAlignFile(); |
| 445 |
|
|
| 446 |
|
|
| 447 |
|
} |
| 448 |
|
} |
| 449 |
|
} catch (java.io.IOException ex) |
| 450 |
|
{ |
| 451 |
0 |
error = ex.getMessage(); |
| 452 |
|
} |
| 453 |
|
|
| 454 |
311 |
if ((al != null) && (al.getHeight() > 0) && al.hasValidSequence()) |
| 455 |
|
{ |
| 456 |
|
|
| 457 |
311 |
for (SequenceI sq : al.getSequences()) |
| 458 |
|
{ |
| 459 |
2524 |
while (sq.getDatasetSequence() != null) |
| 460 |
|
{ |
| 461 |
3 |
sq = sq.getDatasetSequence(); |
| 462 |
|
} |
| 463 |
2521 |
if (sq.getAllPDBEntries() != null) |
| 464 |
|
{ |
| 465 |
2521 |
for (PDBEntry pdbe : sq.getAllPDBEntries()) |
| 466 |
|
{ |
| 467 |
|
|
| 468 |
|
|
| 469 |
36 |
StructureSelectionManager |
| 470 |
|
.getStructureSelectionManager(Desktop.getInstance()) |
| 471 |
|
.registerPDBEntry(pdbe); |
| 472 |
|
} |
| 473 |
|
} |
| 474 |
|
} |
| 475 |
|
|
| 476 |
311 |
FeatureSettingsModelI proxyColourScheme = source |
| 477 |
|
.getFeatureColourScheme(); |
| 478 |
311 |
if (viewport != null) |
| 479 |
|
{ |
| 480 |
|
|
| 481 |
19 |
viewport.addAlignment(al, title); |
| 482 |
19 |
if (proxyColourScheme != null) |
| 483 |
|
{ |
| 484 |
1 |
viewport.applyFeaturesStyle(proxyColourScheme); |
| 485 |
|
} |
| 486 |
19 |
if (source instanceof HMMFile) |
| 487 |
|
{ |
| 488 |
0 |
AlignmentI alignment = viewport.getAlignment(); |
| 489 |
0 |
SequenceI seq = alignment |
| 490 |
|
.getSequenceAt(alignment.getHeight() - 1); |
| 491 |
0 |
if (seq.hasHMMProfile()) |
| 492 |
|
{ |
| 493 |
|
|
| 494 |
|
|
| 495 |
|
|
| 496 |
0 |
alignment.deleteSequence(alignment.getAbsoluteHeight() - 1); |
| 497 |
0 |
alignment.insertSequenceAt(0, seq); |
| 498 |
|
} |
| 499 |
0 |
viewport.getAlignPanel().adjustAnnotationHeight(); |
| 500 |
0 |
viewport.updateSequenceIdColours(); |
| 501 |
|
} |
| 502 |
|
} |
| 503 |
|
else |
| 504 |
|
{ |
| 505 |
|
|
| 506 |
|
|
| 507 |
292 |
if (source instanceof ComplexAlignFile) |
| 508 |
|
{ |
| 509 |
0 |
HiddenColumns colSel = ((ComplexAlignFile) source) |
| 510 |
|
.getHiddenColumns(); |
| 511 |
0 |
SequenceI[] hiddenSeqs = ((ComplexAlignFile) source) |
| 512 |
|
.getHiddenSequences(); |
| 513 |
0 |
String colourSchemeName = ((ComplexAlignFile) source) |
| 514 |
|
.getGlobalColourScheme(); |
| 515 |
0 |
FeaturesDisplayedI fd = ((ComplexAlignFile) source) |
| 516 |
|
.getDisplayedFeatures(); |
| 517 |
0 |
alignFrame = new AlignFrame(al, hiddenSeqs, colSel, |
| 518 |
|
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); |
| 519 |
0 |
alignFrame.getViewport().setFeaturesDisplayed(fd); |
| 520 |
0 |
alignFrame.getViewport().setShowSequenceFeatures( |
| 521 |
|
((ComplexAlignFile) source).isShowSeqFeatures()); |
| 522 |
0 |
ColourSchemeI cs = ColourSchemeMapper |
| 523 |
|
.getJalviewColourScheme(colourSchemeName, al); |
| 524 |
0 |
if (cs != null) |
| 525 |
|
{ |
| 526 |
0 |
alignFrame.changeColour(cs); |
| 527 |
|
} |
| 528 |
|
} |
| 529 |
|
else |
| 530 |
|
{ |
| 531 |
292 |
alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, |
| 532 |
|
AlignFrame.DEFAULT_HEIGHT); |
| 533 |
292 |
if (source instanceof FeaturesSourceI) |
| 534 |
|
{ |
| 535 |
1 |
alignFrame.getViewport().setShowSequenceFeatures(true); |
| 536 |
|
} |
| 537 |
|
} |
| 538 |
|
|
| 539 |
292 |
if (!(protocol == DataSourceType.PASTE)) |
| 540 |
|
{ |
| 541 |
245 |
alignFrame.setFile(file, selectedFile, protocol, format); |
| 542 |
|
} |
| 543 |
292 |
if (proxyColourScheme != null) |
| 544 |
|
{ |
| 545 |
12 |
alignFrame.getViewport() |
| 546 |
|
.applyFeaturesStyle(proxyColourScheme); |
| 547 |
|
} |
| 548 |
292 |
alignFrame.setStatus(MessageManager.formatMessage( |
| 549 |
|
"label.successfully_loaded_file", new String[] |
| 550 |
|
{ title })); |
| 551 |
|
|
| 552 |
292 |
if (raiseGUI) |
| 553 |
|
{ |
| 554 |
|
|
| 555 |
|
|
| 556 |
|
|
| 557 |
|
|
| 558 |
|
|
| 559 |
|
|
| 560 |
243 |
Dimension dim = Platform.getDimIfEmbedded(alignFrame, |
| 561 |
|
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); |
| 562 |
|
|
| 563 |
|
|
| 564 |
|
|
| 565 |
|
|
| 566 |
|
|
| 567 |
243 |
alignFrame.setSize(dim); |
| 568 |
243 |
Desktop.addInternalFrame(alignFrame, title, dim.width, |
| 569 |
|
dim.height); |
| 570 |
243 |
alignFrame.alignPanel.setOverviewTitle(alignFrame); |
| 571 |
|
|
| 572 |
|
} |
| 573 |
|
|
| 574 |
292 |
try |
| 575 |
|
{ |
| 576 |
292 |
alignFrame.setMaximum( |
| 577 |
|
Cache.getDefault("SHOW_FULLSCREEN", false)); |
| 578 |
|
} catch (java.beans.PropertyVetoException ex) |
| 579 |
|
{ |
| 580 |
|
} |
| 581 |
|
} |
| 582 |
311 |
alignFrame.alignPanel.alignmentChanged(); |
| 583 |
|
} |
| 584 |
|
else |
| 585 |
|
{ |
| 586 |
0 |
if (Desktop.getInstance() != null) |
| 587 |
|
{ |
| 588 |
0 |
Desktop.getInstance().stopLoading(); |
| 589 |
|
} |
| 590 |
|
|
| 591 |
0 |
final String errorMessage = MessageManager.getString( |
| 592 |
|
"label.couldnt_load_file") + " " + title + "\n" + error; |
| 593 |
|
|
| 594 |
|
|
| 595 |
0 |
if (raiseGUI && !Jalview.getInstance().isBatchMode() && Desktop.getInstance().getDesktopPane() != null) |
| 596 |
|
{ |
| 597 |
0 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
| 598 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 599 |
0 |
@Override... |
| 600 |
|
public void run() |
| 601 |
|
{ |
| 602 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(), |
| 603 |
|
errorMessage, |
| 604 |
|
MessageManager |
| 605 |
|
.getString("label.error_loading_file"), |
| 606 |
|
JvOptionPane.WARNING_MESSAGE); |
| 607 |
|
} |
| 608 |
|
}); |
| 609 |
|
} |
| 610 |
|
else |
| 611 |
|
{ |
| 612 |
0 |
jalview.bin.Console.errPrintln(errorMessage); |
| 613 |
|
} |
| 614 |
|
} |
| 615 |
|
} |
| 616 |
|
|
| 617 |
332 |
updateRecentlyOpened(file, protocol); |
| 618 |
|
|
| 619 |
332 |
if (protocol == DataSourceType.FILE && format != null) |
| 620 |
|
{ |
| 621 |
282 |
Cache.setProperty("DEFAULT_FILE_FORMAT", format.getName()); |
| 622 |
|
} |
| 623 |
|
|
| 624 |
|
} catch (Exception er) |
| 625 |
|
{ |
| 626 |
19 |
jalview.bin.Console |
| 627 |
|
.errPrintln("Exception whilst opening file '" + file); |
| 628 |
19 |
er.printStackTrace(); |
| 629 |
19 |
if (raiseGUI && !Jalview.isBatchMode()) |
| 630 |
|
{ |
| 631 |
1 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
| 632 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 633 |
1 |
@Override... |
| 634 |
|
public void run() |
| 635 |
|
{ |
| 636 |
1 |
JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(), |
| 637 |
|
MessageManager.formatMessage( |
| 638 |
|
"label.problems_opening_file", new String[] |
| 639 |
|
{ file }), |
| 640 |
|
MessageManager.getString("label.file_open_error"), |
| 641 |
|
JvOptionPane.WARNING_MESSAGE); |
| 642 |
|
} |
| 643 |
|
}); |
| 644 |
|
} |
| 645 |
19 |
alignFrame = null; |
| 646 |
|
} catch (OutOfMemoryError er) |
| 647 |
|
{ |
| 648 |
|
|
| 649 |
0 |
er.printStackTrace(); |
| 650 |
0 |
alignFrame = null; |
| 651 |
0 |
if (raiseGUI && !Jalview.isBatchMode()) |
| 652 |
|
{ |
| 653 |
0 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
| 654 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 655 |
0 |
@Override... |
| 656 |
|
public void run() |
| 657 |
|
{ |
| 658 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(), |
| 659 |
|
MessageManager.formatMessage( |
| 660 |
|
"warn.out_of_memory_loading_file", new String[] |
| 661 |
|
{ file }), |
| 662 |
|
MessageManager.getString("label.out_of_memory"), |
| 663 |
|
JvOptionPane.WARNING_MESSAGE); |
| 664 |
|
} |
| 665 |
|
}); |
| 666 |
|
} |
| 667 |
0 |
jalview.bin.Console |
| 668 |
|
.errPrintln("Out of memory loading file " + file + "!!"); |
| 669 |
|
|
| 670 |
|
} |
| 671 |
351 |
loadtime += System.currentTimeMillis(); |
| 672 |
|
|
| 673 |
|
|
| 674 |
|
|
| 675 |
351 |
memused = memused |
| 676 |
|
- (rt.maxMemory() - rt.totalMemory() + rt.freeMemory()); |
| 677 |
|
|
| 678 |
|
|
| 679 |
|
|
| 680 |
|
|
| 681 |
351 |
if (Desktop.getDesktopPane() != null && Desktop.getDesktopPane().isShowMemoryUsage()) |
| 682 |
|
{ |
| 683 |
0 |
if (alignFrame != null) |
| 684 |
|
{ |
| 685 |
0 |
AlignmentI al = alignFrame.getViewport().getAlignment(); |
| 686 |
|
|
| 687 |
0 |
jalview.bin.Console.outPrintln("Loaded '" + title + "' in " |
| 688 |
|
+ (loadtime / 1000.0) + "s, took an additional " |
| 689 |
|
+ (1.0 * memused / (1024.0 * 1024.0)) + " MB (" |
| 690 |
|
+ al.getHeight() + " seqs by " + al.getWidth() + " cols)"); |
| 691 |
|
} |
| 692 |
|
else |
| 693 |
|
{ |
| 694 |
|
|
| 695 |
|
|
| 696 |
0 |
jalview.bin.Console.outPrintln("Failed to load '" + title + "' in " |
| 697 |
|
+ (loadtime / 1000.0) + "s, took an additional " |
| 698 |
|
+ (1.0 * memused / (1024.0 * 1024.0)) |
| 699 |
|
+ " MB (alignment is null)"); |
| 700 |
|
} |
| 701 |
|
} |
| 702 |
|
|
| 703 |
351 |
if (Desktop.getInstance() != null) |
| 704 |
|
{ |
| 705 |
303 |
Desktop.getInstance().stopLoading(); |
| 706 |
|
} |
| 707 |
|
|
| 708 |
351 |
this.setShouldBeSaved(); |
| 709 |
|
|
| 710 |
351 |
useDefaultFileFormat = true; |
| 711 |
|
} |
| 712 |
|
|
| 713 |
|
|
| 714 |
|
|
| 715 |
|
|
| 716 |
|
|
| 717 |
|
|
| 718 |
|
@param |
| 719 |
|
|
| 720 |
|
@param |
| 721 |
|
|
| 722 |
|
@return |
| 723 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 724 |
0 |
private static String createNamedJvTempFile(String fileName,... |
| 725 |
|
String extension) throws IOException |
| 726 |
|
{ |
| 727 |
0 |
String seprator = System.getProperty("file.separator"); |
| 728 |
0 |
String jvTempDir = System.getProperty("java.io.tmpdir") + "jalview" |
| 729 |
|
+ seprator + System.currentTimeMillis(); |
| 730 |
0 |
File tempStructFile = new File( |
| 731 |
|
jvTempDir + seprator + fileName + "." + extension); |
| 732 |
0 |
tempStructFile.mkdirs(); |
| 733 |
0 |
return tempStructFile.toString(); |
| 734 |
|
} |
| 735 |
|
|
| 736 |
|
|
| 737 |
|
|
| 738 |
|
|
| |
|
| 72.7% |
Uncovered Elements: 6 (22) |
Complexity: 7 |
Complexity Density: 0.58 |
|
| 739 |
351 |
private void setShouldBeSaved()... |
| 740 |
|
{ |
| 741 |
351 |
if (protocol == null) |
| 742 |
0 |
return; |
| 743 |
351 |
AlignFrame af = this.alignFrame; |
| 744 |
351 |
if (af == null) |
| 745 |
19 |
return; |
| 746 |
332 |
AlignViewport avp = af.getViewport(); |
| 747 |
332 |
if (avp == null) |
| 748 |
0 |
return; |
| 749 |
332 |
boolean upToDate = !protocol.isDynamic(); |
| 750 |
332 |
if (protocol.isUrl() && !Cache |
| 751 |
|
.getDefault(PROMPT_SAVE_UNCHANGED_URL_ALIGNMENTS, true)) |
| 752 |
|
{ |
| 753 |
0 |
upToDate = true; |
| 754 |
|
} |
| 755 |
332 |
avp.setSavedUpToDate(upToDate, |
| 756 |
332 |
upToDate ? null : QuitHandler.Message.UNSAVED_ALIGNMENTS); |
| 757 |
|
} |
| 758 |
|
|
| 759 |
|
public static final String PROMPT_SAVE_UNCHANGED_URL_ALIGNMENTS = "PROMPT_SAVE_UNCHANGED_URL_ALIGNMENTS"; |
| 760 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 761 |
22 |
public static boolean getUseDefaultFileFormat()... |
| 762 |
|
{ |
| 763 |
22 |
return useDefaultFileFormat; |
| 764 |
|
} |
| 765 |
|
|
| 766 |
|
} |