git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6e2c975
)
JAL-2068 better documentation in example script
author
gmungoc
<g.m.carstairs@dundee.ac.uk>
Thu, 5 May 2016 14:36:08 +0000
(15:36 +0100)
committer
gmungoc
<g.m.carstairs@dundee.ac.uk>
Thu, 5 May 2016 14:36:08 +0000
(15:36 +0100)
examples/groovy/featureCounter.groovy
patch
|
blob
|
history
diff --git
a/examples/groovy/featureCounter.groovy
b/examples/groovy/featureCounter.groovy
index
08d038d
..
42d3187
100644
(file)
--- 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
* 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.
*/
* 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
*/
* - 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 },
[
getName: { name },
getDescription: { desc },
@@
-58,9
+61,9
@@
def getColumnCounter = { name, desc, residueTester, featureCounter ->
count:
{ res, feats ->
def c = 0
count:
{ res, feats ->
def c = 0
- if (residueTester.call(res))
+ if (acceptResidue.call(res))
{
{
- if (featureCounter.call(feats))
+ if (acceptFeatures.call(feats))
{
c++
}
{
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)
/*
*/
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)
*/
def chargedPfamAnnotation = getColumnCounter("Pfam charged", "Count of charged residues with Pfam domain annotation", isCharged, hasPfam)