--- /dev/null
+import jalview.workers.AlignmentAnnotationFactory;
+import jalview.workers.FeatureSetCounterI;
+
+/*
+ * Example script to compute two alignment annotations
+ * - count of Phosphorylation features
+ * - count of Turn features
+ * To try this, first load example file uniref50.fa and load on features file
+ * exampleFeatures.txt, before running this script
+ *
+ * The script only needs to be run once - it will be registered by Jalview
+ * and recalculated automatically when the alignment changes.
+ */
+def annotator =
+ [
+ getNames: { ['Phosphorylation', 'Turn'] as String[] },
+ getDescriptions: { ['Count of Phosphorylation features', 'Count of Turn features'] as String[] },
+ getMinColour: { [0, 255, 255] as int[] }, // cyan
+ getMaxColour: { [0, 0, 255] as int[] }, // blue
+ count:
+ { res, feats ->
+ int phos
+ int turn
+ for (sf in feats)
+ {
+ /*
+ * Here we inspect the type of the sequence feature.
+ * You can also test sf.description, sf.score, sf.featureGroup,
+ * sf.strand, sf.phase, sf.begin, sf.end
+ * or sf.getValue(attributeName) for GFF 'column 9' properties
+ */
+ if (sf.type.contains('TURN'))
+ {
+ turn++
+ }
+ if (sf.type.contains('PHOSPHORYLATION'))
+ {
+ phos++
+ }
+ }
+ [phos, turn] as int[]
+ }
+ ] as FeatureSetCounterI
+
+/*
+ * Register the annotation calculator with Jalview
+ */
+AlignmentAnnotationFactory.newCalculator(annotator)