X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FJSONFile.java;h=9402562897a29f2b82022ccff009204041dd8cd3;hb=eb9c652416a69e6db0531e956dd2011012eac898;hp=3ac4aa7722297c55d7549e8ecef8f1a236356ad5;hpb=0fd1986d18c3093cc5386697ed49301599b74379;p=jalview.git diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index 3ac4aa7..9402562 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -39,12 +39,14 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.json.binding.biojson.v1.AlignmentAnnotationPojo; import jalview.json.binding.biojson.v1.AlignmentPojo; +import jalview.json.binding.biojson.v1.AnnotationDisplaySettingPojo; import jalview.json.binding.biojson.v1.AnnotationPojo; 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; import jalview.schemes.ColourSchemeProperty; +import jalview.schemes.UserColourScheme; import jalview.viewmodel.seqfeatures.FeaturesDisplayed; import java.awt.Color; @@ -90,6 +92,8 @@ public class JSONFile extends AlignFile implements ComplexAlignFile private ArrayList hiddenSequences; + private final static String TCOFFEE_SCORE = "TCoffeeScore"; + public JSONFile() { super(); @@ -211,7 +215,10 @@ public class JSONFile extends AlignFile implements ComplexAlignFile } else { - if (globalColourScheme.equalsIgnoreCase("RNA Helices")) + // These color schemes require annotation, disable them if annotations + // are not exported + if (globalColourScheme.equalsIgnoreCase("RNA Helices") + || globalColourScheme.equalsIgnoreCase("T-COFFEE SCORES")) { jsonAlignmentPojo.setGlobalColorScheme("None"); } @@ -367,6 +374,26 @@ public class JSONFile extends AlignFile implements ComplexAlignFile AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo(); alignAnnotPojo.setDescription(annot.description); alignAnnotPojo.setLabel(annot.label); + if (!Double.isNaN(annot.score)) + { + alignAnnotPojo.setScore(annot.score); + } + alignAnnotPojo.setCalcId(annot.getCalcId()); + alignAnnotPojo.setGraphType(annot.graph); + + AnnotationDisplaySettingPojo annotSetting = new AnnotationDisplaySettingPojo(); + annotSetting.setBelowAlignment(annot.belowAlignment); + annotSetting.setCentreColLabels(annot.centreColLabels); + annotSetting.setScaleColLabel(annot.scaleColLabel); + annotSetting.setShowAllColLabels(annot.showAllColLabels); + annotSetting.setVisible(annot.visible); + annotSetting.setHasIcon(annot.hasIcons); + alignAnnotPojo.setAnnotationSettings(annotSetting); + SequenceI refSeq = annot.sequenceRef; + if (refSeq != null) + { + alignAnnotPojo.setSequenceRef(String.valueOf(refSeq.hashCode())); + } for (Annotation annotation : annot.annotations) { AnnotationPojo annotationPojo = new AnnotationPojo(); @@ -376,12 +403,28 @@ public class JSONFile extends AlignFile implements ComplexAlignFile annotationPojo.setValue(annotation.value); annotationPojo .setSecondaryStructure(annotation.secondaryStructure); - annotationPojo.setDisplayCharacter(annotation.displayCharacter); + String displayChar = annotation.displayCharacter == null ? null + : annotation.displayCharacter; + // System.out.println("--------------------->[" + displayChar + "]"); + annotationPojo.setDisplayCharacter(displayChar); + if (annotation.colour != null) + { + annotationPojo.setColour(jalview.util.Format + .getHexString(annotation.colour)); + } alignAnnotPojo.getAnnotations().add(annotationPojo); } else { - alignAnnotPojo.getAnnotations().add(annotationPojo); + if (annot.getCalcId() != null + && annot.getCalcId().equalsIgnoreCase(TCOFFEE_SCORE)) + { + // do nothing + } + else + { + alignAnnotPojo.getAnnotations().add(annotationPojo); + } } } jsonAnnotations.add(alignAnnotPojo); @@ -439,7 +482,6 @@ public class JSONFile extends AlignFile implements ComplexAlignFile seqMap.put(seqUniqueId, seq); } - parseFeatures(jsonSeqArray); for (Iterator seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter @@ -478,8 +520,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile } } SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, null, - displayBoxes, displayText, colourText, - startRes, endRes); + displayBoxes, displayText, colourText, startRes, endRes); seqGrp.cs = ColourSchemeMapper.getJalviewColourScheme(colourScheme, seqGrp); seqGrp.setShowNonconserved(showNonconserved); @@ -517,6 +558,12 @@ public class JSONFile extends AlignFile implements ComplexAlignFile : annot.get("displayCharacter").toString(); annotations[count] = new Annotation(displayChar, desc, ss, val); + if (annot.get("colour") != null) + { + Color color = UserColourScheme.getColourFromString(annot.get( + "colour").toString()); + annotations[count].colour = color; + } } ++count; } @@ -524,7 +571,64 @@ public class JSONFile extends AlignFile implements ComplexAlignFile AlignmentAnnotation alignAnnot = new AlignmentAnnotation(alAnnot .get("label").toString(), alAnnot.get("description") .toString(), annotations); + alignAnnot.graph = (alAnnot.get("graphType") == null) ? 0 : Integer + .valueOf(alAnnot.get("graphType").toString()); + + JSONObject diplaySettings = (JSONObject) alAnnot + .get("annotationSettings"); + if (diplaySettings != null) + { + + alignAnnot.scaleColLabel = (diplaySettings.get("scaleColLabel") == null) ? false + : Boolean.valueOf(diplaySettings.get("scaleColLabel") + .toString()); + alignAnnot.showAllColLabels = (diplaySettings + .get("showAllColLabels") == null) ? true : Boolean + .valueOf(diplaySettings.get("showAllColLabels") + .toString()); + alignAnnot.centreColLabels = (diplaySettings + .get("centreColLabels") == null) ? true + : Boolean.valueOf(diplaySettings.get("centreColLabels") + .toString()); + alignAnnot.belowAlignment = (diplaySettings.get("belowAlignment") == null) ? false + : Boolean.valueOf(diplaySettings.get("belowAlignment") + .toString()); + alignAnnot.visible = (diplaySettings.get("visible") == null) ? true + : Boolean.valueOf(diplaySettings.get("visible") + .toString()); + alignAnnot.hasIcons = (diplaySettings.get("hasIcon") == null) ? true + : Boolean.valueOf(diplaySettings.get("hasIcon") + .toString()); + + } + if (alAnnot.get("score") != null) + { + alignAnnot.score = Double + .valueOf(alAnnot.get("score").toString()); + } + + String calcId = (alAnnot.get("calcId") == null) ? "" : alAnnot.get( + "calcId").toString(); + alignAnnot.setCalcId(calcId); + String seqHash = (alAnnot.get("sequenceRef") != null) ? alAnnot + .get("sequenceRef").toString() : null; + + Sequence sequence = (seqHash != null) ? seqMap.get(seqHash) : null; + if (sequence != null) + { + alignAnnot.sequenceRef = sequence; + sequence.addAlignmentAnnotation(alignAnnot); + if (alignAnnot.label.equalsIgnoreCase("T-COFFEE")) + { + alignAnnot.createSequenceMapping(sequence, sequence.getStart(), + false); + sequence.addAlignmentAnnotation(alignAnnot); + alignAnnot.adjustForAlignment(); + } + } + alignAnnot.validateRangeAndDisplay(); this.annotations.add(alignAnnot); + } } catch (Exception e) { @@ -641,10 +745,6 @@ public class JSONFile extends AlignFile implements ComplexAlignFile { if (annot != null && !annot.autoCalculated) { - if (!annot.visible) - { - continue; - } annotations.add(annot); } }