From c03875530f7e0ec66daf8b1273cb807b08454692 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 5 May 2016 15:36:08 +0100 Subject: [PATCH] JAL-2068 better documentation in example script --- examples/groovy/featureCounter.groovy | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/groovy/featureCounter.groovy b/examples/groovy/featureCounter.groovy index 08d038d..42d3187 100644 --- a/examples/groovy/featureCounter.groovy +++ b/examples/groovy/featureCounter.groovy @@ -5,6 +5,9 @@ import jalview.workers.AlignmentAnnotationFactory; * Example script that registers two alignment annotation calculators * - one that counts residues in a column with Pfam annotation * - one that counts only charged residues with Pfam annotation + * To try this, first load uniref50.fa from the examples folder, then load features + * from examples/exampleFeatures.txt, before running this script from the Groovy console. + * Modify this example as required to count by column any desired value that can be * derived from the residue and sequence features at each position of an alignment. */ @@ -49,7 +52,7 @@ def hasPfam = { features -> * - a closure (groovy function) that tests whether to include a residue * - a closure that tests whether to increment count based on sequence features */ -def getColumnCounter = { name, desc, residueTester, featureCounter -> +def getColumnCounter = { name, desc, acceptResidue, acceptFeatures -> [ getName: { name }, getDescription: { desc }, @@ -58,9 +61,9 @@ def getColumnCounter = { name, desc, residueTester, featureCounter -> count: { res, feats -> def c = 0 - if (residueTester.call(res)) + if (acceptResidue.call(res)) { - if (featureCounter.call(feats)) + if (acceptFeatures.call(feats)) { c++ } @@ -71,12 +74,12 @@ def getColumnCounter = { name, desc, residueTester, featureCounter -> } /* - * Define annotation that counts any residue with Pfam domain annotation + * Define an annotation that counts any residue with Pfam domain annotation */ def pfamAnnotation = getColumnCounter("Pfam", "Count of residues with Pfam domain annotation", {true}, hasPfam) /* - * Define annotation that counts charged residues with Pfam domain annotation + * Define an annotation that counts charged residues with Pfam domain annotation */ def chargedPfamAnnotation = getColumnCounter("Pfam charged", "Count of charged residues with Pfam domain annotation", isCharged, hasPfam) -- 1.7.10.2