From a9cbd1f67eef27f9744583400f4ff33e13994d1e Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Tue, 5 May 2015 18:43:12 +0100 Subject: [PATCH] JAL-1641 Re-implemented lost changes after sequenceFeature refactor --- src/jalview/gui/AlignFrame.java | 103 ++--- src/jalview/gui/CutAndPasteTransfer.java | 5 + src/jalview/gui/Desktop.java | 65 +++- src/jalview/io/AlignFile.java | 19 +- src/jalview/io/AppletFormatAdapter.java | 54 ++- src/jalview/io/BioJsHTMLOutput.java | 16 +- src/jalview/io/FileLoader.java | 9 +- src/jalview/io/FormatAdapter.java | 41 +- src/jalview/io/HtmlFile.java | 150 ++++--- src/jalview/io/IdentifyFile.java | 5 + src/jalview/io/JSONFile.java | 411 ++++++++++++++++++++ .../json/binding/v1/AlignmentAnnotationPojo.java | 43 ++ ...{BioJsAlignmentPojo.java => AlignmentPojo.java} | 37 +- src/jalview/json/binding/v1/AnnotationPojo.java | 54 +++ src/jalview/json/binding/v1/BioJsFeaturePojo.java | 60 --- src/jalview/json/binding/v1/FeaturePojo.java | 120 ++++++ src/jalview/json/binding/v1/SequenceGrpPojo.java | 126 ++++++ .../v1/{BioJsSeqPojo.java => SequencePojo.java} | 24 +- 18 files changed, 1078 insertions(+), 264 deletions(-) create mode 100644 src/jalview/io/JSONFile.java create mode 100644 src/jalview/json/binding/v1/AlignmentAnnotationPojo.java rename src/jalview/json/binding/v1/{BioJsAlignmentPojo.java => AlignmentPojo.java} (82%) create mode 100644 src/jalview/json/binding/v1/AnnotationPojo.java delete mode 100644 src/jalview/json/binding/v1/BioJsFeaturePojo.java create mode 100644 src/jalview/json/binding/v1/FeaturePojo.java create mode 100644 src/jalview/json/binding/v1/SequenceGrpPojo.java rename src/jalview/json/binding/v1/{BioJsSeqPojo.java => SequencePojo.java} (67%) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 80838e2..1963523 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -20,57 +20,6 @@ */ package jalview.gui; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.GridLayout; -import java.awt.Rectangle; -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.StringSelection; -import java.awt.datatransfer.Transferable; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DropTargetDragEvent; -import java.awt.dnd.DropTargetDropEvent; -import java.awt.dnd.DropTargetEvent; -import java.awt.dnd.DropTargetListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.print.PageFormat; -import java.awt.print.PrinterJob; -import java.beans.PropertyChangeEvent; -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Deque; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.List; -import java.util.Set; -import java.util.Vector; - -import javax.swing.JButton; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JEditorPane; -import javax.swing.JInternalFrame; -import javax.swing.JLabel; -import javax.swing.JLayeredPane; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; - import jalview.analysis.AAFrequency; import jalview.analysis.AlignmentSorter; import jalview.analysis.AlignmentUtils; @@ -148,6 +97,57 @@ import jalview.ws.jws2.Jws2Discoverer; import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.ws.seqfetcher.DbSourceProxy; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.print.PageFormat; +import java.awt.print.PrinterJob; +import java.beans.PropertyChangeEvent; +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Deque; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.List; +import java.util.Set; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JEditorPane; +import javax.swing.JInternalFrame; +import javax.swing.JLabel; +import javax.swing.JLayeredPane; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; + /** * DOCUMENT ME! * @@ -1306,6 +1306,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, try { + Desktop.setCurrentAlignFrame(this); cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(), viewport.getAlignment(), omitHidden, viewport.getColumnSelection())); diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index 22f0a59..24e464a 100644 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -219,6 +219,11 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer af.statusBar.setText(MessageManager .getString("label.successfully_pasted_alignment_file")); + + af.setShowSeqFeatures(true); + af.changeColour(Desktop.getCurrentGlobalColourScheme()); + af.setMenusForViewport(); + try { af.setMaximum(jalview.bin.Cache.getDefault("SHOW_FULLSCREEN", diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 5f45dc1..53237f9 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -20,6 +20,23 @@ */ package jalview.gui; +import jalview.api.AlignViewportI; +import jalview.api.AlignmentViewPanel; +import jalview.bin.Cache; +import jalview.io.FileLoader; +import jalview.io.FormatAdapter; +import jalview.io.IdentifyFile; +import jalview.io.JalviewFileChooser; +import jalview.io.JalviewFileView; +import jalview.jbgui.GSplitFrame; +import jalview.jbgui.GStructureViewer; +import jalview.schemes.ColourSchemeI; +import jalview.structure.StructureSelectionManager; +import jalview.util.ImageMaker; +import jalview.util.MessageManager; +import jalview.viewmodel.AlignmentViewport; +import jalview.ws.params.ParamManager; + import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -84,22 +101,6 @@ import javax.swing.event.HyperlinkEvent.EventType; import javax.swing.event.MenuEvent; import javax.swing.event.MenuListener; -import jalview.api.AlignViewportI; -import jalview.api.AlignmentViewPanel; -import jalview.bin.Cache; -import jalview.io.FileLoader; -import jalview.io.FormatAdapter; -import jalview.io.IdentifyFile; -import jalview.io.JalviewFileChooser; -import jalview.io.JalviewFileView; -import jalview.jbgui.GSplitFrame; -import jalview.jbgui.GStructureViewer; -import jalview.structure.StructureSelectionManager; -import jalview.util.ImageMaker; -import jalview.util.MessageManager; -import jalview.viewmodel.AlignmentViewport; -import jalview.ws.params.ParamManager; - /** * Jalview Desktop * @@ -169,6 +170,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements private static final int THREE = 3; + private static AlignFrame currentAlignFrame; + + private static ColourSchemeI currentGlobalColourScheme; + public static jalview.ws.jws1.Discoverer discoverer; public static Object[] jalviewClipboard; @@ -1022,6 +1027,11 @@ public class Desktop extends jalview.jbgui.GDesktop implements { new FileLoader().LoadFile(viewport, choice, FormatAdapter.FILE, format); + + viewport.setShowSequenceFeatures(true); + viewport.getAlignPanel().alignFrame.changeColour(Desktop + .getCurrentGlobalColourScheme()); + viewport.getAlignPanel().alignFrame.setMenusForViewport(); } else { @@ -3073,4 +3083,27 @@ public class Desktop extends jalview.jbgui.GDesktop implements myTopFrame.setDisplayedView(myTopFrame.alignPanel); } + + public static AlignFrame getCurrentAlignFrame() + { + return currentAlignFrame; + } + + public static void setCurrentAlignFrame(AlignFrame currentAlignFrame) + { + Desktop.currentAlignFrame = currentAlignFrame; + } + + public static ColourSchemeI getCurrentGlobalColourScheme() + { + return currentGlobalColourScheme; + } + + public static void setCurrentGlobalColourScheme( + ColourSchemeI currentGlobalColourScheme) + { + Desktop.currentGlobalColourScheme = currentGlobalColourScheme; + } + + } diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index e902ccf..993a1e8 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -22,13 +22,17 @@ package jalview.io; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.util.MessageManager; import java.io.IOException; +import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; +import java.util.List; import java.util.Vector; /** @@ -54,6 +58,11 @@ public abstract class AlignFile extends FileParse protected Vector annotations; /** + * SequenceGroups to be added to the alignment object + */ + protected List seqGroups; + + /** * Properties to be added to generated alignment object */ protected Hashtable properties; @@ -174,7 +183,7 @@ public abstract class AlignFile extends FileParse for (int i = 0; i < seqs.size(); i++) { - s[i] = (SequenceI) seqs.elementAt(i); + s[i] = seqs.elementAt(i); } return s; @@ -198,7 +207,7 @@ public abstract class AlignFile extends FileParse * Rna.GetBasePairsFromAlignmentAnnotation(annotations.elementAt(i)); * Rna.HelixMap(pairArray); */ - AlignmentAnnotation an = (AlignmentAnnotation) annotations + AlignmentAnnotation an = annotations .elementAt(i); an.validateRangeAndDisplay(); al.addAnnotation(an); @@ -206,6 +215,11 @@ public abstract class AlignFile extends FileParse } + public void addSeqGroups(AlignmentI al) + { + this.seqGroups = al.getGroups(); + } + /** * Add any additional information extracted from the file to the alignment * properties. @@ -269,6 +283,7 @@ public abstract class AlignFile extends FileParse { seqs = new Vector(); annotations = new Vector(); + seqGroups = new ArrayList(); parseCalled=false; } diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index c69a0c7..39b0819 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -47,7 +47,8 @@ public class AppletFormatAdapter */ public static final String[] READABLE_FORMATS = new String[] { "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH", - "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC, "HTML" }; + "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC, + "HTML" }; /** * List of readable format file extensions by application in order @@ -55,7 +56,8 @@ public class AppletFormatAdapter */ public static final String[] READABLE_EXTENSIONS = new String[] { "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa", - "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT, "jar,jvp", "html" }; + "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT, JSONFile.FILE_EXT, + "jar,jvp", "html" }; /** * List of readable formats by application in order corresponding to @@ -63,7 +65,7 @@ public class AppletFormatAdapter */ public static final String[] READABLE_FNAMES = new String[] { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Stockholm", - "RNAML", PhylipFile.FILE_DESC, "Jalview", "HTML" }; + "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC, "Jalview", "HTML" }; /** * List of valid format strings for use by callers of the formatSequences @@ -71,7 +73,7 @@ public class AppletFormatAdapter */ public static final String[] WRITEABLE_FORMATS = new String[] { "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "AMSA", - "STH", PhylipFile.FILE_DESC }; + "STH", PhylipFile.FILE_DESC, JSONFile.FILE_DESC }; /** * List of extensions corresponding to file format types in WRITABLE_FNAMES @@ -79,7 +81,7 @@ public class AppletFormatAdapter */ public static final String[] WRITABLE_EXTENSIONS = new String[] { "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa", - "sto,stk", PhylipFile.FILE_EXT, "jvp" }; + "sto,stk", PhylipFile.FILE_EXT, JSONFile.FILE_EXT, "jvp" }; /** * List of writable formats by the application. Order must correspond with the @@ -87,7 +89,7 @@ public class AppletFormatAdapter */ public static final String[] WRITABLE_FNAMES = new String[] { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "STH", - PhylipFile.FILE_DESC, "Jalview" }; + PhylipFile.FILE_DESC, JSONFile.FILE_DESC, "Jalview" }; public static String INVALID_CHARACTERS = "Contains invalid characters"; @@ -265,10 +267,10 @@ public class AppletFormatAdapter { afile = new PhylipFile(inFile, type); } - // else if (format.equals(HtmlFile.FILE_DESC)) - // { - // afile = new HtmlFile(inFile, type); - // } + else if (format.equals(JSONFile.FILE_DESC)) + { + afile = new JSONFile(inFile, type); + } else if (format.equals("RNAML")) { afile = new RnamlFile(inFile, type); @@ -277,6 +279,7 @@ public class AppletFormatAdapter Alignment al = new Alignment(afile.getSeqsAsArray()); afile.addAnnotations(al); + afile.addSeqGroups(al); return al; } catch (Exception e) @@ -299,6 +302,8 @@ public class AppletFormatAdapter // Possible sequence is just residues with no label afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste"); Alignment al = new Alignment(afile.getSeqsAsArray()); + + afile.addSeqGroups(al); afile.addAnnotations(al); return al; @@ -393,13 +398,14 @@ public class AppletFormatAdapter { afile = new PhylipFile(source); } - // else if (format.equals(HtmlFile.FILE_DESC)) - // { - // afile = new HtmlFile(source); - // } + else if (format.equals(JSONFile.FILE_DESC)) + { + afile = new JSONFile(source); + } Alignment al = new Alignment(afile.getSeqsAsArray()); afile.addAnnotations(al); + afile.addSeqGroups(al); return al; } catch (Exception e) @@ -491,7 +497,6 @@ public class AppletFormatAdapter try { AlignFile afile = null; - if (format.equalsIgnoreCase("FASTA")) { afile = new FastaFile(); @@ -532,10 +537,10 @@ public class AppletFormatAdapter { afile = new PhylipFile(); } - // else if (format.equalsIgnoreCase(HtmlFile.FILE_DESC)) - // { - // afile = new HtmlFile(); - // } + else if (format.equalsIgnoreCase(JSONFile.FILE_DESC)) + { + afile = new JSONFile(); + } else if (format.equalsIgnoreCase("RNAML")) { afile = new RnamlFile(); @@ -549,6 +554,17 @@ public class AppletFormatAdapter afile.addJVSuffix(jvsuffix); afile.setSeqs(alignment.getSequencesArray()); + afile.addSeqGroups(alignment); + + // Add non auto calculated annotation to AlignFile + for (AlignmentAnnotation annot : alignment.getAlignmentAnnotation()) + { + if (!annot.autoCalculated) + { + afile.annotations.add(annot); + } + + } String afileresp = afile.print(); if (afile.hasWarningMessage()) diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java index d2c4a7f..c44f1bf 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -7,9 +7,9 @@ import jalview.datamodel.SequenceI; import jalview.exceptions.NoFileSelectedException; import jalview.gui.AlignmentPanel; import jalview.gui.FeatureRenderer; -import jalview.json.binding.v1.BioJsAlignmentPojo; -import jalview.json.binding.v1.BioJsFeaturePojo; -import jalview.json.binding.v1.BioJsSeqPojo; +import jalview.json.binding.v1.AlignmentPojo; +import jalview.json.binding.v1.FeaturePojo; +import jalview.json.binding.v1.SequencePojo; import jalview.schemes.ColourSchemeProperty; import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; @@ -117,7 +117,7 @@ public class BioJsHTMLOutput public String getJalviewAlignmentAsJsonString(AlignmentI alignment) throws IOException, JSONException { - BioJsAlignmentPojo bjsAlignment = new BioJsAlignmentPojo(); + AlignmentPojo bjsAlignment = new AlignmentPojo(); bjsAlignment.setGlobalColorScheme(getGlobalColorScheme()); bjsAlignment.setJalviewVersion(jalviewVersion); @@ -130,7 +130,7 @@ public class BioJsHTMLOutput name.append(seq.getName()).append("/").append(seq.getStart()) .append("-").append(seq.getEnd()); - BioJsSeqPojo seqPojo = new BioJsSeqPojo(); + SequencePojo seqPojo = new SequencePojo(); seqPojo.setId(String.valueOf(++count)); seqPojo.setEnd(seq.getEnd()); seqPojo.setStart(seq.getStart()); @@ -140,7 +140,7 @@ public class BioJsHTMLOutput SequenceFeature[] seqFeatures = seq.getSequenceFeatures(); if (seqFeatures != null) { - ArrayList bjsSeqFeatures = new ArrayList(); + ArrayList bjsSeqFeatures = new ArrayList(); for (SequenceFeature sf : seqFeatures) { if (displayedFeatures != null @@ -151,11 +151,11 @@ public class BioJsHTMLOutput String featureColour = jalview.util.Format.getHexString(fr .findFeatureColour(Color.white, seq, seq.findIndex(sf.getBegin()))); - BioJsFeaturePojo bjsFeature = new BioJsFeaturePojo(); + FeaturePojo bjsFeature = new FeaturePojo(); bjsFeature.setFillColor(featureColour); bjsFeature.setXstart(seq.findIndex(sf.getBegin()) - 1); bjsFeature.setXend(seq.findIndex(sf.getEnd())); - bjsFeature.setText(sf.getType()); + bjsFeature.setType(sf.getType()); bjsSeqFeatures.add(bjsFeature); } } diff --git a/src/jalview/io/FileLoader.java b/src/jalview/io/FileLoader.java index 3322689..cd9258c 100755 --- a/src/jalview/io/FileLoader.java +++ b/src/jalview/io/FileLoader.java @@ -30,7 +30,6 @@ import jalview.gui.Jalview2XML; import jalview.structure.StructureSelectionManager; import jalview.util.MessageManager; -import java.util.List; import java.util.StringTokenizer; import java.util.Vector; @@ -323,7 +322,7 @@ public class FileLoader implements Runnable } if (sq.getPDBId() != null) { - for (PDBEntry pdbe : (List) sq.getPDBId()) + for (PDBEntry pdbe : sq.getPDBId()) { StructureSelectionManager.getStructureSelectionManager( Desktop.instance).registerPDBEntry(pdbe); @@ -350,8 +349,12 @@ public class FileLoader implements Runnable if (source instanceof HtmlFile) { ((HtmlFile) source).LoadAlignmentFeatures(alignFrame); - } + else if (source instanceof JSONFile) + { + ((JSONFile) source).LoadAlignmentFeatures(alignFrame); + } + if (raiseGUI) { // add the window to the GUI diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index dfbdf86..8f47317 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -259,17 +259,19 @@ public class FormatAdapter extends AppletFormatAdapter throws java.io.IOException { Alignment al; - if (format.equals("HTML")) - { - afile = new HtmlFile(inFile, type); - al = new Alignment(afile.getSeqsAsArray()); - afile.addAnnotations(al); - } - else - { + // if (format.equals(JSONFile.FILE_DESC)) + // { + // // afile = new HtmlFile(inFile, type); + // al = new Alignment(afile.getSeqsAsArray()); + // afile.addAnnotations(al); + // } + // else + // { al = super.readFile(inFile, type, format); - } + // } + afile.addSeqGroups(al); + afile.addAnnotations(al); return al; } @@ -277,16 +279,18 @@ public class FormatAdapter extends AppletFormatAdapter throws java.io.IOException { Alignment al; - if (format.equals("HTML")) - { - afile = new HtmlFile(source); - al = new Alignment(afile.getSeqsAsArray()); - afile.addAnnotations(al); - } - else - { + // if (format.equals(JSONFile.FILE_DESC)) + // { + // // afile = new HtmlFile(source); + // al = new Alignment(afile.getSeqsAsArray()); + // afile.addAnnotations(al); + // } + // else + // { al = (Alignment) super.readFromFile(source, format); - } + // } + afile.addSeqGroups(al); + afile.addAnnotations(al); return al; } @@ -323,4 +327,5 @@ public class FormatAdapter extends AppletFormatAdapter return formatSequences(format, getCacheSuffixDefault(format), av, selectedOnly); } + } diff --git a/src/jalview/io/HtmlFile.java b/src/jalview/io/HtmlFile.java index 3cb7c3f..aadf246 100644 --- a/src/jalview/io/HtmlFile.java +++ b/src/jalview/io/HtmlFile.java @@ -1,17 +1,10 @@ package jalview.io; -import jalview.datamodel.Sequence; -import jalview.datamodel.SequenceFeature; import jalview.gui.AlignFrame; -import jalview.json.binding.v1.BioJsAlignmentPojo.JalviewBioJsColorSchemeMapper; import jalview.schemes.ColourSchemeI; import java.io.IOException; -import java.util.Iterator; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -56,68 +49,73 @@ public class HtmlFile extends AlignFile Element content = doc.getElementById("seqData"); String alignmentJsonString = content.val(); - JSONParser jsonParser = new JSONParser(); - JSONObject alignmentJsonObj = (JSONObject) jsonParser - .parse(alignmentJsonString); - JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs"); - String bioJsColourScheme = (String) alignmentJsonObj - .get("globalColorScheme"); - cs = getJalviewColorScheme(bioJsColourScheme); - - for (Iterator sequenceIter = seqJsonArray.iterator(); sequenceIter - .hasNext();) - { - JSONObject sequence = sequenceIter.next(); - String sequcenceString = sequence.get("seq").toString(); - Sequence seq = new Sequence(sequence.get("name").toString(), - sequcenceString, Integer.valueOf(sequence.get("start") - .toString()), Integer.valueOf(sequence.get("end") - .toString())); - - JSONArray jsonSeqArray = (JSONArray) sequence.get("features"); - SequenceFeature[] retrievedSeqFeatures = getJalviewSequenceFeatures( - jsonSeqArray, seq); - if (retrievedSeqFeatures != null) - { - seq.setSequenceFeatures(retrievedSeqFeatures); - } - seqs.add(seq); - } + new JSONFile().parse(alignmentJsonString); + + // JSONParser jsonParser = new JSONParser(); + // JSONObject alignmentJsonObj = (JSONObject) jsonParser + // .parse(alignmentJsonString); + // JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs"); + // String bioJsColourScheme = (String) alignmentJsonObj + // .get("globalColorScheme"); + // cs = getJalviewColorScheme(bioJsColourScheme); + // + // for (Iterator sequenceIter = seqJsonArray.iterator(); + // sequenceIter + // .hasNext();) + // { + // JSONObject sequence = sequenceIter.next(); + // String sequcenceString = sequence.get("seq").toString(); + // Sequence seq = new Sequence(sequence.get("name").toString(), + // sequcenceString, Integer.valueOf(sequence.get("start") + // .toString()), Integer.valueOf(sequence.get("end") + // .toString())); + // + // JSONArray jsonSeqArray = (JSONArray) sequence.get("features"); + // SequenceFeature[] retrievedSeqFeatures = getJalviewSequenceFeatures( + // jsonSeqArray, seq); + // if (retrievedSeqFeatures != null) + // { + // seq.setSequenceFeatures(retrievedSeqFeatures); + // } + // seqs.add(seq); + // + // } } catch (Exception e) { e.printStackTrace(); } } - public SequenceFeature[] getJalviewSequenceFeatures( - JSONArray jsonSeqFeatures, Sequence seq) - { - SequenceFeature[] seqFeatures = null; - int count = 0; - if (jsonSeqFeatures != null) - { - seqFeatures = new SequenceFeature[jsonSeqFeatures.size()]; - for (@SuppressWarnings("unchecked") - Iterator seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr - .hasNext();) - { - - SequenceFeature sequenceFeature = new SequenceFeature(); - JSONObject jsonFeature = seqFeatureItr.next(); - Long begin = (Long) jsonFeature.get("xStart"); - Long end = (Long) jsonFeature.get("xEnd"); - String type = (String) jsonFeature.get("text"); - // String color = (String) jsonFeature.get("fillColor"); - - sequenceFeature.setBegin(seq.findPosition(begin.intValue())); - sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1); - sequenceFeature.setType(type); - seqFeatures[count++] = sequenceFeature; - } - } - return seqFeatures; - } + // public SequenceFeature[] getJalviewSequenceFeatures( + // JSONArray jsonSeqFeatures, Sequence seq) + // { + // SequenceFeature[] seqFeatures = null; + // int count = 0; + // if (jsonSeqFeatures != null) + // { + // seqFeatures = new SequenceFeature[jsonSeqFeatures.size()]; + // for (@SuppressWarnings("unchecked") + // Iterator seqFeatureItr = jsonSeqFeatures.iterator(); + // seqFeatureItr + // .hasNext();) + // { + // + // SequenceFeature sequenceFeature = new SequenceFeature(); + // JSONObject jsonFeature = seqFeatureItr.next(); + // Long begin = (Long) jsonFeature.get("xStart"); + // Long end = (Long) jsonFeature.get("xEnd"); + // String type = (String) jsonFeature.get("text"); + // // String color = (String) jsonFeature.get("fillColor"); + // + // sequenceFeature.setBegin(seq.findPosition(begin.intValue())); + // sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1); + // sequenceFeature.setType(type); + // seqFeatures[count++] = sequenceFeature; + // } + // } + // return seqFeatures; + // } public void LoadAlignmentFeatures(AlignFrame af) { @@ -127,20 +125,20 @@ public class HtmlFile extends AlignFile af.setMenusForViewport(); } - private ColourSchemeI getJalviewColorScheme(String bioJsColourSchemeName) - { - ColourSchemeI jalviewColor = null; - for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper - .values()) - { - if (cs.getBioJsName().equals(bioJsColourSchemeName)) - { - jalviewColor = cs.getJvColourScheme(); - break; - } - } - return jalviewColor; - } + // private ColourSchemeI getJalviewColorScheme(String bioJsColourSchemeName) + // { + // ColourSchemeI jalviewColor = null; + // for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper + // .values()) + // { + // if (cs.getBioJsName().equals(bioJsColourSchemeName)) + // { + // jalviewColor = cs.getJvColourScheme(); + // break; + // } + // } + // return jalviewColor; + // } @Override public String print() diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index 25cef72..a87f34a 100755 --- a/src/jalview/io/IdentifyFile.java +++ b/src/jalview/io/IdentifyFile.java @@ -136,6 +136,11 @@ public class IdentifyFile break; } + if (data.indexOf("{\"") > -1) + { + reply = JSONFile.FILE_DESC; + break; + } // if (data.matches("<(\"[^\"]*\"|'[^']*'|[^'\">])*>")) if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>")) { diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java new file mode 100644 index 0000000..8b38d84 --- /dev/null +++ b/src/jalview/io/JSONFile.java @@ -0,0 +1,411 @@ +package jalview.io; + +import jalview.api.FeaturesDisplayedI; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.Annotation; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceFeature; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.gui.AlignFrame; +import jalview.gui.Desktop; +import jalview.json.binding.v1.AlignmentAnnotationPojo; +import jalview.json.binding.v1.AlignmentPojo; +import jalview.json.binding.v1.AlignmentPojo.JalviewBioJsColorSchemeMapper; +import jalview.json.binding.v1.AnnotationPojo; +import jalview.json.binding.v1.FeaturePojo; +import jalview.json.binding.v1.SequenceGrpPojo; +import jalview.json.binding.v1.SequencePojo; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.ColourSchemeProperty; +import jalview.viewmodel.AlignmentViewport; + +import java.awt.Color; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + +public class JSONFile extends AlignFile +{ + private ColourSchemeI cs; + + private String jalviewVersion; + + private String webStartLaunchServletUrl = "http://www.jalview.org/services/launchApp"; + + public static final String FILE_EXT = "json"; + + public static final String FILE_DESC = "JSON"; + + private String globalColorScheme; + + private Hashtable seqMap; + + private FeaturesDisplayedI displayedFeatures; + + // private AlignmentI al; + + private AlignmentViewport av; + + private jalview.api.FeatureRenderer fr; + + public JSONFile() + { + super(); + } + + public JSONFile(FileParse source) throws IOException + { + super(source); + } + + public JSONFile(String inFile, String type) throws IOException + { + super(inFile, type); + } + + + @Override + public void parse() throws IOException + { + StringBuilder jsonStringBuilder = new StringBuilder(); + String currentLine; + while ((currentLine = nextLine()) != null) + { + jsonStringBuilder.append(currentLine); + } + parse(jsonStringBuilder.toString()); + + } + + @Override + public String print() + { + AlignmentPojo jsonAlignmentPojo = new AlignmentPojo(); + if (Desktop.getCurrentAlignFrame() != null) + { + jsonAlignmentPojo.setGlobalColorScheme(ColourSchemeProperty + .getColourName(Desktop.getCurrentAlignFrame().getViewport() + .getGlobalColourScheme())); + this.av = Desktop.getCurrentAlignFrame().getCurrentView(); + this.fr = Desktop.getCurrentAlignFrame().alignPanel + .cloneFeatureRenderer(); + displayedFeatures = av.getFeaturesDisplayed(); + } + jsonAlignmentPojo.setJalviewVersion(jalviewVersion); + jsonAlignmentPojo.setWebStartUrl(webStartLaunchServletUrl); + + System.out.println(">>>>>>>>>>>>>> found grps : " + seqGroups.size()); + if (seqGroups.size() > 0) + { + ArrayList sequenceGroupsPojo = new ArrayList(); + for (SequenceGroup seqGrp : seqGroups) + { + System.out.println(">>>>>>>>>>>> grp : " + seqGrp.getName()); + SequenceGrpPojo seqGrpPojo = new SequenceGrpPojo(); + seqGrpPojo.setGroupName(seqGrp.getName()); + seqGrpPojo.setColourScheme(ColourSchemeProperty + .getColourName(seqGrp.cs)); + seqGrpPojo.setColourText(seqGrp.getColourText()); + seqGrpPojo.setDescription(seqGrp.getDescription()); + seqGrpPojo.setDisplayBoxes(seqGrp.getDisplayBoxes()); + seqGrpPojo.setDisplayText(seqGrp.getDisplayText()); + seqGrpPojo.setEndRes(seqGrp.getEndRes()); + seqGrpPojo.setStartRes(seqGrp.getStartRes()); + seqGrpPojo.setShowNonconserved(seqGrp.getShowNonconserved()); + jsonAlignmentPojo.getSequenceGroups().add(seqGrpPojo); + for(SequenceI seq : seqGrp.getSequences()){ + seqGrpPojo.getSeqsHash().add(seq.getName() + "_" + seq.hashCode()); + } + // sequenceGroupsPojo.add(seqGrpPojo); + } + } + for (AlignmentAnnotation annot : annotations) + { + AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo(); + alignAnnotPojo.setDescription(annot.description); + alignAnnotPojo.setLabel(annot.label); + for (Annotation annotation : annot.annotations) + { + AnnotationPojo annotationPojo = new AnnotationPojo(); + if (annotation != null) + { + annotationPojo.setDescription(annotation.description); + annotationPojo.setValue(annotation.value); + annotationPojo + .setSecondaryStructure(annotation.secondaryStructure); + annotationPojo.setDisplayCharacter(annotation.displayCharacter); + alignAnnotPojo.getAnnotations().add(annotationPojo); + } + else + { + alignAnnotPojo.getAnnotations().add(annotationPojo); + } + } + jsonAlignmentPojo.getAlignmentAnnotation().add(alignAnnotPojo); + } + + int count = 0; + for (SequenceI seq : seqs) + { + StringBuilder name = new StringBuilder(); + name.append(seq.getName()).append("/").append(seq.getStart()) + .append("-").append(seq.getEnd()); + + SequencePojo jsonSeqPojo = new SequencePojo(); + + jsonSeqPojo.setId(seq.getName() + "_" + seq.hashCode()); + jsonSeqPojo.setOrder(++count); + jsonSeqPojo.setEnd(seq.getEnd()); + jsonSeqPojo.setStart(seq.getStart()); + jsonSeqPojo.setName(name.toString()); + jsonSeqPojo.setSeq(seq.getSequenceAsString()); + jsonAlignmentPojo.getSeqs().add(jsonSeqPojo); + + if (seq.getDatasetSequence() != null + && seq.getDatasetSequence().getSequenceFeatures() != null) + { + ArrayList seqFeaturesPojo = new ArrayList(); + for (SequenceFeature sf : seq.getDatasetSequence() + .getSequenceFeatures()) + { + + if (displayedFeatures != null + && displayedFeatures.isVisible(sf.getType())) + { + + String fillColor = ((fr != null) ? jalview.util.Format + .getHexString(fr.findFeatureColour(Color.white, seq, + seq.findIndex(sf.getBegin()))) : null); + FeaturePojo jsonFeature = new FeaturePojo(); + jsonFeature.setXstart(seq.findIndex(sf.getBegin()) - 1); + jsonFeature.setXend(seq.findIndex(sf.getEnd())); + jsonFeature.setType(sf.getType()); + jsonFeature.setDescription(sf.getDescription()); + jsonFeature.setLinks(sf.links); + jsonFeature.setOtherDetails(sf.otherDetails); + jsonFeature.setScore(sf.getScore()); + jsonFeature.setFillColor(fillColor); + jsonFeature.setFeatureGroup(sf.getFeatureGroup()); + seqFeaturesPojo.add(jsonFeature); + } + } + jsonSeqPojo.setFeatures(seqFeaturesPojo); + } + } + return new com.json.JSONObject(jsonAlignmentPojo).toString() + .replaceAll("xstart", "xStart").replaceAll("xend", "xEnd"); + } + + public void parse(String jsonAlignmentString) + { + try + { + JSONParser jsonParser = new JSONParser(); + JSONObject alignmentJsonObj = (JSONObject) jsonParser + .parse(jsonAlignmentString); + JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs"); + JSONArray alAnnotJsonArray = (JSONArray) alignmentJsonObj.get("alignmentAnnotation"); + JSONArray seqGrpJsonArray = (JSONArray) alignmentJsonObj.get("sequenceGroups"); + String jsColourScheme = (String) alignmentJsonObj + .get("globalColorScheme"); + System.out.println(">>>>>>>>>>>>>>>> global cs : " + jsColourScheme); + cs = getJalviewColorScheme(jsColourScheme); + seqMap = new Hashtable(); + Desktop.setCurrentGlobalColourScheme(cs); + for (Iterator sequenceIter = seqJsonArray.iterator(); sequenceIter + .hasNext();) + { + JSONObject sequence = sequenceIter.next(); + String sequcenceString = sequence.get("seq").toString(); + String sequenceName = sequence.get("name").toString(); + String seqUniqueId = sequence.get("id").toString(); + int start = Integer.valueOf(sequence.get("start").toString()); + int end = Integer.valueOf(sequence.get("end").toString()); + Sequence seq = new Sequence(sequenceName, sequcenceString, start, + end); + JSONArray jsonSeqArray = (JSONArray) sequence.get("features"); + SequenceFeature[] retrievedSeqFeatures = getJalviewSequenceFeatures( + jsonSeqArray, seq); + if (retrievedSeqFeatures != null) + { + seq.setSequenceFeatures(retrievedSeqFeatures); + } + seqs.add(seq); + seqMap.put(seqUniqueId, seq); + } + + // for (Iterator seqGrpIter = seqGrpJsonArray.iterator(); + // seqGrpIter + // .hasNext();) + // { + // JSONObject seqGrpObj = seqGrpIter.next(); + // String grpName = seqGrpObj.get("groupName").toString(); + // String colourScheme = seqGrpObj.get("colourScheme").toString(); + // String description = (seqGrpObj.get("description") == null) ? null + // : seqGrpObj.get("description").toString(); + // boolean displayBoxes = Boolean.valueOf(seqGrpObj + // .get("displayBoxes").toString()); + // boolean displayText = Boolean.valueOf(seqGrpObj.get("displayText") + // .toString()); + // boolean colourText = Boolean.valueOf(seqGrpObj.get("colourText") + // .toString()); + // boolean showNonconserved = Boolean.valueOf(seqGrpObj.get( + // "showNonconserved").toString()); + // int startRes = Integer + // .valueOf(seqGrpObj.get("startRes").toString()); + // int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString()); + // JSONArray seqsHashArray = (JSONArray) seqGrpObj.get("seqsHash"); + // + // ArrayList grpSeqs = new ArrayList(); + // if (seqsHashArray.size() > 0) + // { + // Iterator seqHashIter = seqsHashArray.iterator(); + // + // while (seqHashIter.hasNext()) + // { + // String seqHash = seqHashIter.next(); + // Sequence sequence = seqMap.get(seqHash); + // if (sequence != null) + // { + // grpSeqs.add(sequence); + // } + // // System.out.println(">>>>>>>>>>>>>>>>>>>>>>> seqHash : " + // // + seqHash); + // } + // } + // System.out.println(">>>>>>>>>>>>>>>>>> scheme string : " + // + colourScheme); + // ColourSchemeI scheme = getJalviewColorScheme(colourScheme); + // System.out.println(">>>>>>>>>>>>>>>>>> scheme: " + scheme); + // SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, scheme, + // displayBoxes, displayText, colourText, startRes, endRes); + // this.seqGroups.add(seqGrp); + // + // } + + + for (Iterator alAnnotIter = alAnnotJsonArray.iterator(); alAnnotIter + .hasNext();) + { + JSONObject alAnnot = alAnnotIter.next(); + JSONArray annotJsonArray = (JSONArray) alAnnot + .get("annotations"); + Annotation[] annotations = new Annotation[annotJsonArray.size()]; + int count = 0; + for (Iterator annotIter = annotJsonArray.iterator(); annotIter + .hasNext();) + { + JSONObject annot = annotIter.next(); + if (annot == null) + { + annotations[count] = null; + } + else + { + float val = annot.get("value") == null ? null + : Float.valueOf(annot.get("value") + .toString()); + String desc = annot.get("description") == null ? null : annot + .get("description").toString(); + + char ss = annot.get("secondaryStructure") == null ? null + : annot + .get("secondaryStructure").toString().charAt(0); + String displayChar = annot.get( + "displayCharacter").toString(); + + annotations[count] = new Annotation(displayChar, desc, ss, val); + } + ++count; + } + + AlignmentAnnotation alignAnnot = new AlignmentAnnotation(alAnnot + .get("label").toString(), alAnnot.get("description") + .toString(), annotations); + this.annotations.add(alignAnnot); + } + + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public SequenceFeature[] getJalviewSequenceFeatures( + JSONArray jsonSeqFeatures, Sequence seq) + { + SequenceFeature[] seqFeatures = null; + int count = 0; + if (jsonSeqFeatures != null) + { + seqFeatures = new SequenceFeature[jsonSeqFeatures.size()]; + for (@SuppressWarnings("unchecked") + Iterator seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr + .hasNext();) + { + + SequenceFeature sequenceFeature = new SequenceFeature(); + JSONObject jsonFeature = seqFeatureItr.next(); + Long begin = (Long) jsonFeature.get("xStart"); + Long end = (Long) jsonFeature.get("xEnd"); + String type = (String) jsonFeature.get("type"); + // String color = (String) jsonFeature.get("fillColor"); + String featureGrp = (String) jsonFeature.get("featureGroup"); + String descripiton = (String) jsonFeature.get("description"); + Float score = Float.valueOf(jsonFeature.get("score").toString()); + // Hashtable otherDetails = (Hashtable) jsonFeature + // .get("otherDetails"); + // Vector links = (Vector) jsonFeature.get("links"); + + // sequenceFeature.links = links; + // sequenceFeature.otherDetails = otherDetails; + sequenceFeature.setScore(score); + sequenceFeature.setDescription(descripiton); + + sequenceFeature.setBegin(seq.findPosition(begin.intValue())); + sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1); + sequenceFeature.setType(type); + seqFeatures[count++] = sequenceFeature; + } + } + return seqFeatures; + } + + private ColourSchemeI getJalviewColorScheme(String bioJsColourSchemeName) + { + ColourSchemeI jalviewColor = null; + for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper + .values()) + { + if (cs.getBioJsName().equalsIgnoreCase(bioJsColourSchemeName)) + { + jalviewColor = cs.getJvColourScheme(); + break; + } + } + return jalviewColor; + } + + public void LoadAlignmentFeatures(AlignFrame af) + { + af.setShowSeqFeatures(true); + af.changeColour(cs); + af.setMenusForViewport(); + } + + public String getGlobalColorScheme() + { + return globalColorScheme; + } + + public void setGlobalColorScheme(String globalColorScheme) + { + this.globalColorScheme = globalColorScheme; + } +} diff --git a/src/jalview/json/binding/v1/AlignmentAnnotationPojo.java b/src/jalview/json/binding/v1/AlignmentAnnotationPojo.java new file mode 100644 index 0000000..4cdc3d1 --- /dev/null +++ b/src/jalview/json/binding/v1/AlignmentAnnotationPojo.java @@ -0,0 +1,43 @@ +package jalview.json.binding.v1; + +import java.util.ArrayList; +import java.util.List; + +public class AlignmentAnnotationPojo +{ + private String label; + + private String description; + + private List annotations = new ArrayList(); + + public String getLabel() + { + return label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String annotationId) + { + this.description = annotationId; + } + + public List getAnnotations() + { + return annotations; + } + + public void setAnnotations(List annotations) + { + this.annotations = annotations; + } +} diff --git a/src/jalview/json/binding/v1/BioJsAlignmentPojo.java b/src/jalview/json/binding/v1/AlignmentPojo.java similarity index 82% rename from src/jalview/json/binding/v1/BioJsAlignmentPojo.java rename to src/jalview/json/binding/v1/AlignmentPojo.java index 8e8747f..48c477d 100644 --- a/src/jalview/json/binding/v1/BioJsAlignmentPojo.java +++ b/src/jalview/json/binding/v1/AlignmentPojo.java @@ -15,26 +15,33 @@ import jalview.schemes.TurnColourScheme; import jalview.schemes.ZappoColourScheme; import java.util.ArrayList; +import java.util.List; -public class BioJsAlignmentPojo +public class AlignmentPojo { private String globalColorScheme = "none"; private String jalviewVersion; private String webStartUrl; - private ArrayList seqs = new ArrayList(); - public BioJsAlignmentPojo() + private List seqs = new ArrayList(); + + private List alignmentAnnotation = new ArrayList(); + + private List sequenceGroups = new ArrayList(); + + public AlignmentPojo() { } - public ArrayList getSeqs() + + public List getSeqs() { return seqs; } - public void setSeqs(ArrayList seqs) + public void setSeqs(ArrayList seqs) { this.seqs = seqs; } @@ -89,6 +96,26 @@ public class BioJsAlignmentPojo this.webStartUrl = webStartUrl; } + public List getAlignmentAnnotation() + { + return alignmentAnnotation; + } + + public void setAlignmentAnnotation(List alignmentAnnotation) + { + this.alignmentAnnotation = alignmentAnnotation; + } + + public List getSequenceGroups() + { + return sequenceGroups; + } + + public void setSequenceGroups(List sequenceGroups) + { + this.sequenceGroups = sequenceGroups; + } + public enum JalviewBioJsColorSchemeMapper { USER_DEFINED("User Defined", "user defined", null), NONE("None", "foo", diff --git a/src/jalview/json/binding/v1/AnnotationPojo.java b/src/jalview/json/binding/v1/AnnotationPojo.java new file mode 100644 index 0000000..2e5aac4 --- /dev/null +++ b/src/jalview/json/binding/v1/AnnotationPojo.java @@ -0,0 +1,54 @@ +package jalview.json.binding.v1; + + +public class AnnotationPojo +{ + private String displayCharacter = ""; + + private String description; + + private char secondaryStructure; + + private float value; + + + public String getDisplayCharacter() + { + return displayCharacter; + } + + public void setDisplayCharacter(String displayCharacter) + { + this.displayCharacter = displayCharacter; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + + public char getSecondaryStructure() + { + return secondaryStructure; + } + + public void setSecondaryStructure(char secondaryStructure) + { + this.secondaryStructure = secondaryStructure; + } + + public float getValue() + { + return value; + } + + public void setValue(float value) + { + this.value = value; + } +} diff --git a/src/jalview/json/binding/v1/BioJsFeaturePojo.java b/src/jalview/json/binding/v1/BioJsFeaturePojo.java deleted file mode 100644 index 3c2fdda..0000000 --- a/src/jalview/json/binding/v1/BioJsFeaturePojo.java +++ /dev/null @@ -1,60 +0,0 @@ -package jalview.json.binding.v1; - -public class BioJsFeaturePojo -{ - - private int xstart; - - private int xend; - - private String text; - - private String fillColor; - - public BioJsFeaturePojo() - { - } - - - public String getText() - { - return text; - } - - public void setText(String text) - { - this.text = text; - } - - public String getFillColor() - { - return "#" + fillColor; - } - - public void setFillColor(String fillColor) - { - this.fillColor = fillColor; - } - - public int getXstart() - { - return xstart; - } - - public void setXstart(int xstart) - { - this.xstart = xstart; - } - - public int getXend() - { - return xend; - } - - public void setXend(int xend) - { - this.xend = xend; - } - - -} diff --git a/src/jalview/json/binding/v1/FeaturePojo.java b/src/jalview/json/binding/v1/FeaturePojo.java new file mode 100644 index 0000000..404f6bc --- /dev/null +++ b/src/jalview/json/binding/v1/FeaturePojo.java @@ -0,0 +1,120 @@ +package jalview.json.binding.v1; + +import java.util.Hashtable; +import java.util.Vector; + +public class FeaturePojo +{ + + private int xstart; + + private int xend; + + private String type; + + private String fillColor; + + private Float score; + + private String description; + + private Hashtable otherDetails; + + private String featureGroup; + + private Vector links; + + public FeaturePojo() + { + } + + public String getFillColor() + { + return "#" + fillColor; + } + + public void setFillColor(String fillColor) + { + this.fillColor = fillColor; + } + + public int getXstart() + { + return xstart; + } + + public void setXstart(int xstart) + { + this.xstart = xstart; + } + + public int getXend() + { + return xend; + } + + public void setXend(int xend) + { + this.xend = xend; + } + + public String getType() + { + return type; + } + + public void setType(String type) + { + this.type = type; + } + + public Float getScore() + { + return score; + } + + public void setScore(Float score) + { + this.score = score; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + + public Hashtable getOtherDetails() + { + return otherDetails; + } + + public void setOtherDetails(Hashtable otherDetails) + { + this.otherDetails = otherDetails; + } + + public Vector getLinks() + { + return links; + } + + public void setLinks(Vector links) + { + this.links = links; + } + + public String getFeatureGroup() + { + return featureGroup; + } + + public void setFeatureGroup(String featureGroup) + { + this.featureGroup = featureGroup; + } +} diff --git a/src/jalview/json/binding/v1/SequenceGrpPojo.java b/src/jalview/json/binding/v1/SequenceGrpPojo.java new file mode 100644 index 0000000..bb0e724 --- /dev/null +++ b/src/jalview/json/binding/v1/SequenceGrpPojo.java @@ -0,0 +1,126 @@ +package jalview.json.binding.v1; + +import java.util.ArrayList; + +public class SequenceGrpPojo +{ + private String colourScheme; + + private String groupName; + + private String description; + + private boolean displayBoxes; + + private boolean displayText; + + private boolean colourText; + + private boolean showNonconserved; + + private int startRes; + + private int endRes; + + private ArrayList seqsHash = new ArrayList(); + + public String getColourScheme() + { + return colourScheme; + } + + public void setColourScheme(String colourScheme) + { + this.colourScheme = colourScheme; + } + + public String getGroupName() + { + return groupName; + } + + public void setGroupName(String groupName) + { + this.groupName = groupName; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + + public boolean isDisplayBoxes() + { + return displayBoxes; + } + + public void setDisplayBoxes(boolean displayBoxes) + { + this.displayBoxes = displayBoxes; + } + + public boolean isDisplayText() + { + return displayText; + } + + public void setDisplayText(boolean displayText) + { + this.displayText = displayText; + } + + public boolean isColourText() + { + return colourText; + } + + public void setColourText(boolean colourText) + { + this.colourText = colourText; + } + + public boolean isShowNonconserved() + { + return showNonconserved; + } + + public void setShowNonconserved(boolean showNonconserved) + { + this.showNonconserved = showNonconserved; + } + + public int getStartRes() + { + return startRes; + } + + public void setStartRes(int startRes) + { + this.startRes = startRes; + } + + public int getEndRes() + { + return endRes; + } + + public void setEndRes(int endRes) + { + this.endRes = endRes; + } + + public ArrayList getSeqsHash() + { + return seqsHash; + } + + public void setSeqsHash(ArrayList seqsHash) + { + this.seqsHash = seqsHash; + } +} diff --git a/src/jalview/json/binding/v1/BioJsSeqPojo.java b/src/jalview/json/binding/v1/SequencePojo.java similarity index 67% rename from src/jalview/json/binding/v1/BioJsSeqPojo.java rename to src/jalview/json/binding/v1/SequencePojo.java index bac8601..762acaf 100644 --- a/src/jalview/json/binding/v1/BioJsSeqPojo.java +++ b/src/jalview/json/binding/v1/SequencePojo.java @@ -3,7 +3,7 @@ package jalview.json.binding.v1; import java.util.ArrayList; -public class BioJsSeqPojo +public class SequencePojo { private String seq; @@ -11,17 +11,19 @@ public class BioJsSeqPojo private String id; + private int order; + private int start; private int end; - private ArrayList features = new ArrayList(); + private ArrayList features = new ArrayList(); - public BioJsSeqPojo() + public SequencePojo() { } - public BioJsSeqPojo(int start, int end, String id, String name, String seq) + public SequencePojo(int start, int end, String id, String name, String seq) { this.id = id; this.name = name; @@ -78,13 +80,23 @@ public class BioJsSeqPojo this.end = end; } - public ArrayList getFeatures() + public ArrayList getFeatures() { return features; } - public void setFeatures(ArrayList features) + public void setFeatures(ArrayList features) { this.features = features; } + + public int getOrder() + { + return order; + } + + public void setOrder(int order) + { + this.order = order; + } } -- 1.7.10.2