X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FFileLoader.java;h=96ab8bbd60ce83c2daaa9ad7e8bbd22a7fc2ca7c;hb=9289ad58228571a63fdf54ef720603a590d58adc;hp=11432bd5c3f1ef09b365ae32228d3ccdbcbcb7bc;hpb=0b0b3d3687479204da2d199042c7bc90f3a6fd43;p=jalview.git diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 11432bd..96ab8bb 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -32,6 +32,7 @@ import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.AlignViewport; +import jalview.gui.BamFileOptionsChooser; import jalview.gui.Desktop; import jalview.gui.Jalview2XML; import jalview.gui.JvOptionPane; @@ -310,7 +311,34 @@ public class FileLoader implements Runnable if (FileFormat.Bam.equals(format)) { + FormatAdapter fa = new FormatAdapter(); + if (source == null) + { + fa.prepareFileReader(file, protocol, format); + source = fa.getAlignFile(); + } + + BamFileOptionsChooser bamoptions = new BamFileOptionsChooser( + source); + // ask the user which bit of the bam they want to load + int confirm = JvOptionPane.showConfirmDialog(null, + bamoptions, + MessageManager.getString("label.bam_file_options"), + JvOptionPane.OK_CANCEL_OPTION, + JvOptionPane.PLAIN_MESSAGE); + + if (confirm == JvOptionPane.CANCEL_OPTION + || confirm == JvOptionPane.CLOSED_OPTION) + { + Desktop.instance.stopLoading(); + return; + } + else + { + bamoptions.update(source); + al = fa.readFile(file, protocol, format); + } } if (FileFormat.Jalview.equals(format)) @@ -329,37 +357,40 @@ public class FileLoader implements Runnable String error = AppletFormatAdapter.getSupportedFormats(); try { - if (source != null) + if (al == null) { - // read from the provided source - al = new FormatAdapter().readFromFile(source, format); - } - else - { - - // open a new source and read from it - FormatAdapter fa = new FormatAdapter(); - boolean downloadStructureFile = format.isStructureFile() - && protocol.equals(DataSourceType.URL); - if (downloadStructureFile) + if (source != null) { - String structExt = format.getExtensions().split(",")[0]; - String urlLeafName = file.substring( - file.lastIndexOf( - System.getProperty("file.separator")), - file.lastIndexOf(".")); - String tempStructureFileStr = createNamedJvTempFile( - urlLeafName, structExt); - UrlDownloadClient.download(file, tempStructureFileStr); - al = fa.readFile(tempStructureFileStr, DataSourceType.FILE, - format); - source = fa.getAlignFile(); + // read from the provided source + al = new FormatAdapter().readFromFile(source, format); } else { - al = fa.readFile(file, protocol, format); - source = fa.getAlignFile(); // keep reference for later if - // necessary. + + // open a new source and read from it + FormatAdapter fa = new FormatAdapter(); + boolean downloadStructureFile = format.isStructureFile() + && protocol.equals(DataSourceType.URL); + if (downloadStructureFile) + { + String structExt = format.getExtensions().split(",")[0]; + String urlLeafName = file.substring( + file.lastIndexOf( + System.getProperty("file.separator")), + file.lastIndexOf(".")); + String tempStructureFileStr = createNamedJvTempFile( + urlLeafName, structExt); + UrlDownloadClient.download(file, tempStructureFileStr); + al = fa.readFile(tempStructureFileStr, DataSourceType.FILE, + format); + source = fa.getAlignFile(); + } + else + { + al = fa.readFile(file, protocol, format); + source = fa.getAlignFile(); // keep reference for later if + // necessary. + } } } } catch (java.io.IOException ex)