import jalview.api.FeatureRenderer;
import jalview.api.FeaturesDisplayedI;
import jalview.bin.BuildDetails;
+import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
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.ColourSchemeMapper;
import jalview.json.binding.biojson.v1.SequenceFeaturesPojo;
import jalview.json.binding.biojson.v1.SequenceGrpPojo;
import jalview.json.binding.biojson.v1.SequencePojo;
@SuppressWarnings("unchecked")
public JSONFile parse(Reader jsonAlignmentString)
{
+ String jsColourScheme = null;
try
{
JSONParser jsonParser = new JSONParser();
if (jvSettingsJsonObj != null)
{
- String jsColourScheme = (String) jvSettingsJsonObj
+ jsColourScheme = (String) jvSettingsJsonObj
.get("globalColorScheme");
Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get(
"showSeqFeatures").toString());
- setColourScheme(getJalviewColorScheme(jsColourScheme));
setShowSeqFeatures(showFeatures);
parseHiddenSeqRefsAsList(jvSettingsJsonObj);
parseHiddenCols(jvSettingsJsonObj);
seqs.add(seq);
seqMap.put(seqUniqueId, seq);
}
+
+ if (jsColourScheme != null)
+ {
+ setColourScheme(ColourSchemeMapper.getJalviewColourScheme(
+ jsColourScheme,
+ new Alignment(seqs.toArray(new SequenceI[0]))));
+ }
parseFeatures(jsonSeqArray);
for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter
}
}
}
- ColourSchemeI grpColourScheme = getJalviewColorScheme(colourScheme);
- SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName,
- grpColourScheme, displayBoxes, displayText, colourText,
+ SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, null,
+ displayBoxes, displayText, colourText,
startRes, endRes);
+ seqGrp.cs = ColourSchemeMapper.getJalviewColourScheme(colourScheme,
+ seqGrp);
seqGrp.setShowNonconserved(showNonconserved);
seqGrp.setDescription(description);
this.seqGroups.add(seqGrp);
}
}
- public static ColourSchemeI getJalviewColorScheme(
- String bioJsColourSchemeName)
- {
- ColourSchemeI jalviewColor = null;
- for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper
- .values())
- {
- if (cs.getBioJsName().equalsIgnoreCase(bioJsColourSchemeName)
- || cs.getJalviewName()
- .equalsIgnoreCase(bioJsColourSchemeName))
- {
- jalviewColor = cs.getJvColourScheme();
- break;
- }
- }
- return jalviewColor;
- }
-
public String getGlobalColorScheme()
{
return globalColorScheme;
--- /dev/null
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.json.binding.biojson.v1;
+
+import jalview.datamodel.AnnotatedCollectionI;
+import jalview.schemes.Blosum62ColourScheme;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.ClustalxColourScheme;
+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.RNAHelicesColour;
+import jalview.schemes.RNAInteractionColourScheme;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TCoffeeColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.ZappoColourScheme;
+
+public class ColourSchemeMapper
+{
+ public static ColourSchemeI getJalviewColourScheme(
+ String colourSchemeName, AnnotatedCollectionI annotCol)
+ {
+ switch (colourSchemeName.toUpperCase())
+ {
+ case "ZAPPO":
+ return new ZappoColourScheme();
+ case "TAYLOR":
+ return new TaylorColourScheme();
+ case "NUCLEOTIDE":
+ return new NucleotideColourScheme();
+ case "PURINE":
+ case "PURINE/PYRIMIDINE":
+ return new PurinePyrimidineColourScheme();
+ case "HELIX":
+ case "HELIX PROPENSITY":
+ return new HelixColourScheme();
+ case "TURN":
+ case "TURN PROPENSITY":
+ return new TurnColourScheme();
+ case "STRAND":
+ case "STRAND PROPENSITY":
+ return new StrandColourScheme();
+ case "BURIED":
+ case "BURIED INDEX":
+ return new BuriedColourScheme();
+ case "HYDRO":
+ case "HYDROPHOBIC":
+ return new HydrophobicColourScheme();
+ case "RNA INTERACTION TYPE":
+ return new RNAInteractionColourScheme();
+ case "PID":
+ case "% IDENTITY":
+ return new PIDColourScheme();
+ case "BLOSUM62":
+ return new Blosum62ColourScheme();
+ case "T-COFFEE SCORES":
+ return (annotCol != null) ? new TCoffeeColourScheme(annotCol) : null;
+ case "RNA HELICES":
+ return (annotCol != null) ? new RNAHelicesColour(annotCol) : null;
+ case "CLUSTAL":
+ return (annotCol != null) ? new ClustalxColourScheme(annotCol, null)
+ : null;
+ case "USER DEFINED":
+ return null;
+ default:
+ return null;
+ }
+ }
+}
+++ /dev/null
-/*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ The Jalview Authors
- *
- * This file is part of Jalview.
- *
- * Jalview is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3
- * of the License, or (at your option) any later version.
- *
- * Jalview is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
- * The Jalview Authors are detailed in the 'AUTHORS' file.
- */
-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_PROPENSITY(
- "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;
- }
-
-}
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.json.binding.biojson.v1.ColourSchemeMapper;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ZappoColourScheme;
grpSeqs.add(seqs[2]);
grpSeqs.add(seqs[3]);
grpSeqs.add(seqs[4]);
- ColourSchemeI scheme = JSONFile.getJalviewColorScheme("zappo");
SequenceGroup seqGrp = new SequenceGroup(grpSeqs, "JGroup:1883305585",
- scheme, true, true, false, 21, 29);
+ null, true, true, false, 21, 29);
+ ColourSchemeI scheme = ColourSchemeMapper.getJalviewColourScheme(
+ "zappo", seqGrp);
+ seqGrp.cs = scheme;
seqGrp.setShowNonconserved(false);
seqGrp.setDescription(null);
+ actualGrp.getStartRes());
System.out.println(expectedGrp.getEndRes() + " | "
+ actualGrp.getEndRes());
+ System.out.println(expectedGrp.cs + " | " + actualGrp.cs);
if (expectedGrp.getName().equals(actualGrp.getName())
&& expectedGrp.getColourText() == actualGrp.getColourText()
&& expectedGrp.getDisplayBoxes() == actualGrp.getDisplayBoxes()
&& expectedGrp.getIgnoreGapsConsensus() == actualGrp
.getIgnoreGapsConsensus()
- && expectedGrp.cs.equals(actualGrp.cs)
+ && (expectedGrp.cs.getClass().equals(actualGrp.cs.getClass()))
&& expectedGrp.getSequences().size() == actualGrp
.getSequences().size()
&& expectedGrp.getStartRes() == actualGrp.getStartRes()