}
+ /**
+ * When positional annotation and a sequence reference is present, clears and
+ * resizes the annotations array to the current alignment width, and adds
+ * annotation according to aligned positions of the sequenceRef given by
+ * sequenceMapping.
+ */
public void adjustForAlignment()
{
if (sequenceRef == null)
int position;
Annotation[] temp = new Annotation[aSize];
Integer index;
-
- for (a = sequenceRef.getStart(); a <= sequenceRef.getEnd(); a++)
+ if (sequenceMapping != null)
{
- index = new Integer(a);
- if (sequenceMapping.containsKey(index))
+ for (a = sequenceRef.getStart(); a <= sequenceRef.getEnd(); a++)
{
- position = sequenceRef.findIndex(a) - 1;
+ index = new Integer(a);
+ Annotation annot = sequenceMapping.get(index);
+ if (annot != null)
+ {
+ position = sequenceRef.findIndex(a) - 1;
- temp[position] = sequenceMapping.get(index);
+ temp[position] = annot;
+ }
}
}
-
annotations = temp;
}
}
/**
- * Associate this annotion with the aligned residues of a particular sequence.
- * sequenceMapping will be updated in the following way: null sequenceI -
- * existing mapping will be discarded but annotations left in mapped
- * positions. valid sequenceI not equal to current sequenceRef: mapping is
- * discarded and rebuilt assuming 1:1 correspondence TODO: overload with
+ * Associate this annotation with the aligned residues of a particular
+ * sequence. sequenceMapping will be updated in the following way: null
+ * sequenceI - existing mapping will be discarded but annotations left in
+ * mapped positions. valid sequenceI not equal to current sequenceRef: mapping
+ * is discarded and rebuilt assuming 1:1 correspondence TODO: overload with
* parameter to specify correspondence between current and new sequenceRef
*
* @param sequenceI
cs.setConservationInc(SliderPanel.setConservationSlider(alignPanel,
cs, "Background"));
}
+ if (cs instanceof TCoffeeColourScheme)
+ {
+ tcoffeeColour.setEnabled(true);
+ tcoffeeColour.setSelected(true);
+ }
}
viewport.setGlobalColourScheme(cs);
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;
private ArrayList<SequenceI> hiddenSequences;
+ private final static String TCOFFEE_SCORE = "TCoffeeScore";
+
public JSONFile()
{
super();
}
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");
}
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();
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);
: 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;
}
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)
{
{
if (annot != null && !annot.autoCalculated)
{
- if (!annot.visible)
- {
- continue;
- }
annotations.add(annot);
}
}
@Attributes(
required = false,
- description = "Label for the Alignment Annotation")
+ description = "Label for the alignment annotation")
private String label;
@Attributes(
required = false,
- description = "Description for the Alignment Annotation")
+ description = "Description for the alignment annotation")
private String description;
@Attributes(required = false)
private List<AnnotationPojo> annotations = new ArrayList<AnnotationPojo>();
+ @Attributes(
+ required = false,
+ enums = { "0", "1", "2" },
+ description = "Determines the rendering for the annotation<br><ul><li>0 - No graph</li><li>1 - Bar Graph</li><li>2 - Line graph</li></ul>")
+ private int graphType;
+
+ @Attributes(
+ required = false,
+ description = "Reference to the sequence in the alignment<br> if per-sequence annotation")
+ private String sequenceRef;
+
+ @Attributes(
+ required = false,
+ description = "Stores display settings for an annotation")
+ private AnnotationDisplaySettingPojo annotationSettings;
+
+ @Attributes(required = false, description = "Score of the annotation")
+ private double score;
+
+ @Attributes(
+ required = false,
+ description = "The annotation generation source")
+ private String calcId;
+
public String getLabel()
{
return label;
this.annotations = annotations;
}
+ public String getSequenceRef()
+ {
+ return sequenceRef;
+ }
+
+ public void setSequenceRef(String sequenceRef)
+ {
+ this.sequenceRef = sequenceRef;
+ }
+
+ public int getGraphType()
+ {
+ return graphType;
+ }
+
+ public void setGraphType(int graphType)
+ {
+ this.graphType = graphType;
+ }
+
+ public AnnotationDisplaySettingPojo getAnnotationSettings()
+ {
+ return annotationSettings;
+ }
+
+ public void setAnnotationSettings(
+ AnnotationDisplaySettingPojo annotationSettings)
+ {
+ this.annotationSettings = annotationSettings;
+ }
+
+ public double getScore()
+ {
+ return score;
+ }
+
+ public void setScore(double score)
+ {
+ this.score = score;
+ }
+
+ public String getCalcId()
+ {
+ return calcId;
+ }
+
+ public void setCalcId(String calcId)
+ {
+ this.calcId = calcId;
+ }
+
}
--- /dev/null
+package jalview.json.binding.biojson.v1;
+
+import com.github.reinert.jjschema.Attributes;
+
+public class AnnotationDisplaySettingPojo
+{
+
+ @Attributes(
+ required = false,
+ description = "Indicates if column label is scaled to fit within the <br>alignment column")
+ private boolean scaleColLabel;
+
+ @Attributes(
+ required = false,
+ description = "Indicates if every column label is displayed.")
+ private boolean showAllColLabels;
+
+ @Attributes(
+ required = false,
+ description = "Indicates if column labels is centred relative to the <br>alignment column")
+ private boolean centreColLabels;
+
+ @Attributes(
+ required = false,
+ description = "Indicates if the Annotation is shown below the alignment")
+ private boolean belowAlignment;
+
+ @Attributes(
+ required = false,
+ description = "Indicates if the annotation row is visible")
+ private boolean visible;
+
+ @Attributes(
+ required = false,
+ description = "Indicates if annotation has a graphical symbol track")
+ private boolean hasIcon;
+
+ public boolean isScaleColLabel()
+ {
+ return scaleColLabel;
+ }
+
+ public void setScaleColLabel(boolean scaleColLabel)
+ {
+ this.scaleColLabel = scaleColLabel;
+ }
+
+ public boolean isShowAllColLabels()
+ {
+ return showAllColLabels;
+ }
+
+ public void setShowAllColLabels(boolean showAllColLabels)
+ {
+ this.showAllColLabels = showAllColLabels;
+ }
+
+ public boolean isCentreColLabels()
+ {
+ return centreColLabels;
+ }
+
+ public void setCentreColLabels(boolean centreColLabels)
+ {
+ this.centreColLabels = centreColLabels;
+ }
+
+ public boolean isBelowAlignment()
+ {
+ return belowAlignment;
+ }
+
+ public void setBelowAlignment(boolean belowAlignment)
+ {
+ this.belowAlignment = belowAlignment;
+ }
+
+ public boolean isVisible()
+ {
+ return visible;
+ }
+
+ public void setVisible(boolean visible)
+ {
+ this.visible = visible;
+ }
+
+ public boolean isHasIcon()
+ {
+ return hasIcon;
+ }
+
+ public void setHasIcon(boolean hasIcon)
+ {
+ this.hasIcon = hasIcon;
+ }
+
+}
@Attributes(required = false, description = "Value of the annotation")
private float value;
+ @Attributes(
+ required = false,
+ description = "Colour of the annotation position in hex string.")
+ private String colour;
+
public String getDisplayCharacter()
{
return displayCharacter;
this.value = value;
}
+ public String getColour()
+ {
+ return colour;
+ }
+
+ public void setColour(String colour)
+ {
+ this.colour = colour;
+ }
+
}
return schemeName;
}
- public Color getColourFromString(String colour)
+ public static Color getColourFromString(String colour)
{
colour = colour.trim();
"Colourscheme is null, parsing failed!");
Assert.assertEquals(testJsonFile.getGlobalColourScheme(), "Zappo",
"Zappo colour scheme expected!");
- // Assert.assertTrue(
- // testJsonFile.getGlobalColourScheme() instanceof ZappoColourScheme,
- // "Zappo colour scheme expected!");
}
@Test(groups = { "Functional" })