X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFileLoader.java;fp=src%2Fjalview%2Fio%2FFileLoader.java;h=8eb60e5dd33178a656ae8987b5efa18d14207d87;hb=2e9e0527943d0c42a6059ebbb8e7e69346c38206;hp=f26d6dab6495e2270ece311216423b9b1dbdab11;hpb=e4843176d8337fc165c1b93ae6c161cb29521f6d;p=jalview.git diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index f26d6da..8eb60e5 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; @@ -308,6 +309,43 @@ public class FileLoader implements Runnable loadtime = -System.currentTimeMillis(); AlignmentI al = null; + if (FileFormat.Bam.equals(format)) + { + FormatAdapter fa = new FormatAdapter(); + if (source == null) + { + fa.prepareFileReader(file, protocol, format); + source = fa.getAlignFile(); + } + if (!((BamFile) source).parseSuffix()) + { + // configure a window + 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); + if (file.indexOf("#") == -1) + { + file = file + "#" + ((BamFile) source).suffix; + } + } + } + al = fa.readFile(file, protocol, format); + } + if (FileFormat.Jalview.equals(format)) { if (source != null) @@ -324,37 +362,40 @@ public class FileLoader implements Runnable String error = AppletFormatAdapter.getSupportedFormats(); try { - if (source != null) - { - // read from the provided source - al = new FormatAdapter().readFromFile(source, format); - } - else + if (al == null) { - - // 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)