From: Jim Procter Date: Mon, 22 Jun 2015 18:12:07 +0000 (+0100) Subject: JAL-1780 JAL-653 Format/AppletFormat import and export pipeline regularised, uses... X-Git-Tag: Release_2_10_0~296^2~137^2~5 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=6dd554fdbf34db6b79595d5027159d20225f4894 JAL-1780 JAL-653 Format/AppletFormat import and export pipeline regularised, uses AlignmentI where possible, and allows configuration via Alignment Panel and ExportSettings interface references --- diff --git a/src/MCview/PDBfile.java b/src/MCview/PDBfile.java index 3f47d9c..7b7f4b0 100755 --- a/src/MCview/PDBfile.java +++ b/src/MCview/PDBfile.java @@ -383,7 +383,7 @@ public class PDBfile extends jalview.io.AlignFile "getSeqsAsArray", new Class[] {}).invoke(jmf)); cl.getMethod("addAnnotations", new Class[] - { Alignment.class }).invoke(jmf, al); + { AlignmentI.class }).invoke(jmf, al); for (SequenceI sq : al.getSequences()) { if (sq.getDatasetSequence() != null) diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 971630d..f16da84 100644 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -832,7 +832,7 @@ public class APopupMenu extends java.awt.PopupMenu implements // TODO consider using getSequenceSelection instead here cap.setText(new jalview.io.AppletFormatAdapter().formatSequences( - e.getActionCommand(), ap.av.getShowJVSuffix(), ap.av, true)); + e.getActionCommand(), ap.av.getShowJVSuffix(), ap, true)); } diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index 3051230..ca1d158 100644 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -1340,7 +1340,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener, { e.getActionCommand() }), 600, 500); FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer(); - cap.setText(new AppletFormatAdapter(viewport).formatSequences( + cap.setText(new AppletFormatAdapter(alignPanel).formatSequences( e.getActionCommand(), viewport.getAlignment(), viewport.getShowJVSuffix())); } diff --git a/src/jalview/appletgui/CutAndPasteTransfer.java b/src/jalview/appletgui/CutAndPasteTransfer.java index 1fdbed8..535dc62 100644 --- a/src/jalview/appletgui/CutAndPasteTransfer.java +++ b/src/jalview/appletgui/CutAndPasteTransfer.java @@ -23,7 +23,6 @@ package jalview.appletgui; import jalview.analysis.AlignmentUtils; import jalview.api.ComplexAlignFile; import jalview.bin.JalviewLite; -import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; import jalview.datamodel.PDBEntry; @@ -221,11 +220,11 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, protected void loadAlignment(String text, boolean newWindow, AlignViewport viewport) { - Alignment al = null; + AlignmentI al = null; String format = new IdentifyFile().Identify(text, AppletFormatAdapter.PASTE); - AppletFormatAdapter afa = new AppletFormatAdapter(viewport); + AppletFormatAdapter afa = new AppletFormatAdapter(alignFrame.alignPanel); try { al = afa.readFile(text, AppletFormatAdapter.PASTE, format); @@ -294,7 +293,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, * @param al * @return */ - protected boolean openSplitFrame(Alignment al, String format) + protected boolean openSplitFrame(AlignmentI al, String format) { final AlignmentI thisAlignment = this.alignFrame.getAlignViewport().getAlignment(); if (thisAlignment.isNucleotide() == al.isNucleotide()) diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 3d1e275..ae5c63f 100644 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -847,7 +847,7 @@ public class JalviewLite extends Applet implements */ public AlignFrame loadAlignment(String text, String title) { - Alignment al = null; + AlignmentI al = null; String format = new IdentifyFile().Identify(text, AppletFormatAdapter.PASTE); diff --git a/src/jalview/bin/JalviewLiteURLRetrieve.java b/src/jalview/bin/JalviewLiteURLRetrieve.java index 462cb81..6be1016 100644 --- a/src/jalview/bin/JalviewLiteURLRetrieve.java +++ b/src/jalview/bin/JalviewLiteURLRetrieve.java @@ -20,7 +20,7 @@ */ package jalview.bin; -import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.io.AppletFormatAdapter; import jalview.io.FileParse; @@ -120,7 +120,7 @@ public class JalviewLiteURLRetrieve extends Applet { System.out.println("User specified Format is " + format); } - Alignment al = null; + AlignmentI al = null; try { al = new AppletFormatAdapter().readFile(file, protocol, format); diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index 835d7e9..3916b7d 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -1138,7 +1138,7 @@ public class ColumnSelection * profileseq marked as hidden. */ public static ColumnSelection propagateInsertions(SequenceI profileseq, - Alignment al, AlignmentView input) + AlignmentI al, AlignmentView input) { int profsqpos = 0; diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index e3efa59..01353d8 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1141,7 +1141,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } ExportData exportData = getAlignmentForExport(format); - FormatAdapter f = new FormatAdapter(viewport); + FormatAdapter f = new FormatAdapter(alignPanel); String output = f.formatSequences(format, exportData.getAlignment(), // class cast exceptions will // occur in the distant future @@ -1222,7 +1222,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, cap.setForInput(null); try { - cap.setText(new FormatAdapter(viewport).formatSequences( + cap.setText(new FormatAdapter(alignPanel, exportData.getSettings()) + .formatSequences( e.getActionCommand(), exportData.getAlignment(), exportData.getOmitHidden(), exportData.getStartEndPostions(), diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index 15e6818..b492ddf 100644 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -58,7 +58,9 @@ import javax.swing.SwingUtilities; public class CutAndPasteTransfer extends GCutAndPasteTransfer { - AlignViewport viewport; + AlignmentViewPanel alignpanel; + + AlignViewportI viewport; FileParse source = null; public CutAndPasteTransfer() @@ -76,9 +78,14 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer /** * DOCUMENT ME! */ - public void setForInput(AlignViewport viewport) + public void setForInput(AlignmentViewPanel viewpanel) { - this.viewport = viewport; + this.alignpanel = viewpanel; + if (alignpanel != null) + { + + } + this.viewport = alignpanel.getAlignViewport(); if (viewport != null) { ok.setText(MessageManager.getString("action.add")); @@ -190,13 +197,13 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer { String format = new IdentifyFile().Identify(getText(), "Paste"); // TODO: identify feature, annotation or tree file and parse appropriately. - Alignment al = null; + AlignmentI al = null; if (FormatAdapter.isValidFormat(format)) { try { - FormatAdapter fa = new FormatAdapter(viewport); + FormatAdapter fa = new FormatAdapter(alignpanel); al = fa.readFile(getText(), "Paste", format); source = fa.getAlignFile(); @@ -218,7 +225,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer { format }); if (viewport != null) { - viewport.addAlignment(al, title); + ((AlignViewport) viewport).addAlignment(al, title); } else { diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 984dd98..cc9daa1 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1133,7 +1133,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements public void inputTextboxMenuItem_actionPerformed(AlignViewport viewport) { CutAndPasteTransfer cap = new CutAndPasteTransfer(); - cap.setForInput(viewport); + cap.setForInput(viewport.getAlignPanel()); Desktop.addInternalFrame(cap, MessageManager.getString("label.cut_paste_alignmen_file"), true, 600, 500); diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 0d28a70..2aa8675 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -2396,7 +2396,7 @@ public class PopupMenu extends JPopupMenu // wysiwig behaviour cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(), - ap.av, true)); + ap, true)); } public void pdbFromFile_actionPerformed() diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index d920028..c330a92 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -773,7 +773,7 @@ public class SequenceFetcher extends JPanel implements Runnable AlignmentI parseResult(String result, String title) { String format = new IdentifyFile().Identify(result, "Paste"); - Alignment sequences = null; + AlignmentI sequences = null; if (FormatAdapter.isValidFormat(format)) { sequences = null; diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index e4891f0..3b46760 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -20,7 +20,6 @@ */ package jalview.io; -import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Sequence; @@ -200,7 +199,7 @@ public abstract class AlignFile extends FileParse * * @param al */ - public void addAnnotations(Alignment al) + public void addAnnotations(AlignmentI al) { addProperties(al); for (int i = 0; i < annotations.size(); i++) @@ -220,6 +219,11 @@ public abstract class AlignFile extends FileParse } + /** + * register sequence groups on the alignment for **output** + * + * @param al + */ public void addSeqGroups(AlignmentI al) { this.seqGroups = al.getGroups(); @@ -233,7 +237,7 @@ public abstract class AlignFile extends FileParse * @note implicitly called by addAnnotations() * @param al */ - public void addProperties(Alignment al) + public void addProperties(AlignmentI al) { if (properties != null && properties.size() > 0) { diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 7810771..b235bcc 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -20,11 +20,13 @@ */ package jalview.io; -import jalview.api.AlignViewportI; +import jalview.api.AlignExportSettingI; +import jalview.api.AlignmentViewPanel; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; +import jalview.gui.AlignmentPanel; import jalview.util.MessageManager; import java.io.File; @@ -42,7 +44,7 @@ import java.util.List; */ public class AppletFormatAdapter { - private AlignViewportI viewport; + private AlignmentViewPanel viewpanel; public static String FILE = "File"; @@ -76,6 +78,8 @@ public class AppletFormatAdapter */ protected String newline = System.getProperty("line.separator"); + private AlignExportSettingI exportSettings; + /** * List of valid format strings used in the isValidFormat method */ @@ -137,9 +141,16 @@ public class AppletFormatAdapter { } - public AppletFormatAdapter(AlignViewportI viewport) + public AppletFormatAdapter(AlignmentViewPanel viewpanel) + { + this.viewpanel = viewpanel; + } + + public AppletFormatAdapter(AlignmentPanel alignPanel, + AlignExportSettingI settings) { - this.viewport = viewport; + viewpanel = alignPanel; + exportSettings = settings; } /** @@ -221,7 +232,7 @@ public class AppletFormatAdapter * * @return DOCUMENT ME! */ - public Alignment readFile(String inFile, String type, String format) + public AlignmentI readFile(String inFile, String type, String format) throws java.io.IOException { // TODO: generalise mapping between format string and io. class instances @@ -229,7 +240,6 @@ public class AppletFormatAdapter this.inFile = inFile; try { - Alignment al; if (format.equals("FASTA")) { alignFile = new FastaFile(inFile, type); @@ -298,16 +308,7 @@ public class AppletFormatAdapter { alignFile = new Gff3File(inFile, type); } - // Standard boilerplate for creating alignment from parser - alignFile.setViewport(viewport); - - al = new Alignment(alignFile.getSeqsAsArray()); - - alignFile.addAnnotations(al); - - alignFile.addGroups(al); - - return al; + return buildAlignmentFrom(alignFile); } catch (Exception e) { e.printStackTrace(); @@ -327,11 +328,7 @@ public class AppletFormatAdapter { // Possible sequence is just residues with no label alignFile = new FastaFile(">UNKNOWN\n" + inFile, "Paste"); - Alignment al = new Alignment(alignFile.getSeqsAsArray()); - - alignFile.addSeqGroups(al); - alignFile.addAnnotations(al); - return al; + return buildAlignmentFrom(alignFile); } catch (Exception ex) { @@ -370,7 +367,6 @@ public class AppletFormatAdapter String type = source.type; try { - Alignment al; if (format.equals("FASTA")) { alignFile = new FastaFile(source); @@ -432,19 +428,14 @@ public class AppletFormatAdapter else if (format.equals(JSONFile.FILE_DESC)) { alignFile = new JSONFile(source); - al = new Alignment(alignFile.getSeqsAsArray()); - alignFile.addAnnotations(al); - alignFile.addSeqGroups(al); - return al; } else if (format.equals(HtmlFile.FILE_DESC)) { alignFile = new HtmlFile(source); } - al = new Alignment(alignFile.getSeqsAsArray()); - alignFile.addAnnotations(al); - return al; + return buildAlignmentFrom(alignFile); + } catch (Exception e) { e.printStackTrace(); @@ -464,10 +455,7 @@ public class AppletFormatAdapter { // Possible sequence is just residues with no label alignFile = new FastaFile(">UNKNOWN\n" + inFile, "Paste"); - Alignment al = new Alignment(alignFile.getSeqsAsArray()); - alignFile.addAnnotations(al); - alignFile.addSeqGroups(al); - return al; + return buildAlignmentFrom(alignFile); } catch (Exception ex) { @@ -487,6 +475,27 @@ public class AppletFormatAdapter /** + * boilerplate method to handle data from an AlignFile and construct a new + * alignment or import to an existing alignment + * + * @param alignFile2 + * @return AlignmentI instance ready to pass to a UI constructor + */ + private AlignmentI buildAlignmentFrom(AlignFile alignFile2) + { + // Standard boilerplate for creating alignment from parser + alignFile.configureForView(viewpanel); + + AlignmentI al = new Alignment(alignFile.getSeqsAsArray()); + + alignFile.addAnnotations(al); + + alignFile.addGroups(al); + + return al; + } + + /** * create an alignment flatfile from a Jalview alignment view * @param format * @param jvsuffix @@ -495,13 +504,14 @@ public class AppletFormatAdapter * @return flatfile in a string */ public String formatSequences(String format, boolean jvsuffix, - AlignViewportI av, boolean selectedOnly) + AlignmentViewPanel ap, boolean selectedOnly) { - AlignmentView selvew = av.getAlignmentView(selectedOnly, false); - AlignmentI aselview = selvew.getVisibleAlignment(av + AlignmentView selvew = ap.getAlignViewport().getAlignmentView( + selectedOnly, false); + AlignmentI aselview = selvew.getVisibleAlignment(ap.getAlignViewport() .getGapCharacter()); - List ala = (av + List ala = (ap.getAlignViewport() .getVisibleAlignmentAnnotation(selectedOnly)); if (ala != null) { @@ -578,22 +588,6 @@ public class AppletFormatAdapter else if (format.equalsIgnoreCase(JSONFile.FILE_DESC)) { afile = new JSONFile(); - afile.setViewport(viewport); - // Add groups to AlignFile - afile.seqGroups = alignment.getGroups(); - - // Add non auto calculated annotation to AlignFile - for (AlignmentAnnotation annot : alignment.getAlignmentAnnotation()) - { - if (annot != null && !annot.autoCalculated) - { - if (annot.label.equals("PDB.CATempFactor")) - { - continue; - } - afile.annotations.add(annot); - } - } } else if (format.equalsIgnoreCase("RNAML")) { @@ -607,8 +601,21 @@ public class AppletFormatAdapter afile.setNewlineString(newline); afile.addJVSuffix(jvsuffix); - afile.setSeqs(alignment.getSequencesArray()); + afile.setExportSettings(exportSettings); + + afile.configureForView(viewpanel); + // check whether we were given a specific alignment to export, rather than + // the one in the viewpanel + if (viewpanel == null || viewpanel.getAlignment() == null + || viewpanel.getAlignment() != alignment) + { + afile.setSeqs(alignment.getSequencesArray()); + } + else + { + afile.setSeqs(viewpanel.getAlignment().getSequencesArray()); + } String afileresp = afile.print(); if (afile.hasWarningMessage()) @@ -655,7 +662,7 @@ public class AppletFormatAdapter System.gc(); long memf = -r.totalMemory() + r.freeMemory(); long t1 = -System.currentTimeMillis(); - Alignment al = afa.readFile(args[i], FILE, + AlignmentI al = afa.readFile(args[i], FILE, new IdentifyFile().Identify(args[i], FILE)); t1 += System.currentTimeMillis(); System.gc(); diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 44af9ad..57f6384 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -22,7 +22,6 @@ package jalview.io; import jalview.analysis.SequenceIdMatcher; import jalview.datamodel.AlignedCodonFrame; -import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceDummy; import jalview.datamodel.SequenceFeature; @@ -171,14 +170,14 @@ public class FeaturesFile extends AlignFile } @Override - public void addAnnotations(Alignment al) + public void addAnnotations(AlignmentI al) { // TODO Auto-generated method stub super.addAnnotations(al); } @Override - public void addProperties(Alignment al) + public void addProperties(AlignmentI al) { // TODO Auto-generated method stub super.addProperties(al); diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index 8f5144b..9228257 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -22,6 +22,7 @@ package jalview.io; import jalview.api.AlignExportSettingI; import jalview.api.AlignViewportI; +import jalview.api.AlignmentViewPanel; import jalview.util.MessageManager; import java.io.BufferedReader; @@ -410,6 +411,19 @@ public class FileParse throw new IOException(MessageManager.formatMessage("exception.invalid_source_stream", new String[]{errormessage})); } + /** + * + * @return true if this FileParse is configured for Export only + */ + public boolean isExporting() + { + return !error && dataIn == null; + } + + /** + * + * @return true if the data source is valid + */ public boolean isValid() { return !error; @@ -535,4 +549,18 @@ public class FileParse { this.exportSettings = exportSettings; } + + /** + * method overridden by complex file exporter/importers which support + * exporting visualisation and layout settings for a view + * + * @param avpanel + */ + public void configureForView(AlignmentViewPanel avpanel) + { + if (avpanel!=null) { + setViewport(avpanel.getAlignViewport()); + } + // could also set export/import settings + } } diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index d241308..e795925 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -20,7 +20,8 @@ */ package jalview.io; -import jalview.api.AlignViewportI; +import jalview.api.AlignExportSettingI; +import jalview.api.AlignmentViewPanel; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; @@ -28,6 +29,7 @@ import jalview.datamodel.ColumnSelection; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.gui.AlignmentPanel; /** * Additional formatting methods used by the application in a number of places. @@ -37,9 +39,9 @@ import jalview.datamodel.SequenceI; */ public class FormatAdapter extends AppletFormatAdapter { - public FormatAdapter(AlignViewportI viewport) + public FormatAdapter(AlignmentViewPanel viewpanel) { - super(viewport); + super(viewpanel); init(); } @@ -49,6 +51,12 @@ public class FormatAdapter extends AppletFormatAdapter init(); } + public FormatAdapter(AlignmentPanel alignPanel, + AlignExportSettingI settings) + { + super(alignPanel, settings); + } + private void init() { if (jalview.bin.Cache.getDefault("STRUCT_FROM_PDB", true)) @@ -304,17 +312,17 @@ public class FormatAdapter extends AppletFormatAdapter return this.formatSequences(format, alignment, suffix); } - public Alignment readFile(String inFile, String type, String format) + public AlignmentI readFile(String inFile, String type, String format) throws java.io.IOException { - Alignment al = super.readFile(inFile, type, format); + AlignmentI al = super.readFile(inFile, type, format); return al; } public AlignmentI readFromFile(FileParse source, String format) throws java.io.IOException { - Alignment al = (Alignment) super.readFromFile(source, format); + AlignmentI al = super.readFromFile(source, format); return al; } @@ -341,14 +349,19 @@ public class FormatAdapter extends AppletFormatAdapter } /** - * Create a flat file representation of a given view or selected region of a view + * Create a flat file representation of a given view or selected region of a + * view + * * @param format - * @param av + * @param ap + * alignment panel originating the view * @return String containing flat file */ - public String formatSequences(String format, AlignViewportI av, boolean selectedOnly) + public String formatSequences(String format, AlignmentViewPanel ap, + boolean selectedOnly) { - return formatSequences(format, getCacheSuffixDefault(format), av, selectedOnly); + return formatSequences(format, getCacheSuffixDefault(format), ap, + selectedOnly); } diff --git a/src/jalview/io/Gff3File.java b/src/jalview/io/Gff3File.java index 53179e0..1f8c3be 100644 --- a/src/jalview/io/Gff3File.java +++ b/src/jalview/io/Gff3File.java @@ -139,7 +139,7 @@ public class Gff3File extends FeaturesFile } @Override - public void addProperties(Alignment al) + public void addProperties(AlignmentI al) { super.addProperties(al); if (dataset.getCodonFrames() != null) diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index 20f1f94..ce70ea5 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -116,11 +116,6 @@ public class JSONFile extends AlignFile implements ComplexAlignFile try { AlignmentPojo jsonAlignmentPojo = new AlignmentPojo(); - if (getViewport() != null) - { - configureFromViewport(); - - } int count = 0; for (SequenceI seq : seqs) @@ -595,46 +590,44 @@ public class JSONFile extends AlignFile implements ComplexAlignFile this.displayedFeatures = displayedFeatures; } + @Override public void configureForView(AlignmentViewPanel avpanel) { + super.configureForView(avpanel); + if (isExporting()) + { + setViewport(avpanel.getAlignViewport()); + seqGroups = avpanel.getAlignment().getGroups(); + setDisplayedFeatures(getViewport().getFeaturesDisplayed()); + fr = avpanel.cloneFeatureRenderer(); - setViewport(avpanel.getAlignViewport()); - seqGroups = avpanel.getAlignment().getGroups(); - setDisplayedFeatures(getViewport().getFeaturesDisplayed()); - fr = avpanel.cloneFeatureRenderer(); + for (SequenceI seq : getViewport().getAlignment().getSequences()) + { + seqs.add(seq); + } - for (SequenceI seq : getViewport().getAlignment().getSequences()) - { - seqs.add(seq); - } - - // Add non auto calculated annotation to AlignFile - for (AlignmentAnnotation annot : getViewport().getAlignment() - .getAlignmentAnnotation()) - { - if (annot != null && !annot.autoCalculated) + // Add non auto calculated annotation to AlignFile + for (AlignmentAnnotation annot : getViewport().getAlignment() + .getAlignmentAnnotation()) { - if (annot.label.equals("PDB.CATempFactor")) + if (annot != null && !annot.autoCalculated) { - continue; + if (annot.label.equals("PDB.CATempFactor")) + { + continue; + } + annotations.add(annot); } - annotations.add(annot); } - } - } - public void configureFromViewport() - { - if (getViewport() == null) - { - return; + globalColorScheme = ColourSchemeProperty.getColourName(getViewport() + .getGlobalColourScheme()); + setDisplayedFeatures(getViewport().getFeaturesDisplayed()); + showSeqFeatures = getViewport().isShowSequenceFeatures(); } - globalColorScheme = ColourSchemeProperty.getColourName(getViewport() - .getGlobalColourScheme()); - setDisplayedFeatures(getViewport().getFeaturesDisplayed()); - showSeqFeatures = getViewport().isShowSequenceFeatures(); } + public static String getJSONData(AlignmentViewPanel av) { JSONFile jsonFile = new JSONFile(); diff --git a/src/jalview/jbgui/GFinder.java b/src/jalview/jbgui/GFinder.java index 45a5957..0b2e6be 100755 --- a/src/jalview/jbgui/GFinder.java +++ b/src/jalview/jbgui/GFinder.java @@ -20,7 +20,7 @@ */ package jalview.jbgui; -import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.io.FormatAdapter; import jalview.util.MessageManager; @@ -211,7 +211,7 @@ public class GFinder extends JPanel public void run() { String str = textfield.getText(); - Alignment al = null; + AlignmentI al = null; try { al = new FormatAdapter().readFile(str, "Paste", "FASTA"); diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 95a134a..4c8f3ce 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -20,7 +20,6 @@ */ package jalview.ws.dbsources; -import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.DBRefSource; @@ -156,7 +155,7 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy { queries = queries.toUpperCase().replaceAll( "(UNIPROT\\|?|UNIPROT_|UNIREF\\d+_|UNIREF\\d+\\|?)", ""); - Alignment al = null; + AlignmentI al = null; EBIFetchClient ebi = new EBIFetchClient(); // uniprotxml parameter required since december 2007 // uniprotkb dbname changed introduced december 2008 @@ -245,7 +244,7 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy * @param entries * a list of n uniprot entries to be analysed. */ - public void addUniprotXrefs(Alignment al, Vector entries) + public void addUniprotXrefs(AlignmentI al, Vector entries) { final String dbVersion = getDbVersion(); diff --git a/src/jalview/ws/jws1/JPredThread.java b/src/jalview/ws/jws1/JPredThread.java index 69d0ae4..62566cf 100644 --- a/src/jalview/ws/jws1/JPredThread.java +++ b/src/jalview/ws/jws1/JPredThread.java @@ -24,6 +24,7 @@ import jalview.analysis.AlignSeq; import jalview.bin.Cache; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.datamodel.ColumnSelection; import jalview.datamodel.SequenceI; @@ -103,7 +104,7 @@ class JPredThread extends JWS1Thread implements WSClientI { return null; } - Alignment al = null; + AlignmentI al = null; ColumnSelection alcsel = null; int FirstSeq = -1; // the position of the query sequence in Alignment al @@ -279,7 +280,7 @@ class JPredThread extends JWS1Thread implements WSClientI * @param al * @param profileseq */ - private void alignToProfileSeq(Alignment al, SequenceI profileseq) + private void alignToProfileSeq(AlignmentI al, SequenceI profileseq) { char gc = al.getGapCharacter(); int[] gapMap = profileseq.gapMap(); diff --git a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java index 719027f..0785dfa 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java @@ -20,7 +20,7 @@ */ package jalview.ws.seqfetcher; -import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; @@ -118,9 +118,9 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy * @return null or a valid alignment * @throws Exception */ - protected Alignment parseResult(String result) throws Exception + protected AlignmentI parseResult(String result) throws Exception { - Alignment sequences = null; + AlignmentI sequences = null; String format = new IdentifyFile().Identify(result, "Paste"); if (FormatAdapter.isValidFormat(format)) { diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 26ae0b8..10fb81f 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -263,7 +263,7 @@ public class AlignmentUtilsTests */ protected AlignmentI loadAlignment(final String data, String format) throws IOException { - Alignment a = new FormatAdapter().readFile(data, + AlignmentI a = new FormatAdapter().readFile(data, AppletFormatAdapter.PASTE, format); a.setDataset(null); return a; diff --git a/test/jalview/datamodel/AlignmentTest.java b/test/jalview/datamodel/AlignmentTest.java index df98af9..8a84737 100644 --- a/test/jalview/datamodel/AlignmentTest.java +++ b/test/jalview/datamodel/AlignmentTest.java @@ -68,7 +68,7 @@ public class AlignmentTest protected AlignmentI loadAlignment(final String data, String format) throws IOException { - Alignment a = new FormatAdapter().readFile(data, + AlignmentI a = new FormatAdapter().readFile(data, AppletFormatAdapter.PASTE, format); a.setDataset(null); return a; diff --git a/test/jalview/io/JSONFileTest.java b/test/jalview/io/JSONFileTest.java index 92b172c..bce9795 100644 --- a/test/jalview/io/JSONFileTest.java +++ b/test/jalview/io/JSONFileTest.java @@ -2,7 +2,6 @@ package jalview.io; import static org.junit.Assert.assertNotNull; -import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; @@ -156,7 +155,7 @@ public class JSONFileTest { String jsonFile = "examples/example.json"; AppletFormatAdapter rf = new AppletFormatAdapter(); - Alignment al = null; + AlignmentI al = null; try { al = rf.readFile(jsonFile, AppletFormatAdapter.FILE, diff --git a/test/jalview/io/PhylipFileTests.java b/test/jalview/io/PhylipFileTests.java index e411272..d6f28fa 100644 --- a/test/jalview/io/PhylipFileTests.java +++ b/test/jalview/io/PhylipFileTests.java @@ -2,7 +2,7 @@ package jalview.io; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentI; import jalview.datamodel.SequenceI; import java.io.IOException; @@ -105,7 +105,7 @@ public class PhylipFileTests private void testDataExtraction(String file) throws IOException { AppletFormatAdapter rf = new AppletFormatAdapter(); - Alignment al = rf.readFile(file, AppletFormatAdapter.FILE, + AlignmentI al = rf.readFile(file, AppletFormatAdapter.FILE, PhylipFile.FILE_DESC); assertNotNull("Couldn't read supplied alignment data.", al); @@ -150,13 +150,13 @@ public class PhylipFileTests public void testIO(String file) throws IOException { AppletFormatAdapter rf = new AppletFormatAdapter(); - Alignment al = rf.readFile(file, AppletFormatAdapter.FILE, + AlignmentI al = rf.readFile(file, AppletFormatAdapter.FILE, PhylipFile.FILE_DESC); assertNotNull("Couldn't read supplied alignment data.", al); String outputfile = rf.formatSequences(PhylipFile.FILE_DESC, al, true); - Alignment al_input = new AppletFormatAdapter().readFile(outputfile, + AlignmentI al_input = new AppletFormatAdapter().readFile(outputfile, AppletFormatAdapter.PASTE, PhylipFile.FILE_DESC); assertNotNull("Couldn't parse reimported alignment data.", al_input); diff --git a/test/jalview/io/StockholmFileTest.java b/test/jalview/io/StockholmFileTest.java index 806e4dc..c3fd4e3 100644 --- a/test/jalview/io/StockholmFileTest.java +++ b/test/jalview/io/StockholmFileTest.java @@ -23,7 +23,6 @@ package jalview.io; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; @@ -93,7 +92,7 @@ public class StockholmFileTest { AppletFormatAdapter rf = new AppletFormatAdapter(); - Alignment al = rf.readFile(ff, AppletFormatAdapter.FILE, + AlignmentI al = rf.readFile(ff, AppletFormatAdapter.FILE, new IdentifyFile().Identify(ff, AppletFormatAdapter.FILE)); assertNotNull("Couldn't read supplied alignment data.", al); @@ -107,7 +106,7 @@ public class StockholmFileTest System.out.println("Output file in '" + ioformat + "':\n" + outputfile + "\n<