From: tcofoegbu Date: Thu, 3 Sep 2015 10:27:46 +0000 (+0100) Subject: JAL-793 use default custom export settings for html exports X-Git-Tag: Release_2_10_0~508 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=02d6b4895305788dbf460a6e0334dba93b0b3423;p=jalview.git JAL-793 use default custom export settings for html exports --- diff --git a/examples/example.json b/examples/example.json index 92d691b..5f6e784 100644 --- a/examples/example.json +++ b/examples/example.json @@ -1 +1 @@ -{"seqs":[{"name":"FER_CAPAN/3-34","start":3,"svid":"1.0","end":34,"id":"1665704504","seq":"SVSATMISTSFMPRKPAVTSL-KPIPNVGE--ALF","order":1},{"name":"FER1_SOLLC/3-34","start":3,"svid":"1.0","end":34,"id":"1003594867","seq":"SISGTMISTSFLPRKPAVTSL-KAISNVGE--ALF","order":2},{"name":"Q93XJ9_SOLTU/3-34","start":3,"svid":"1.0","end":34,"id":"1332961135","seq":"SISGTMISTSFLPRKPVVTSL-KAISNVGE--ALF","order":3},{"name":"FER1_PEA/6-37","start":6,"svid":"1.0","end":37,"id":"1335040546","seq":"ALYGTAVSTSFLRTQPMPMSV-TTTKAFSN--GFL","order":4},{"name":"Q7XA98_TRIPR/6-39","start":6,"svid":"1.0","end":39,"id":"1777084554","seq":"ALYGTAVSTSFMRRQPVPMSV-ATTTTTKAFPSGF","order":5},{"name":"FER_TOCH/3-34","start":3,"svid":"1.0","end":34,"id":"823528539","seq":"FILGTMISKSFLFRKPAVTSL-KAISNVGE--ALF","order":6}],"appSettings":{"globalColorScheme":"zappo","webStartUrl":"www.jalview.org/services/launchApp","application":"Jalview","hiddenSeqs":"823528539","showSeqFeatures":"true","version":"2.9","hiddenCols":"32-33;34-34"},"seqGroups":[{"displayText":true,"startRes":21,"groupName":"JGroup:1883305585","endRes":29,"colourText":false,"seqsHash":["1003594867","1332961135","1335040546","1777084554"],"svid":"1.0","showNonconserved":false,"colourScheme":"Zappo","displayBoxes":true}],"alignAnnotation":[{"svid":"1.0","annotations":[{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"}],"description":"New description","label":"Secondary Structure"}],"svid":"1.0","seqFeatures":[{"fillColor":"#7d1633","score":0,"sequenceRef":"1332961135","featureGroup":"Jalview","svid":"1.0","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"},{"fillColor":"#7d1633","score":0,"sequenceRef":"1335040546","featureGroup":"Jalview","svid":"1.0","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"},{"fillColor":"#7d1633","score":0,"sequenceRef":"1777084554","featureGroup":"Jalview","svid":"1.0","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"}]} \ No newline at end of file +{"seqs":[{"name":"FER_CAPAN/3-34","start":3,"svid":"1.0","end":34,"id":"1665704504","seq":"SVSATMISTSFMPRKPAVTSL-KPIPNVGE--ALF","order":1},{"name":"FER1_SOLLC/3-34","start":3,"svid":"1.0","end":34,"id":"1003594867","seq":"SISGTMISTSFLPRKPAVTSL-KAISNVGE--ALF","order":2},{"name":"Q93XJ9_SOLTU/3-34","start":3,"svid":"1.0","end":34,"id":"1332961135","seq":"SISGTMISTSFLPRKPVVTSL-KAISNVGE--ALF","order":3},{"name":"FER1_PEA/6-37","start":6,"svid":"1.0","end":37,"id":"1335040546","seq":"ALYGTAVSTSFLRTQPMPMSV-TTTKAFSN--GFL","order":4},{"name":"Q7XA98_TRIPR/6-39","start":6,"svid":"1.0","end":39,"id":"1777084554","seq":"ALYGTAVSTSFMRRQPVPMSV-ATTTTTKAFPSGF","order":5},{"name":"FER_TOCH/3-34","start":3,"svid":"1.0","end":34,"id":"823528539","seq":"FILGTMISKSFLFRKPAVTSL-KAISNVGE--ALF","order":6}],"appSettings":{"globalColorScheme":"zappo","webStartUrl":"www.jalview.org/services/launchApp","application":"Jalview","hiddenSeqs":"823528539","showSeqFeatures":"true","version":"2.9","hiddenCols":"32-33;34-34"},"seqGroups":[{"displayText":true,"startRes":21,"groupName":"JGroup:1883305585","endRes":29,"colourText":false,"sequenceRefs":["1003594867","1332961135","1335040546","1777084554"],"svid":"1.0","showNonconserved":false,"colourScheme":"Zappo","displayBoxes":true}],"alignAnnotation":[{"svid":"1.0","annotations":[{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"β","value":0,"secondaryStructure":"E"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"α","value":0,"secondaryStructure":"H"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"},{"displayCharacter":"","value":0,"secondaryStructure":"\u0000"}],"description":"New description","label":"Secondary Structure"}],"svid":"1.0","seqFeatures":[{"fillColor":"#7d1633","score":0,"sequenceRef":"1332961135","featureGroup":"Jalview","svid":"1.0","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"},{"fillColor":"#7d1633","score":0,"sequenceRef":"1335040546","featureGroup":"Jalview","svid":"1.0","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"},{"fillColor":"#7d1633","score":0,"sequenceRef":"1777084554","featureGroup":"Jalview","svid":"1.0","description":"desciption","xStart":3,"xEnd":13,"type":"feature_x"}]} \ No newline at end of file diff --git a/src/jalview/api/AlignExportSettingI.java b/src/jalview/api/AlignExportSettingI.java index 9b67cf5..18f529b 100644 --- a/src/jalview/api/AlignExportSettingI.java +++ b/src/jalview/api/AlignExportSettingI.java @@ -68,4 +68,6 @@ public interface AlignExportSettingI */ public boolean isExportGroups(); + public boolean isCancelled(); + } diff --git a/src/jalview/datamodel/AlignmentExportData.java b/src/jalview/datamodel/AlignmentExportData.java index 46da85d..ff550ea 100644 --- a/src/jalview/datamodel/AlignmentExportData.java +++ b/src/jalview/datamodel/AlignmentExportData.java @@ -1,6 +1,7 @@ package jalview.datamodel; -import jalview.gui.AlignExportSettings; +import jalview.api.AlignExportSettingI; + public class AlignmentExportData { @@ -10,10 +11,10 @@ public class AlignmentExportData private int[] startEnd; - private AlignExportSettings settings; + private AlignExportSettingI settings; public AlignmentExportData(AlignmentI align, String[] ommit, - int[] startEnd, AlignExportSettings settings) + int[] startEnd, AlignExportSettingI settings) { this.alignment = align; this.omitHidden = ommit; @@ -51,12 +52,12 @@ public class AlignmentExportData this.startEnd = startEnd; } - public AlignExportSettings getSettings() + public AlignExportSettingI getSettings() { return settings; } - public void setSettings(AlignExportSettings settings) + public void setSettings(AlignExportSettingI settings) { this.settings = settings; } diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index bdcf8a4..809609a 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -28,6 +28,7 @@ import jalview.analysis.CrossRef; import jalview.analysis.Dna; import jalview.analysis.ParseProperties; import jalview.analysis.SequenceIdMatcher; +import jalview.api.AlignExportSettingI; import jalview.api.AlignViewControllerGuiI; import jalview.api.AlignViewControllerI; import jalview.api.AlignViewportI; @@ -1147,7 +1148,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return false; } - AlignmentExportData exportData = getAlignmentForExport(format, viewport); + AlignmentExportData exportData = getAlignmentForExport(format, + viewport, null); if (exportData.getSettings().isCancelled()) { return false; @@ -1226,7 +1228,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { AlignmentExportData exportData = getAlignmentForExport( - e.getActionCommand(), viewport); + e.getActionCommand(), viewport, null); if (exportData.getSettings().isCancelled()) { return; @@ -1253,9 +1255,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } public static AlignmentExportData getAlignmentForExport(String exportFormat, - AlignViewportI viewport) + AlignViewportI viewport, + AlignExportSettingI exportSettings) { AlignmentI alignmentToExport = null; + AlignExportSettingI settings = exportSettings; String[] omitHidden = null; int[] alignmentStartEnd = new int[2]; @@ -1268,9 +1272,12 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, { 0, alignmentToExport.getWidth() - 1 }; boolean hasHiddenSeqs = hiddenSeqs.getSize() > 0; - AlignExportSettings settings = new AlignExportSettings(hasHiddenSeqs, + if (settings == null) + { + settings = new AlignExportSettings(hasHiddenSeqs, viewport.hasHiddenColumns(), exportFormat); - settings.isExportAnnotations(); + } + // settings.isExportAnnotations(); if (viewport.hasHiddenColumns() && !settings.isExportHiddenColumns()) { diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java index 6c8d2df..50486f2 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -1,5 +1,6 @@ package jalview.io; +import jalview.api.AlignExportSettingI; import jalview.api.AlignmentViewPanel; import jalview.datamodel.AlignmentExportData; import jalview.exceptions.NoFileSelectedException; @@ -53,9 +54,49 @@ public class BioJsHTMLOutput { String outputFile = getOutputFile(); // String jalviewAlignmentJson = JSONFile.getJSONData(ap); + AlignExportSettingI exportSettings = new AlignExportSettingI() + { + @Override + public boolean isExportHiddenSequences() + { + return true; + } + + @Override + public boolean isExportHiddenColumns() + { + return true; + } + + @Override + public boolean isExportAnnotations() + { + return true; + } + + @Override + public boolean isExportFeatures() + { + return true; + } + + @Override + public boolean isExportGroups() + { + return true; + } + + @Override + public boolean isCancelled() + { + return false; + } + + }; AlignmentExportData exportData = jalview.gui.AlignFrame .getAlignmentForExport( - JSONFile.FILE_DESC, ap.getAlignViewport()); +JSONFile.FILE_DESC, + ap.getAlignViewport(), exportSettings); if (exportData.getSettings().isCancelled()) { return; diff --git a/src/jalview/io/HtmlSvgOutput.java b/src/jalview/io/HtmlSvgOutput.java index 6612db3..3a0f169 100644 --- a/src/jalview/io/HtmlSvgOutput.java +++ b/src/jalview/io/HtmlSvgOutput.java @@ -1,5 +1,6 @@ package jalview.io; +import jalview.api.AlignExportSettingI; import jalview.api.FeatureRenderer; import jalview.datamodel.AlignmentExportData; import jalview.datamodel.SequenceI; @@ -98,13 +99,47 @@ public class HtmlSvgOutput .getDefault("EXPORT_EMBBED_BIOJSON", "true")); if (isEmbbedBioJSON) { + AlignExportSettingI exportSettings = new AlignExportSettingI(){ + @Override + public boolean isExportHiddenSequences() + { + return true; + } + + @Override + public boolean isExportHiddenColumns() + { + return true; + } + + @Override + public boolean isExportAnnotations() + { + return true; + } + + @Override + public boolean isExportFeatures() + { + return true; + } + + @Override + public boolean isExportGroups() + { + return true; + } + + @Override + public boolean isCancelled() + { + return false; + } + + }; AlignmentExportData exportData = jalview.gui.AlignFrame - .getAlignmentForExport( - JSONFile.FILE_DESC, av); - if (exportData.getSettings().isCancelled()) - { - return; - } + .getAlignmentForExport(JSONFile.FILE_DESC, av, + exportSettings); jsonData = new FormatAdapter(ap, exportData.getSettings()) .formatSequences(JSONFile.FILE_DESC, exportData .getAlignment(), exportData.getOmitHidden(), diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index 8c790cc..a0a8cb1 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -159,6 +159,12 @@ public class JSONFile extends AlignFile implements ComplexAlignFile { return true; } + + @Override + public boolean isCancelled() + { + return false; + } }; } diff --git a/test/jalview/io/JSONFileTest.java b/test/jalview/io/JSONFileTest.java index b6a3e4a..0b9f30a 100644 --- a/test/jalview/io/JSONFileTest.java +++ b/test/jalview/io/JSONFileTest.java @@ -195,6 +195,12 @@ public class JSONFileTest { return true; } + + @Override + public boolean isCancelled() + { + return false; + } }; AppletFormatAdapter formatAdapter = new AppletFormatAdapter();