X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAlignViewport.java;h=d56764b0bec5879d701a374bb6a03851f51159ee;hb=9d465da4f21e403c20b835264929906b538c0c9b;hp=fea74db0ce48d12520463f6772638f8b1d854a22;hpb=a7bc89415a6749ff89eb97f75fbc950a433a4935;p=jalview.git diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index fea74db..d56764b 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -745,6 +745,11 @@ public class AlignViewport extends AlignmentViewport */ public void addFile(File file, FileFormatI format) { + addFile(file, format, true); + } + + public void addFile(File file, FileFormatI format, boolean async) + { DataSourceType protocol = AppletFormatAdapter.checkProtocol(file); if (format == null) @@ -769,7 +774,8 @@ public class AlignViewport extends AlignmentViewport } } - new FileLoader().LoadFile(this, file, DataSourceType.FILE, format); + new FileLoader().LoadFile(this, file, DataSourceType.FILE, format, + async); } public void addFile(File file) @@ -803,13 +809,10 @@ public class AlignViewport extends AlignmentViewport JvOptionPane dialog = JvOptionPane.newOptionDialog(Desktop.desktop) .setResponseHandler(0, () -> { addDataToAlignment(al); - return null; }).setResponseHandler(1, () -> { us.openLinkedAlignmentAs(al, title, true); - return null; }).setResponseHandler(2, () -> { us.openLinkedAlignmentAs(al, title, false); - return null; }); dialog.showDialog(question, MessageManager.getString("label.open_split_window"), @@ -827,18 +830,31 @@ public class AlignViewport extends AlignmentViewport AlignmentI thisAlignment = newWindowOrSplitPane ? new Alignment(getAlignment()) : getAlignment(); - AlignmentI protein = al.isNucleotide() ? thisAlignment : al; - final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment; - - /* - * Map sequences. At least one should get mapped as we have already passed - * the test for 'mappability'. Any mappings made will be added to the - * protein alignment. Note creating dataset sequences on the new alignment - * is a pre-requisite for building mappings. - */ + + // always create dataset for imported alignment before doing anything else.. al.setDataset(null); - AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna); + + if (!al.isNucleotide() && !thisAlignment.isNucleotide()) + { + // link AA to 3di or other kind of 'alternative' 1:1 mapping alignment + AlignmentUtils.map3diPeptideToProteinAligment(thisAlignment,al); + } + else + { + // link CODON triplets to Protein + AlignmentI protein = al.isNucleotide() ? thisAlignment : al; + final AlignmentI cdna = al.isNucleotide() ? al : thisAlignment; + + /* + * Map sequences. At least one should get mapped as we have already passed + * the test for 'mappability'. Any mappings made will be added to the + * protein alignment. Note creating dataset sequences on the new alignment + * is a pre-requisite for building mappings. + */ + AlignmentUtils.mapProteinAlignmentToCdna(protein, cdna); + } + /* * Create the AlignFrame for the added alignment. If it is protein, mappings * are registered with StructureSelectionManager as a side-effect. @@ -873,7 +889,7 @@ public class AlignViewport extends AlignmentViewport if (newWindowOrSplitPane) { al.alignAs(thisAlignment); - protein = openSplitFrame(newAlignFrame, thisAlignment); + AlignmentI mapped = openSplitFrame(newAlignFrame, thisAlignment); } } @@ -994,7 +1010,7 @@ public class AlignViewport extends AlignmentViewport */ protected boolean noReferencesTo(AlignedCodonFrame acf) { - AlignFrame[] frames = Desktop.getAlignFrames(); + AlignFrame[] frames = Desktop.getDesktopAlignFrames(); if (frames == null) { return true; @@ -1155,4 +1171,5 @@ public class AlignViewport extends AlignmentViewport { this.viewName = viewName; } + }