From c7d9dbc9b92889077b91bcdb052032fe33fb269e Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Fri, 14 Aug 2015 16:37:13 +0100 Subject: [PATCH] JAL-1831 added changes to allow auto-generation of BioJSON schema from src code --- src/com/github/reinert/jjschema/Attributes.java | 67 ++++++++ src/jalview/io/BioJsHTMLOutput.java | 4 +- src/jalview/io/JSONFile.java | 58 ++++--- .../binding/{v1 => biojs}/BioJSReleasePojo.java | 2 +- .../binding/{v1 => biojs}/BioJSRepositoryPojo.java | 2 +- .../{ => biojson}/v1/AlignmentAnnotationPojo.java | 8 +- .../json/binding/biojson/v1/AlignmentPojo.java | 112 +++++++++++++ .../json/binding/biojson/v1/AnnotationPojo.java | 60 +++++++ .../binding/{ => biojson}/v1/AppSettingsPojo.java | 2 +- .../biojson/v1/JalviewBioJsColorSchemeMapper.java | 74 +++++++++ .../{ => biojson}/v1/SequenceFeaturesPojo.java | 47 ++++-- .../binding/{ => biojson}/v1/SequenceGrpPojo.java | 19 ++- .../binding/{ => biojson}/v1/SequencePojo.java | 16 +- src/jalview/json/binding/v1/AlignmentPojo.java | 168 -------------------- src/jalview/json/binding/v1/AnnotationPojo.java | 55 ------- test/jalview/io/BioJsHTMLOutputTest.java | 4 +- 16 files changed, 418 insertions(+), 280 deletions(-) create mode 100755 src/com/github/reinert/jjschema/Attributes.java rename src/jalview/json/binding/{v1 => biojs}/BioJSReleasePojo.java (93%) rename src/jalview/json/binding/{v1 => biojs}/BioJSRepositoryPojo.java (98%) rename src/jalview/json/binding/{ => biojson}/v1/AlignmentAnnotationPojo.java (66%) create mode 100644 src/jalview/json/binding/biojson/v1/AlignmentPojo.java create mode 100644 src/jalview/json/binding/biojson/v1/AnnotationPojo.java rename src/jalview/json/binding/{ => biojson}/v1/AppSettingsPojo.java (98%) create mode 100644 src/jalview/json/binding/biojson/v1/JalviewBioJsColorSchemeMapper.java rename src/jalview/json/binding/{ => biojson}/v1/SequenceFeaturesPojo.java (51%) rename src/jalview/json/binding/{ => biojson}/v1/SequenceGrpPojo.java (59%) rename src/jalview/json/binding/{ => biojson}/v1/SequencePojo.java (53%) delete mode 100644 src/jalview/json/binding/v1/AlignmentPojo.java delete mode 100644 src/jalview/json/binding/v1/AnnotationPojo.java diff --git a/src/com/github/reinert/jjschema/Attributes.java b/src/com/github/reinert/jjschema/Attributes.java new file mode 100755 index 0000000..f6a3d47 --- /dev/null +++ b/src/com/github/reinert/jjschema/Attributes.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014, Danilo Reinert (daniloreinert@growbit.com) + * + * This software is dual-licensed under: + * + * - the Lesser General Public License (LGPL) version 3.0 or, at your option, any + * later version; + * - the Apache Software License (ASL) version 2.0. + * + * The text of both licenses is available under the src/resources/ directory of + * this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively). + * + * Direct link to the sources: + * + * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt + * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt + */ + +package com.github.reinert.jjschema; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation for the attributes of JSON Schema + * + * @author reinert + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) +public @interface Attributes { + String $ref() default ""; + + String id() default ""; + + String title() default ""; + + String description() default ""; + + long maximum() default -1l; + + boolean exclusiveMaximum() default false; + + int minimum() default -1; + + boolean exclusiveMinimum() default false; + + String pattern() default ""; + + boolean required() default false; + + String[] enums() default {}; + + int minItems() default 0; + + long maxItems() default -1l; + + boolean uniqueItems() default false; + + int multipleOf() default 0; + + int minLength() default 0; + + long maxLength() default -1l; +} diff --git a/src/jalview/io/BioJsHTMLOutput.java b/src/jalview/io/BioJsHTMLOutput.java index 73be79f..528ba09 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -3,8 +3,8 @@ package jalview.io; import jalview.api.AlignmentViewPanel; import jalview.datamodel.AlignmentExportData; import jalview.exceptions.NoFileSelectedException; -import jalview.json.binding.v1.BioJSReleasePojo; -import jalview.json.binding.v1.BioJSRepositoryPojo; +import jalview.json.binding.biojs.BioJSReleasePojo; +import jalview.json.binding.biojs.BioJSRepositoryPojo; import jalview.util.MessageManager; import java.io.BufferedInputStream; diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index 89518e5..8c790cc 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -37,13 +37,13 @@ import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; -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.SequenceFeaturesPojo; -import jalview.json.binding.v1.SequenceGrpPojo; -import jalview.json.binding.v1.SequencePojo; +import jalview.json.binding.biojson.v1.AlignmentAnnotationPojo; +import jalview.json.binding.biojson.v1.AlignmentPojo; +import jalview.json.binding.biojson.v1.AnnotationPojo; +import jalview.json.binding.biojson.v1.JalviewBioJsColorSchemeMapper; +import jalview.json.binding.biojson.v1.SequenceFeaturesPojo; +import jalview.json.binding.biojson.v1.SequenceGrpPojo; +import jalview.json.binding.biojson.v1.SequencePojo; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; import jalview.viewmodel.seqfeatures.FeaturesDisplayed; @@ -93,7 +93,6 @@ public class JSONFile extends AlignFile implements ComplexAlignFile private ArrayList hiddenSequences; - public JSONFile() { super(); @@ -115,6 +114,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile parse(getReader()); } + @Override public String print() { @@ -188,15 +188,13 @@ public class JSONFile extends AlignFile implements ComplexAlignFile if (hiddenSections != null) { if (hiddenSections[0] != null - && exportSettings - .isExportHiddenColumns()) + && exportSettings.isExportHiddenColumns()) { jsonAlignmentPojo.getAppSettings().put("hiddenCols", String.valueOf(hiddenSections[0])); } if (hiddenSections[1] != null - && exportSettings - .isExportHiddenSequences()) + && exportSettings.isExportHiddenSequences()) { jsonAlignmentPojo.getAppSettings().put("hiddenSeqs", String.valueOf(hiddenSections[1])); @@ -215,8 +213,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile .setSeqFeatures(sequenceFeatureToJsonPojo(seqs, fr)); } - if (exportSettings.isExportGroups() - && seqGroups != null + if (exportSettings.isExportGroups() && seqGroups != null && seqGroups.size() > 0) { for (SequenceGroup seqGrp : seqGroups) @@ -305,8 +302,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile public List sequenceFeatureToJsonPojo( List seqs, FeatureRenderer fr) { - displayedFeatures = (fr == null) ? null : fr - .getFeaturesDisplayed(); + displayedFeatures = (fr == null) ? null : fr.getFeaturesDisplayed(); List sequenceFeaturesPojo = new ArrayList(); for (SequenceI seq : seqs) { @@ -330,8 +326,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile String.valueOf(seq.hashCode())); String featureColour = (fr == null) ? null : jalview.util.Format - .getHexString(fr - .findFeatureColour(Color.white, seq, + .getHexString(fr.findFeatureColour(Color.white, seq, seq.findIndex(sf.getBegin()))); jsonFeature.setXstart(seq.findIndex(sf.getBegin()) - 1); jsonFeature.setXend(seq.findIndex(sf.getEnd())); @@ -473,8 +468,8 @@ public class JSONFile extends AlignFile implements ComplexAlignFile } ColourSchemeI grpColourScheme = getJalviewColorScheme(colourScheme); SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, - grpColourScheme, - displayBoxes, displayText, colourText, startRes, endRes); + grpColourScheme, displayBoxes, displayText, colourText, + startRes, endRes); seqGrp.setShowNonconserved(showNonconserved); seqGrp.setDescription(description); this.seqGroups.add(seqGrp); @@ -503,9 +498,10 @@ public class JSONFile extends AlignFile implements ComplexAlignFile String desc = annot.get("description") == null ? null : annot .get("description").toString(); - char ss = annot.get("secondaryStructure") == null ? ' ' - : annot.get("secondaryStructure").toString().charAt(0); - String displayChar = annot.get("displayCharacter").toString(); + char ss = annot.get("secondaryStructure") == null ? ' ' : annot + .get("secondaryStructure").toString().charAt(0); + String displayChar = annot.get("displayCharacter") == null ? "" + : annot.get("displayCharacter").toString(); annotations[count] = new Annotation(displayChar, desc, ss, val); } @@ -529,9 +525,11 @@ public class JSONFile extends AlignFile implements ComplexAlignFile { hiddenSeqRefs = new ArrayList(); String hiddenSeqs = (String) jvSettingsJson.get("hiddenSeqs"); - if(hiddenSeqs != null && !hiddenSeqs.isEmpty()){ + if (hiddenSeqs != null && !hiddenSeqs.isEmpty()) + { String[] seqRefs = hiddenSeqs.split(";"); - for(String seqRef : seqRefs){ + for (String seqRef : seqRefs) + { hiddenSeqRefs.add(seqRef); } } @@ -540,10 +538,12 @@ public class JSONFile extends AlignFile implements ComplexAlignFile public void parseHiddenCols(JSONObject jvSettingsJson) { String hiddenCols = (String) jvSettingsJson.get("hiddenCols"); - if(hiddenCols != null && !hiddenCols.isEmpty()){ + if (hiddenCols != null && !hiddenCols.isEmpty()) + { columnSelection = new ColumnSelection(); String[] rangeStrings = hiddenCols.split(";"); - for(String rangeString : rangeStrings){ + for (String rangeString : rangeStrings) + { String[] range = rangeString.split("-"); columnSelection.hideColumns(Integer.valueOf(range[0]), Integer.valueOf(range[1])); @@ -640,7 +640,6 @@ public class JSONFile extends AlignFile implements ComplexAlignFile this.displayedFeatures = displayedFeatures; } - public void configureForView(AlignmentViewPanel avpanel) { super.configureForView(avpanel); @@ -704,8 +703,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile { if (hiddenSequences == null || hiddenSequences.isEmpty()) { - return new SequenceI[] - {}; + return new SequenceI[] {}; } synchronized (hiddenSequences) { diff --git a/src/jalview/json/binding/v1/BioJSReleasePojo.java b/src/jalview/json/binding/biojs/BioJSReleasePojo.java similarity index 93% rename from src/jalview/json/binding/v1/BioJSReleasePojo.java rename to src/jalview/json/binding/biojs/BioJSReleasePojo.java index 61dd308..de8d8b3 100644 --- a/src/jalview/json/binding/v1/BioJSReleasePojo.java +++ b/src/jalview/json/binding/biojs/BioJSReleasePojo.java @@ -1,4 +1,4 @@ -package jalview.json.binding.v1; +package jalview.json.binding.biojs; public class BioJSReleasePojo { diff --git a/src/jalview/json/binding/v1/BioJSRepositoryPojo.java b/src/jalview/json/binding/biojs/BioJSRepositoryPojo.java similarity index 98% rename from src/jalview/json/binding/v1/BioJSRepositoryPojo.java rename to src/jalview/json/binding/biojs/BioJSRepositoryPojo.java index 1e6ef7e..46b4ab8 100644 --- a/src/jalview/json/binding/v1/BioJSRepositoryPojo.java +++ b/src/jalview/json/binding/biojs/BioJSRepositoryPojo.java @@ -1,4 +1,4 @@ -package jalview.json.binding.v1; +package jalview.json.binding.biojs; import java.util.ArrayList; import java.util.Collection; diff --git a/src/jalview/json/binding/v1/AlignmentAnnotationPojo.java b/src/jalview/json/binding/biojson/v1/AlignmentAnnotationPojo.java similarity index 66% rename from src/jalview/json/binding/v1/AlignmentAnnotationPojo.java rename to src/jalview/json/binding/biojson/v1/AlignmentAnnotationPojo.java index 32c433b..6f21a2a 100644 --- a/src/jalview/json/binding/v1/AlignmentAnnotationPojo.java +++ b/src/jalview/json/binding/biojson/v1/AlignmentAnnotationPojo.java @@ -1,16 +1,22 @@ -package jalview.json.binding.v1; +package jalview.json.binding.biojson.v1; import java.util.ArrayList; import java.util.List; +import com.github.reinert.jjschema.Attributes; + public class AlignmentAnnotationPojo { + @Attributes(required = true, description = "Serial version id for the alignAnnotation object model") private String svid = "1.0"; + @Attributes(required = false, description = "Label for the Alignment Annotation") private String label; + @Attributes(required = false, description = "Description for the Alignment Annotation") private String description; + @Attributes(required = false) private List annotations = new ArrayList(); public String getLabel() diff --git a/src/jalview/json/binding/biojson/v1/AlignmentPojo.java b/src/jalview/json/binding/biojson/v1/AlignmentPojo.java new file mode 100644 index 0000000..2625b69 --- /dev/null +++ b/src/jalview/json/binding/biojson/v1/AlignmentPojo.java @@ -0,0 +1,112 @@ +package jalview.json.binding.biojson.v1; + + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.github.reinert.jjschema.Attributes; + +@Attributes(title="BioJSON", description="A specification for the representation and exchange of bioinformatics data") +public class AlignmentPojo +{ + @Attributes(required = true, description = "Serial version identifier for BioJSON schema") + private String svid = "1.0"; + + @Attributes(required = true, minItems = 1, maxItems = 1999999999, description = "A sequence group is a bracket of alignment residues spanning
across multiple columns and rows. These can be treated as a
sub-alignments.") + private List seqs = new ArrayList(); + + @Attributes(required = false, minItems = 0, maxItems = 1999999999, exclusiveMaximum=true, description = "Alignment annotations stores symbols and graphs usually rendered
below the alignment.") + private List alignAnnotation = new ArrayList(); + + @Attributes(required = false, minItems = 0, maxItems = 1999999999, description = "A sequence group is a bracket of alignment residues spanning
across multiple columns and rows. These can be treated as a
sub-alignments.") + private List seqGroups = new ArrayList(); + + @Attributes(required = false, minItems = 0, maxItems = 1999999999, description = "Sequence features are associated with sequences rather than
alignments. A sequence feature can span across multiple
sequences in an alignment. They indicate features generated
by the same analysis process or retrieved from the same database
(such as Uniprot features).") + private List seqFeatures = new ArrayList(); + + @Attributes(required = false, enums = { "None", "Custom", "Clustal", + "Zappo", "Taylor", "Nucleotide", "Pyrimidine", "Purine", "Turn", + "Strand", "Buried", "Hydro" }) + private String colourScheme; + + @Attributes(required = true, maxItems = 1, description = "This is an array of key=value pairs for storing custom application
specific settings") + Map appSettings = new HashMap(); + + public AlignmentPojo() + { + } + + public List getSeqs() + { + return seqs; + } + + public void setSeqs(ArrayList seqs) + { + this.seqs = seqs; + } + + public Map getAppSettings() + { + return appSettings; + } + + public void setAppSettings(Map appSettings) + { + this.appSettings = appSettings; + } + + public List getAlignAnnotation() + { + return alignAnnotation; + } + + public void setAlignAnnotation( + List alignAnnotation) + { + this.alignAnnotation = alignAnnotation; + } + + public List getSeqGroups() + { + return seqGroups; + } + + public void setSeqGroups(List seqGroups) + { + this.seqGroups = seqGroups; + } + + public List getSeqFeatures() + { + return seqFeatures; + } + + public void setSeqFeatures(List seqFeatures) + { + this.seqFeatures = seqFeatures; + } + + public String getSvid() + { + return svid; + } + + public void setGlobalColorScheme(String globalColorScheme) + { +// this.appSettings.put("globalColorScheme", globalColorScheme); + } + + public String getColourScheme() + { + return colourScheme; + } + + public void setColourScheme(String colourScheme) + { + this.colourScheme = colourScheme; + } + +} diff --git a/src/jalview/json/binding/biojson/v1/AnnotationPojo.java b/src/jalview/json/binding/biojson/v1/AnnotationPojo.java new file mode 100644 index 0000000..919f6ab --- /dev/null +++ b/src/jalview/json/binding/biojson/v1/AnnotationPojo.java @@ -0,0 +1,60 @@ +package jalview.json.binding.biojson.v1; + +import com.github.reinert.jjschema.Attributes; + +public class AnnotationPojo +{ + @Attributes(required = false, description = "Display character for the given annotation") + private String displayCharacter; + + @Attributes(required = false, description = "Description for the annotation") + private String description; + + @Attributes(required = true, enums = {"E", "H", "\u0000", ")", "("}, description = "Determines what is rendered for the secondary
structure
  • ’E’ - indicates Beta Sheet/Strand
  • ’H’ - indicates alpha helix
  • ‘\\u0000’ - indicates blank

For RNA Helix (only shown when working with
nucleotide sequences):
  • ‘(’ - indicates bases pair with columns upstream
    (to right)
  • ’(’ - indicate region pairs with bases to the left
") + private char secondaryStructure; + + @Attributes(required = false, description = "Value of the annotation") + 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/AppSettingsPojo.java b/src/jalview/json/binding/biojson/v1/AppSettingsPojo.java similarity index 98% rename from src/jalview/json/binding/v1/AppSettingsPojo.java rename to src/jalview/json/binding/biojson/v1/AppSettingsPojo.java index cfc9347..3385682 100644 --- a/src/jalview/json/binding/v1/AppSettingsPojo.java +++ b/src/jalview/json/binding/biojson/v1/AppSettingsPojo.java @@ -1,4 +1,4 @@ -package jalview.json.binding.v1; +package jalview.json.binding.biojson.v1; public class AppSettingsPojo diff --git a/src/jalview/json/binding/biojson/v1/JalviewBioJsColorSchemeMapper.java b/src/jalview/json/binding/biojson/v1/JalviewBioJsColorSchemeMapper.java new file mode 100644 index 0000000..094adad --- /dev/null +++ b/src/jalview/json/binding/biojson/v1/JalviewBioJsColorSchemeMapper.java @@ -0,0 +1,74 @@ +package jalview.json.binding.biojson.v1; + +import jalview.schemes.Blosum62ColourScheme; +import jalview.schemes.BuriedColourScheme; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.HelixColourScheme; +import jalview.schemes.HydrophobicColourScheme; +import jalview.schemes.NucleotideColourScheme; +import jalview.schemes.PIDColourScheme; +import jalview.schemes.PurinePyrimidineColourScheme; +import jalview.schemes.RNAInteractionColourScheme; +import jalview.schemes.StrandColourScheme; +import jalview.schemes.TaylorColourScheme; +import jalview.schemes.TurnColourScheme; +import jalview.schemes.ZappoColourScheme; + +public enum JalviewBioJsColorSchemeMapper +{ + + USER_DEFINED("User Defined", "user defined", null), NONE("None", "foo", + null), CLUSTAL("Clustal", "clustal", null), ZAPPO("Zappo", + "zappo", new ZappoColourScheme()), TAYLOR("Taylor", "taylor", + new TaylorColourScheme()), NUCLEOTIDE("Nucleotide", "nucleotide", + new NucleotideColourScheme()), PURINE_PYRIMIDINE( + "Purine/Pyrimidine", "purine", new PurinePyrimidineColourScheme()), HELIX_PROPENCITY( + "Helix Propensity", "helix", new HelixColourScheme()), TURN_PROPENSITY( + "Turn Propensity", "turn", new TurnColourScheme()), STRAND_PROPENSITY( + "Strand Propensity", "strand", new StrandColourScheme()), BURIED_INDEX( + "Buried Index", "buried", new BuriedColourScheme()), HYDROPHOBIC( + "Hydrophobic", "hydro", new HydrophobicColourScheme()), + + // The color types below are not yet supported by BioJs MSA viewer + T_COFFE_SCORES("T-Coffee Scores", "T-Coffee Scores", null), RNA_INT_TYPE( + "RNA Interaction type", "RNA Interaction type", + new RNAInteractionColourScheme()), BLOSUM62("Blosum62", + "Blosum62", new Blosum62ColourScheme()), RNA_HELICES( + "RNA Helices", "RNA Helices", null), PERCENTAGE_IDENTITY( + "% Identity", "pid", new PIDColourScheme()); + + private String jalviewName; + + private String bioJsName; + + private ColourSchemeI jvColourScheme; + + private JalviewBioJsColorSchemeMapper(String jalviewName, + String bioJsName, ColourSchemeI jvColourScheme) + { + this.jalviewName = jalviewName; + this.bioJsName = bioJsName; + this.setJvColourScheme(jvColourScheme); + } + + public String getJalviewName() + { + return jalviewName; + } + + public String getBioJsName() + { + return bioJsName; + } + + public ColourSchemeI getJvColourScheme() + { + return jvColourScheme; + } + + public void setJvColourScheme(ColourSchemeI jvColourScheme) + { + this.jvColourScheme = jvColourScheme; + } + +} diff --git a/src/jalview/json/binding/v1/SequenceFeaturesPojo.java b/src/jalview/json/binding/biojson/v1/SequenceFeaturesPojo.java similarity index 51% rename from src/jalview/json/binding/v1/SequenceFeaturesPojo.java rename to src/jalview/json/binding/biojson/v1/SequenceFeaturesPojo.java index f55be46..e493ecb 100644 --- a/src/jalview/json/binding/v1/SequenceFeaturesPojo.java +++ b/src/jalview/json/binding/biojson/v1/SequenceFeaturesPojo.java @@ -1,30 +1,43 @@ -package jalview.json.binding.v1; +package jalview.json.binding.biojson.v1; -import java.util.Hashtable; +import java.util.Map; import java.util.Vector; +import com.github.reinert.jjschema.Attributes; + public class SequenceFeaturesPojo { + @Attributes(required = true, description = "Serial version id for the SeqFeature object") private String svid = "1.0"; - private int xstart; + @Attributes(required = true, description = "Start residue position for the sequence feature") + private int xStart; - private int xend; + @Attributes(required = true, description = "End residue position for the sequence feature") + private int xEnd; + @Attributes(required = true, minItems = 1, maxItems = 1999999999, description = "Reference to the sequence in the alignment
(more like a foreign key)") private String sequenceRef; + @Attributes(required = true, description = "The name or type of the SequenceFeature") private String type; + @Attributes(required = false, description = "Score") private Float score; + @Attributes(required = false, description = "Description for the feature") private String description; + + @Attributes(required = false, description = "Additional metadata for the feature") + private Map otherDetails; - private Hashtable otherDetails; - + @Attributes(required = false, description = "Fill colour") private String fillColor; + @Attributes(required = true, description = "Feature group") private String featureGroup; + @Attributes(required = false, description = "URL links associated to the feature") private Vector links; public SequenceFeaturesPojo() @@ -48,22 +61,22 @@ public class SequenceFeaturesPojo public int getXstart() { - return xstart; + return xStart; } - public void setXstart(int xstart) + public void setXstart(int xStart) { - this.xstart = xstart; + this.xStart = xStart; } public int getXend() { - return xend; + return xEnd; } public void setXend(int xend) { - this.xend = xend; + this.xEnd = xend; } public String getType() @@ -96,12 +109,12 @@ public class SequenceFeaturesPojo this.description = description; } - public Hashtable getOtherDetails() + public Map getOtherDetails() { return otherDetails; } - public void setOtherDetails(Hashtable otherDetails) + public void setOtherDetails(Map otherDetails) { this.otherDetails = otherDetails; } @@ -141,4 +154,12 @@ public class SequenceFeaturesPojo return svid; } +//public Map getOtherDetails() { +// return otherDetails; +//} +// +//public void setOtherDetails(Map otherDetails) { +// this.otherDetails = otherDetails; +//} + } diff --git a/src/jalview/json/binding/v1/SequenceGrpPojo.java b/src/jalview/json/binding/biojson/v1/SequenceGrpPojo.java similarity index 59% rename from src/jalview/json/binding/v1/SequenceGrpPojo.java rename to src/jalview/json/binding/biojson/v1/SequenceGrpPojo.java index 7e4d41c..63bc426 100644 --- a/src/jalview/json/binding/v1/SequenceGrpPojo.java +++ b/src/jalview/json/binding/biojson/v1/SequenceGrpPojo.java @@ -1,29 +1,42 @@ -package jalview.json.binding.v1; +package jalview.json.binding.biojson.v1; import java.util.ArrayList; +import com.github.reinert.jjschema.Attributes; + public class SequenceGrpPojo { + @Attributes(required = true, description = "Serial version identifier for the seqGroup object model") private String svid = "1.0"; - + + @Attributes(required = false, description = "The Colour Scheme applied to the Sequence Group") private String colourScheme; + @Attributes(required = true, description = "The name assigned to the seqGroup") private String groupName; + @Attributes(required = false, description = "Serial version identifier for the seqGroup object model") private String description; + @Attributes(required = false, description = "Determines if the seqGroup border should be visible or not") private boolean displayBoxes; + @Attributes(required = false, description = "Determines if the texts of the group is displayed or not") private boolean displayText; + @Attributes(required = false, description = "Determines if the residues text for the group is coloured") private boolean colourText; + @Attributes(required = false, description = "Boolean value indicating whether residues should only be shown
that are different from current reference or consensus sequence") private boolean showNonconserved; + @Attributes(required = true, description = "The index of the group’s first residue in the alignment space") private int startRes; + @Attributes(required = true, description = "The index of the group’s last residue in the alignment space") private int endRes; - + + @Attributes(required = true, minItems = 1, maxItems = 1999999999, uniqueItems=true, description = "An array of the unique id's for the sequences belonging to the group") private ArrayList sequenceRefs = new ArrayList(); public String getColourScheme() diff --git a/src/jalview/json/binding/v1/SequencePojo.java b/src/jalview/json/binding/biojson/v1/SequencePojo.java similarity index 53% rename from src/jalview/json/binding/v1/SequencePojo.java rename to src/jalview/json/binding/biojson/v1/SequencePojo.java index af57164..17c6506 100644 --- a/src/jalview/json/binding/v1/SequencePojo.java +++ b/src/jalview/json/binding/biojson/v1/SequencePojo.java @@ -1,23 +1,33 @@ -package jalview.json.binding.v1; +package jalview.json.binding.biojson.v1; + +import com.github.reinert.jjschema.Attributes; public class SequencePojo { + @Attributes(required = true, description = "Serial version identifier for the seqs object model") private String svid = "1.0"; + @Attributes(required = true,minLength=3,maxLength=1999999999, description = "Sequence residue characters. An aligned sequence may contain
one of the following gap characters “.”, “-” or “ ”") private String seq; + @Attributes(required = true, description = "Sequence name") private String name; + @Attributes(required = false, description = "Sequence type", enums = {"DNA", "RNA", "Protein"}) private String type; + @Attributes(required = true, description = "Unique identifier for a given Sequence") private String id; - + + @Attributes(required = false, description = "The order/position of a sequence in the alignment space") private int order; - + + @Attributes(required = true, description = "The index of the sequence’s first residue in its source database,
using a one-based numbering index system") private int start; + @Attributes(required = true, description = "The index of the sequence’s last residue in its source database,
using a one-based numbering index system") private int end; diff --git a/src/jalview/json/binding/v1/AlignmentPojo.java b/src/jalview/json/binding/v1/AlignmentPojo.java deleted file mode 100644 index 9f129f7..0000000 --- a/src/jalview/json/binding/v1/AlignmentPojo.java +++ /dev/null @@ -1,168 +0,0 @@ -package jalview.json.binding.v1; - -import jalview.schemes.Blosum62ColourScheme; -import jalview.schemes.BuriedColourScheme; -import jalview.schemes.ColourSchemeI; -import jalview.schemes.HelixColourScheme; -import jalview.schemes.HydrophobicColourScheme; -import jalview.schemes.NucleotideColourScheme; -import jalview.schemes.PIDColourScheme; -import jalview.schemes.PurinePyrimidineColourScheme; -import jalview.schemes.RNAInteractionColourScheme; -import jalview.schemes.StrandColourScheme; -import jalview.schemes.TaylorColourScheme; -import jalview.schemes.TurnColourScheme; -import jalview.schemes.ZappoColourScheme; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class AlignmentPojo -{ - private String svid = "1.0"; - - private List seqs = new ArrayList(); - - private List alignAnnotation = new ArrayList(); - - private List seqGroups = new ArrayList(); - - private List seqFeatures = new ArrayList(); - - HashMap appSettings = new HashMap(); - - public AlignmentPojo() - { - } - - public List getSeqs() - { - return seqs; - } - - public void setSeqs(ArrayList seqs) - { - this.seqs = seqs; - } - - public HashMap getAppSettings() - { - return appSettings; - } - - public void setAppSettings(HashMap appSettings) - { - this.appSettings = appSettings; - } - - public List getAlignAnnotation() - { - return alignAnnotation; - } - - public void setAlignAnnotation( - List alignAnnotation) - { - this.alignAnnotation = alignAnnotation; - } - - public List getSeqGroups() - { - return seqGroups; - } - - public void setSeqGroups(List seqGroups) - { - this.seqGroups = seqGroups; - } - - public List getSeqFeatures() - { - return seqFeatures; - } - - public void setSeqFeatures(List seqFeatures) - { - this.seqFeatures = seqFeatures; - } - - public String getSvid() - { - return svid; - } - - public void setGlobalColorScheme(String globalColorScheme) - { - for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper - .values()) - { - if (cs.getJalviewName().equals(globalColorScheme)) - { - // this.globalColorScheme = cs.getBioJsName(); - this.appSettings.put("globalColorScheme", cs.getBioJsName()); - break; - } - } - } - - public enum JalviewBioJsColorSchemeMapper - { - USER_DEFINED("User Defined", "user defined", null), NONE("None", "foo", - null), CLUSTAL("Clustal", "clustal", null), ZAPPO("Zappo", - "zappo", new ZappoColourScheme()), TAYLOR("Taylor", "taylor", - new TaylorColourScheme()), NUCLEOTIDE("Nucleotide", - "nucleotide", new NucleotideColourScheme()), PURINE_PYRIMIDINE( - "Purine/Pyrimidine", "purine", - new PurinePyrimidineColourScheme()), HELIX_PROPENCITY( - "Helix Propensity", "helix", new HelixColourScheme()), TURN_PROPENSITY( - "Turn Propensity", "turn", new TurnColourScheme()), STRAND_PROPENSITY( - "Strand Propensity", "strand", new StrandColourScheme()), BURIED_INDEX( - "Buried Index", "buried", new BuriedColourScheme()), HYDROPHOBIC( - "Hydrophobic", "hydro", new HydrophobicColourScheme()), - - // The color types below are not yet supported by BioJs MSA viewer - T_COFFE_SCORES("T-Coffee Scores", "T-Coffee Scores", null), RNA_INT_TYPE( - "RNA Interaction type", "RNA Interaction type", - new RNAInteractionColourScheme()), BLOSUM62("Blosum62", - "Blosum62", new Blosum62ColourScheme()), RNA_HELICES( - "RNA Helices", "RNA Helices", null), PERCENTAGE_IDENTITY( - "% Identity", "pid", new PIDColourScheme()); - - private String jalviewName; - - private String bioJsName; - - private ColourSchemeI jvColourScheme; - - private JalviewBioJsColorSchemeMapper(String jalviewName, - String bioJsName, ColourSchemeI jvColourScheme) - { - this.jalviewName = jalviewName; - this.bioJsName = bioJsName; - this.setJvColourScheme(jvColourScheme); - } - - public String getJalviewName() - { - return jalviewName; - } - - public String getBioJsName() - { - return bioJsName; - } - - public ColourSchemeI getJvColourScheme() - { - return jvColourScheme; - } - - public void setJvColourScheme(ColourSchemeI jvColourScheme) - { - this.jvColourScheme = jvColourScheme; - } - - } - -} diff --git a/src/jalview/json/binding/v1/AnnotationPojo.java b/src/jalview/json/binding/v1/AnnotationPojo.java deleted file mode 100644 index 41eae82..0000000 --- a/src/jalview/json/binding/v1/AnnotationPojo.java +++ /dev/null @@ -1,55 +0,0 @@ -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/test/jalview/io/BioJsHTMLOutputTest.java b/test/jalview/io/BioJsHTMLOutputTest.java index 27c8a0e..2d49bf7 100644 --- a/test/jalview/io/BioJsHTMLOutputTest.java +++ b/test/jalview/io/BioJsHTMLOutputTest.java @@ -1,7 +1,7 @@ package jalview.io; -import jalview.json.binding.v1.BioJSReleasePojo; -import jalview.json.binding.v1.BioJSRepositoryPojo; +import jalview.json.binding.biojs.BioJSReleasePojo; +import jalview.json.binding.biojs.BioJSRepositoryPojo; import java.io.File; import java.io.IOException; -- 1.7.10.2