* 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.
*/
* - 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 },
count:
{ res, feats ->
def c = 0
- if (residueTester.call(res))
+ if (acceptResidue.call(res))
{
- if (featureCounter.call(feats))
+ if (acceptFeatures.call(feats))
{
c++
}
}
/*
- * 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)