X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=examples%2Fgroovy%2FFeatureSetCounter.groovy;fp=examples%2Fgroovy%2FFeatureSetCounter.groovy;h=0000000000000000000000000000000000000000;hb=e811386cfe6d7ab7d73db56a31ac83732e185861;hp=43f44a42e48c355019fcad36bf632a432484435f;hpb=c41d746aef7cc3fda8d4fcee41a19443b2bf0281;p=jalview.git diff --git a/examples/groovy/FeatureSetCounter.groovy b/examples/groovy/FeatureSetCounter.groovy deleted file mode 100644 index 43f44a4..0000000 --- a/examples/groovy/FeatureSetCounter.groovy +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ - -import jalview.workers.FeatureSetCounterI; -import jalview.workers.AlignmentAnnotationFactory; - -/* - * Demonstration of FeatureSetWorker - * compute annotation tracks counting number of displayed - * features of each type in each column - */ - -/* - * discover features on the current view - */ - -def featuresVis=jalview.bin.Jalview.currentAlignFrame.getCurrentView().getFeaturesDisplayed().getVisibleFeatures().toList(); -assert 'java.util.ArrayList' == featuresVis.class.name - -/* - * A closure that returns a vector for featuresVis of 1 or 0 for any features of type observed - * Argument should be a list of SequenceFeature - */ -def hasType = { features -> - int[] obs=new int[featuresVis.size()]; - for (sf in features) - { - /* - * 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 - */ - int pos = 0; - for (type in featuresVis) { - if (type.equals(sf.type)) { - obs[pos]=1; - } else { - obs[pos]=0; - } - pos++; - } - } - obs; - } - -/* - * Closure to generate a counter for feature types in featuresVis - * calls hasType to count types in the int[] count(String res, List feats) method - */ -def getColumnSetCounter = { - [ - getNames: { featuresVis as String[] }, - getDescriptions: { featuresVis as String[] }, - getMinColour: { [0, 255, 255] }, // cyan - getMaxColour: { [0, 0, 255] }, // blue - count: - { res, feats -> - hasType.call(feats) - } - ] as FeatureSetCounterI } - -/* - * and register a FeatuerSetCounter instance - */ -AlignmentAnnotationFactory.newCalculator(getColumnSetCounter.call())