From: tcofoegbu Date: Fri, 8 May 2015 15:35:40 +0000 (+0100) Subject: JAL-1641 refinement of the JSON data model and abstraction of several methods that... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a06365c7ebe08bdf24b7595b60d89a79537f3158;p=jalview.git JAL-1641 refinement of the JSON data model and abstraction of several methods that generates different parts to enable reuse --- diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index 081f5eb..10aa994 100644 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -219,9 +219,6 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer af.statusBar.setText(MessageManager .getString("label.successfully_pasted_alignment_file")); - System.out.println(">>>>>>>>>>>>>>>> showFeatures : " - + Desktop.isCurrentSeqFeaturesVisible()); - af.setShowSeqFeatures(Desktop.isCurrentSeqFeaturesVisible()); af.changeColour(Desktop.getCurrentGlobalColourScheme()); diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 526e8e9..649aad3 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -540,7 +540,22 @@ public class AppletFormatAdapter } else if (format.equalsIgnoreCase(JSONFile.FILE_DESC)) { - afile = new JSONFile(); + afile = new JSONFile(); + // Add groups to AlignFile + afile.seqGroups = alignment.getGroups(); + + // Add non auto calculated annotation to AlignFile + for (AlignmentAnnotation annot : alignment.getAlignmentAnnotation()) + { + if (annot != null && !annot.autoCalculated) + { + if (annot.label.equals("PDB.CATempFactor")) + { + continue; + } + afile.annotations.add(annot); + } + } } else if (format.equalsIgnoreCase("RNAML")) { @@ -555,17 +570,7 @@ 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 c44f1bf..4945306 100644 --- a/src/jalview/io/BioJsHTMLOutput.java +++ b/src/jalview/io/BioJsHTMLOutput.java @@ -8,7 +8,7 @@ import jalview.exceptions.NoFileSelectedException; import jalview.gui.AlignmentPanel; import jalview.gui.FeatureRenderer; import jalview.json.binding.v1.AlignmentPojo; -import jalview.json.binding.v1.FeaturePojo; +import jalview.json.binding.v1.SequenceFeaturesPojo; import jalview.json.binding.v1.SequencePojo; import jalview.schemes.ColourSchemeProperty; import jalview.util.MessageManager; @@ -119,9 +119,9 @@ public class BioJsHTMLOutput { AlignmentPojo bjsAlignment = new AlignmentPojo(); - bjsAlignment.setGlobalColorScheme(getGlobalColorScheme()); - bjsAlignment.setJalviewVersion(jalviewVersion); - bjsAlignment.setWebStartUrl(webStartLaunchServletUrl); + // bjsAlignment.setGlobalColorScheme(getGlobalColorScheme()); + // bjsAlignment.setJalviewVersion(jalviewVersion); + // bjsAlignment.setWebStartUrl(webStartLaunchServletUrl); int count = 0; for (SequenceI seq : alignment.getSequences()) @@ -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,15 +151,15 @@ public class BioJsHTMLOutput String featureColour = jalview.util.Format.getHexString(fr .findFeatureColour(Color.white, seq, seq.findIndex(sf.getBegin()))); - FeaturePojo bjsFeature = new FeaturePojo(); - bjsFeature.setFillColor(featureColour); - bjsFeature.setXstart(seq.findIndex(sf.getBegin()) - 1); - bjsFeature.setXend(seq.findIndex(sf.getEnd())); - bjsFeature.setType(sf.getType()); - bjsSeqFeatures.add(bjsFeature); + // SequenceFeaturesPojo bjsFeature = new SequenceFeaturesPojo(); + // bjsFeature.setFillColor(featureColour); + // bjsFeature.setXstart(seq.findIndex(sf.getBegin()) - 1); + // bjsFeature.setXend(seq.findIndex(sf.getEnd())); + // bjsFeature.setType(sf.getType()); + // bjsSeqFeatures.add(bjsFeature); } } - seqPojo.setFeatures(bjsSeqFeatures); + // seqPojo.setFeatures(bjsSeqFeatures); } bjsAlignment.getSeqs().add(seqPojo); } diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index d3d2ef7..7278157 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -11,20 +11,22 @@ 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.JalviewSettingsPojo; +import jalview.json.binding.v1.JalviewSettingsPojo.JalviewBioJsColorSchemeMapper; +import jalview.json.binding.v1.SequenceFeaturesPojo; 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 java.util.List; +import java.util.Vector; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -44,6 +46,8 @@ public class JSONFile extends AlignFile private String globalColorScheme; + private boolean showSeqFeatures; + private Hashtable seqMap; private FeaturesDisplayedI displayedFeatures; @@ -67,7 +71,6 @@ public class JSONFile extends AlignFile super(inFile, type); } - @Override public void parse() throws IOException { @@ -84,46 +87,141 @@ public class JSONFile extends AlignFile @Override public String print() { - AlignmentPojo jsonAlignmentPojo = new AlignmentPojo(); - if (Desktop.getCurrentAlignFrame() != null) + try + { + JSONExportSettings exportSettings = new JSONExportSettings(); + exportSettings.setExportAnnotations(true); + exportSettings.setExportGroups(true); + exportSettings.setExportJalviewSettings(true); + exportSettings.setExportSequenceFeatures(true); + + AlignmentPojo jsonAlignmentPojo = new AlignmentPojo(); + if (Desktop.getCurrentAlignFrame() != null) + { + globalColorScheme = ColourSchemeProperty.getColourName(Desktop + .getCurrentAlignFrame().getViewport() + .getGlobalColourScheme()); + this.av = Desktop.getCurrentAlignFrame().getCurrentView(); + this.fr = Desktop.getCurrentAlignFrame().alignPanel + .cloneFeatureRenderer(); + displayedFeatures = av.getFeaturesDisplayed(); + showSeqFeatures = Desktop.getCurrentAlignFrame().showSeqFeatures + .isSelected(); + } + + 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 (exportSettings.isExportJalviewSettings()) + { + JalviewSettingsPojo jvSettings = new JalviewSettingsPojo(); + jvSettings.setGlobalColorScheme(globalColorScheme); + jvSettings.setJalviewVersion(jalviewVersion); + jvSettings.setWebStartUrl(webStartLaunchServletUrl); + jvSettings.setShowSeqFeatures(showSeqFeatures); + jsonAlignmentPojo.setJalviewSettings(jvSettings); + } + + if (exportSettings.isExportAnnotations()) + { + jsonAlignmentPojo + .setAlignAnnotation(annotationToJsonPojo(annotations)); + } + + if (exportSettings.isExportSequenceFeatures()) + { + jsonAlignmentPojo.setSeqFeatures(sequenceFeatureToJsonPojo(seqs, + displayedFeatures)); + } + + if (exportSettings.isExportGroups() && seqGroups.size() > 0) + { + ArrayList sequenceGroupsPojo = new ArrayList(); + for (SequenceGroup seqGrp : seqGroups) + { + 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()); + for (SequenceI seq : seqGrp.getSequences()) + { + seqGrpPojo.getSeqsHash().add( + seq.getName() + "_" + seq.hashCode()); + } + jsonAlignmentPojo.getSeqGroups().add(seqGrpPojo); + } + } + com.json.JSONObject generatedJSon = new com.json.JSONObject( + jsonAlignmentPojo); + String jsonOutput = generatedJSon.toString(); + return jsonOutput.replaceAll("xstart", "xStart").replaceAll("xend", + "xEnd"); + } catch (Exception e) { - jsonAlignmentPojo.setGlobalColorScheme(ColourSchemeProperty - .getColourName(Desktop.getCurrentAlignFrame().getViewport() - .getGlobalColourScheme())); - this.av = Desktop.getCurrentAlignFrame().getCurrentView(); - this.fr = Desktop.getCurrentAlignFrame().alignPanel - .cloneFeatureRenderer(); - displayedFeatures = av.getFeaturesDisplayed(); - jsonAlignmentPojo - .setShowSeqFeatures(Desktop.getCurrentAlignFrame().showSeqFeatures - .isSelected()); + e.printStackTrace(); + throw e; } - jsonAlignmentPojo.setJalviewVersion(jalviewVersion); - jsonAlignmentPojo.setWebStartUrl(webStartLaunchServletUrl); + } - if (seqGroups.size() > 0) + public static List sequenceFeatureToJsonPojo( + List seqs, FeaturesDisplayedI displayedFeatures) + { + List sequenceFeaturesPojo = new ArrayList(); + for (SequenceI seq : seqs) { - ArrayList sequenceGroupsPojo = new ArrayList(); - for (SequenceGroup seqGrp : seqGroups) + SequenceI dataSetSequence = seq.getDatasetSequence(); + SequenceFeature[] seqFeatures = (dataSetSequence == null) ? null + : seq.getDatasetSequence().getSequenceFeatures(); + for (SequenceFeature sf : seqFeatures) { - 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()); - for(SequenceI seq : seqGrp.getSequences()){ - seqGrpPojo.getSeqsHash().add(seq.getName() + "_" + seq.hashCode()); + 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); + SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo( + seq.getName() + "_" + seq.hashCode()); + 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()); + sequenceFeaturesPojo.add(jsonFeature); } - jsonAlignmentPojo.getSequenceGroups().add(seqGrpPojo); } } + return sequenceFeaturesPojo; + } + public static List annotationToJsonPojo( + Vector annotations) + { + List jsonAnnotations = new ArrayList(); for (AlignmentAnnotation annot : annotations) { AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo(); @@ -146,59 +244,9 @@ public class JSONFile extends AlignFile alignAnnotPojo.getAnnotations().add(annotationPojo); } } - jsonAlignmentPojo.getAlignmentAnnotation().add(alignAnnotPojo); + jsonAnnotations.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"); + return jsonAnnotations; } public void parse(String jsonAlignmentString) @@ -209,16 +257,27 @@ public class JSONFile extends AlignFile 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"); - Boolean showFeatures = Boolean.valueOf(alignmentJsonObj.get( - "showSeqFeatures").toString()); - cs = getJalviewColorScheme(jsColourScheme); + JSONArray alAnnotJsonArray = (JSONArray) alignmentJsonObj + .get("alignAnnotation"); + JSONArray jsonSeqArray = (JSONArray) alignmentJsonObj + .get("seqFeatures"); + JSONArray seqGrpJsonArray = (JSONArray) alignmentJsonObj + .get("seqGroups"); + JSONObject jvSettingsJsonObj = (JSONObject) alignmentJsonObj + .get("jalviewSettings"); + + if (jvSettingsJsonObj != null) + { + String jsColourScheme = (String) jvSettingsJsonObj + .get("globalColorScheme"); + Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get( + "showSeqFeatures").toString()); + cs = getJalviewColorScheme(jsColourScheme); + Desktop.setCurrentSeqFeaturesVisible(showFeatures); + } + seqMap = new Hashtable(); Desktop.setCurrentGlobalColourScheme(cs); - Desktop.setCurrentSeqFeaturesVisible(showFeatures); for (Iterator sequenceIter = seqJsonArray.iterator(); sequenceIter .hasNext();) { @@ -230,17 +289,11 @@ public class JSONFile extends AlignFile 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); } - + parseFeatures(jsonSeqArray); + for (Iterator seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter .hasNext();) { @@ -285,13 +338,11 @@ public class JSONFile extends AlignFile } - for (Iterator alAnnotIter = alAnnotJsonArray.iterator(); alAnnotIter .hasNext();) { JSONObject alAnnot = alAnnotIter.next(); - JSONArray annotJsonArray = (JSONArray) alAnnot - .get("annotations"); + JSONArray annotJsonArray = (JSONArray) alAnnot.get("annotations"); Annotation[] annotations = new Annotation[annotJsonArray.size()]; int count = 0; for (Iterator annotIter = annotJsonArray.iterator(); annotIter @@ -304,17 +355,14 @@ public class JSONFile extends AlignFile } else { - float val = annot.get("value") == null ? null - : Float.valueOf(annot.get("value") - .toString()); + 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(); + : annot.get("secondaryStructure").toString().charAt(0); + String displayChar = annot.get("displayCharacter").toString(); annotations[count] = new Annotation(displayChar, desc, ss, val); } @@ -333,20 +381,15 @@ public class JSONFile extends AlignFile } } - public SequenceFeature[] getJalviewSequenceFeatures( - JSONArray jsonSeqFeatures, Sequence seq) + + private void parseFeatures(JSONArray jsonSeqFeatures) { - 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"); @@ -354,23 +397,33 @@ public class JSONFile extends AlignFile String color = (String) jsonFeature.get("fillColor"); String featureGrp = (String) jsonFeature.get("featureGroup"); String descripiton = (String) jsonFeature.get("description"); + String seqRef = (String) jsonFeature.get("sequenceRef"); 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; + + Sequence seq = seqMap.get(seqRef); + SequenceFeature sequenceFeature = new SequenceFeature(); + JSONArray linksJsonArray = (JSONArray) jsonFeature.get("links"); + if (linksJsonArray != null && linksJsonArray.size() > 0) + { + Iterator linkList = linksJsonArray.iterator(); + while (linkList.hasNext()) + { + String link = linkList.next(); + sequenceFeature.addLink(link); + } + } + sequenceFeature.setFeatureGroup(featureGrp); sequenceFeature.setScore(score); sequenceFeature.setDescription(descripiton); - + sequenceFeature.setType(type); sequenceFeature.setBegin(seq.findPosition(begin.intValue())); sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1); - sequenceFeature.setType(type); - seqFeatures[count++] = sequenceFeature; + seq.addSequenceFeature(sequenceFeature); } } - return seqFeatures; } private ColourSchemeI getJalviewColorScheme(String bioJsColourSchemeName) @@ -404,4 +457,67 @@ public class JSONFile extends AlignFile { this.globalColorScheme = globalColorScheme; } + + public class JSONExportSettings + { + private boolean exportSequence; + + private boolean exportSequenceFeatures; + + private boolean exportAnnotations; + + private boolean exportGroups; + + private boolean exportJalviewSettings; + + public boolean isExportSequence() + { + return exportSequence; + } + + public void setExportSequence(boolean exportSequence) + { + this.exportSequence = exportSequence; + } + + public boolean isExportSequenceFeatures() + { + return exportSequenceFeatures; + } + + public void setExportSequenceFeatures(boolean exportSequenceFeatures) + { + this.exportSequenceFeatures = exportSequenceFeatures; + } + + public boolean isExportAnnotations() + { + return exportAnnotations; + } + + public void setExportAnnotations(boolean exportAnnotations) + { + this.exportAnnotations = exportAnnotations; + } + + public boolean isExportGroups() + { + return exportGroups; + } + + public void setExportGroups(boolean exportGroups) + { + this.exportGroups = exportGroups; + } + + public boolean isExportJalviewSettings() + { + return exportJalviewSettings; + } + + public void setExportJalviewSettings(boolean exportJalviewSettings) + { + this.exportJalviewSettings = exportJalviewSettings; + } + } } diff --git a/src/jalview/json/binding/v1/AlignmentPojo.java b/src/jalview/json/binding/v1/AlignmentPojo.java index 163b6ab..ccf55a4 100644 --- a/src/jalview/json/binding/v1/AlignmentPojo.java +++ b/src/jalview/json/binding/v1/AlignmentPojo.java @@ -1,41 +1,22 @@ 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.List; public class AlignmentPojo { - private String globalColorScheme = "none"; - - private String jalviewVersion; - - private String webStartUrl; + private List seqs = new ArrayList(); - private boolean showSeqFeatures; + private List alignAnnotation = new ArrayList(); - private List seqs = new ArrayList(); + private List seqGroups = new ArrayList(); - private List alignmentAnnotation = new ArrayList(); + private List seqFeatures = new ArrayList(); - private List sequenceGroups = new ArrayList(); + private JalviewSettingsPojo jalviewSettings; public AlignmentPojo() { - } public List getSeqs() @@ -47,144 +28,47 @@ public class AlignmentPojo { this.seqs = seqs; } - public String getGlobalColorScheme() - { - return globalColorScheme; - } - public void setGlobalColorScheme(String globalColorScheme) - { - for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper - .values()) - { - if (cs.getJalviewName().equals(globalColorScheme)) - { - this.globalColorScheme = cs.getBioJsName(); - break; - } - } - - // JALVIEW colors not in biojs - // Blosum62 - // T-Coffee Scores (almost same with Blosom62 - // RNA Interaction type - no color applied - // RNA Helices - missing - - // BIOJS Colour not in jalview - // schemes.push name: "Lesk", id: "lesk" - // schemes.push name: "Cinema", id: "cinema" - // schemes.push name: "MAE", id: "mae" - // schemes.push name: "Clustal2", id: "clustal2" - - } - - - public String getJalviewVersion() - { - return jalviewVersion; - } - public void setJalviewVersion(String jalviewVersion) + public JalviewSettingsPojo getJalviewSettings() { - this.jalviewVersion = jalviewVersion; + return jalviewSettings; } - public String getWebStartUrl() + public void setJalviewSettings(JalviewSettingsPojo jalviewSettings) { - return webStartUrl; + this.jalviewSettings = jalviewSettings; } - public void setWebStartUrl(String webStartUrl) + public List getAlignAnnotation() { - this.webStartUrl = webStartUrl; + return alignAnnotation; } - public List getAlignmentAnnotation() + public void setAlignAnnotation( + List alignAnnotation) { - return alignmentAnnotation; + this.alignAnnotation = alignAnnotation; } - public void setAlignmentAnnotation(List alignmentAnnotation) + public List getSeqGroups() { - this.alignmentAnnotation = alignmentAnnotation; + return seqGroups; } - public List getSequenceGroups() + public void setSeqGroups(List seqGroups) { - return sequenceGroups; + this.seqGroups = seqGroups; } - public void setSequenceGroups(List sequenceGroups) + public List getSeqFeatures() { - this.sequenceGroups = sequenceGroups; + return seqFeatures; } - public boolean isShowSeqFeatures() + public void setSeqFeatures(List seqFeatures) { - return showSeqFeatures; + this.seqFeatures = seqFeatures; } - public void setShowSeqFeatures(boolean showSeqFeatures) - { - this.showSeqFeatures = showSeqFeatures; - } - 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/JalviewSettingsPojo.java b/src/jalview/json/binding/v1/JalviewSettingsPojo.java new file mode 100644 index 0000000..3cc8824 --- /dev/null +++ b/src/jalview/json/binding/v1/JalviewSettingsPojo.java @@ -0,0 +1,150 @@ +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; + +public class JalviewSettingsPojo +{ + private String globalColorScheme = "none"; + + private String jalviewVersion; + + private String webStartUrl; + + private boolean showSeqFeatures; + + private boolean wrapModeEnabled; + + public JalviewSettingsPojo() + { + + } + + public String getGlobalColorScheme() + { + return globalColorScheme; + } + + public void setGlobalColorScheme(String globalColorScheme) + { + for (JalviewBioJsColorSchemeMapper cs : JalviewBioJsColorSchemeMapper + .values()) + { + if (cs.getJalviewName().equals(globalColorScheme)) + { + this.globalColorScheme = cs.getBioJsName(); + break; + } + } + } + + public String getJalviewVersion() + { + return jalviewVersion; + } + + public void setJalviewVersion(String jalviewVersion) + { + this.jalviewVersion = jalviewVersion; + } + + public String getWebStartUrl() + { + return webStartUrl; + } + + public void setWebStartUrl(String webStartUrl) + { + this.webStartUrl = webStartUrl; + } + + public boolean isShowSeqFeatures() + { + return showSeqFeatures; + } + + public void setShowSeqFeatures(boolean showSeqFeatures) + { + this.showSeqFeatures = showSeqFeatures; + } + + public boolean isWrapModeEnabled() + { + return wrapModeEnabled; + } + + public void setWrapModeEnabled(boolean wrapModeEnabled) + { + this.wrapModeEnabled = wrapModeEnabled; + } + + 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/FeaturePojo.java b/src/jalview/json/binding/v1/SequenceFeaturesPojo.java similarity index 72% rename from src/jalview/json/binding/v1/FeaturePojo.java rename to src/jalview/json/binding/v1/SequenceFeaturesPojo.java index 404f6bc..c970191 100644 --- a/src/jalview/json/binding/v1/FeaturePojo.java +++ b/src/jalview/json/binding/v1/SequenceFeaturesPojo.java @@ -3,17 +3,19 @@ package jalview.json.binding.v1; import java.util.Hashtable; import java.util.Vector; -public class FeaturePojo +public class SequenceFeaturesPojo { private int xstart; private int xend; + private String sequenceRef; + private String type; - private String fillColor; - + // private String fillColor; + private Float score; private String description; @@ -23,21 +25,26 @@ public class FeaturePojo private String featureGroup; private Vector links; - - public FeaturePojo() - { - } - public String getFillColor() + public SequenceFeaturesPojo() { - return "#" + fillColor; } - public void setFillColor(String fillColor) + public SequenceFeaturesPojo(String sequenceRef) { - this.fillColor = fillColor; + this.sequenceRef = sequenceRef; } + // public String getFillColor() + // { + // return "#" + fillColor; + // } + // + // public void setFillColor(String fillColor) + // { + // this.fillColor = fillColor; + // } + public int getXstart() { return xstart; @@ -117,4 +124,14 @@ public class FeaturePojo { this.featureGroup = featureGroup; } + + public String getSequenceRef() + { + return sequenceRef; + } + + public void setSequenceRef(String sequenceRef) + { + this.sequenceRef = sequenceRef; + } } diff --git a/src/jalview/json/binding/v1/SequencePojo.java b/src/jalview/json/binding/v1/SequencePojo.java index 762acaf..232cefb 100644 --- a/src/jalview/json/binding/v1/SequencePojo.java +++ b/src/jalview/json/binding/v1/SequencePojo.java @@ -1,6 +1,5 @@ package jalview.json.binding.v1; -import java.util.ArrayList; public class SequencePojo @@ -17,7 +16,8 @@ public class SequencePojo private int end; - private ArrayList features = new ArrayList(); + // private ArrayList features = new + // ArrayList(); public SequencePojo() { @@ -80,15 +80,15 @@ public class SequencePojo this.end = end; } - public ArrayList getFeatures() - { - return features; - } - - public void setFeatures(ArrayList features) - { - this.features = features; - } + // public ArrayList getFeatures() + // { + // return features; + // } + // + // public void setFeatures(ArrayList features) + // { + // this.features = features; + // } public int getOrder() {