Class FilterUtils
- Since:
- 1.2
- Author:
- Matthew Pocock, Thomas Down
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassAn implementation of FilterTransformer that attempts to transform by one transformer, and if that fails, by another.static interfaceAn object able to transform some FeatureFilter instances sytematically into others. -
Method Summary
Modifier and TypeMethodDescriptionstatic final FeatureFilterall()Return a filter which matches all features.static final FeatureFilterand(FeatureFilter[] filters) Constructs a new filter which matches the intersection of a set of filters.static final FeatureFilterand(FeatureFilter c1, FeatureFilter c2) Construct a new filter which matches the intersection of two other filters.static booleanDetermines if two queries can be proven to be disjoint.static final booleanareEqual(FeatureFilter f1, FeatureFilter f2) Decide if two feature filters accept exactly the same set of features.static booleanareProperSubset(FeatureFilter sub, FeatureFilter sup) Determines if the set of features matched by sub can beprovento be a proper subset of the features matched by sup.static final FeatureFilterbyAncestor(FeatureFilter ancestorFilter) Match features where at least one of the ancestors matches the specified filter.static final FeatureFilterbyAnnotation(Object key, Object value) Match features where the annotation property namedkeyis equal tovalue.static final FeatureFilterbyAnnotationType(Object key, Class valClass) Match features where the annotation property namedkeyis an instance ofvalClass.static final FeatureFilterMatch features with annotations matching the specifiedAnnotationTypestatic final FeatureFilterbyChild(FeatureFilter childFilter) Match features where at least one child feature matches the supplied filter.static final FeatureFilterConstruct a filter which matches features which are assignable to the specified class or interface.static final FeatureFilterbyComponentName(String compName) Construct a filter which matches all features which implement theComponentFeatureinterface and have acomponentNameproperty equal to the specified valuestatic final FeatureFilterbyDescendant(FeatureFilter descFilter) Match features where at least one decendant feature -- possibly but not necessarily an immediate child -- matches the specified filter.static final FeatureFilterConstruct a filter which matches FramedFeatures with the specified reading frame.static final FeatureFilterbyPairwiseScore(double minScore, double maxScore) Match SeqSimilaritiy features with scores in the specified range.static final FeatureFilterbyParent(FeatureFilter parentFilter) Match features where the parent feature matches the specified filter.static final FeatureFilterbySequenceName(String name) Match features attached to sequences with a specified name.static final FeatureFilterConstruct a filter which matches features with a specificsourcevalue.static final FeatureFilterbyStrand(StrandedFeature.Strand strand) Match StrandedFeatures on the specified strand.static final FeatureFilterConstruct a filter which matches features with a specifictypevalue.static final FeatureFilterConstruct a filter which matches features with locations wholly contained by the specifiedLocation.static LocationTry to determine the minimal location which all features matching a given filter must overlap.static final FeatureFilterhasAnnotation(Object key) Match features where the propertykeyhas been defined as having some value, regardless of the exact value.static final FeatureFilterleaf()Return a filter which matches features with zero children.static final FeatureFilternone()Return a filter which matches no features.static final FeatureFilternot(FeatureFilter filter) Construct a new filter which is the negation offilter.static final FeatureFilteronlyChildren(FeatureFilter child) Construct a filter which matches features whose children all match the specified filter.static final FeatureFilteronlyDescendants(FeatureFilter desc) Construct a filter which matches features whose decendants all match the specified filter.static final FeatureFilteroptimize(FeatureFilter filter) Attempts to reduce a FeatureFilter to an equivalent FeatureFilter with fewer terms.static final FeatureFilteror(FeatureFilter[] filters) Construct a new filter which matches the intersection of two filters.static final FeatureFilteror(FeatureFilter c1, FeatureFilter c2) Construct a new filter which matches the union of two filters.static final FeatureFilteroverlapsLocation(Location loc) Construct a filter which matches features with locations contained by or overlapping the specifiedLocation.static final FeatureFilterConstruct a filter which matches features with locations where the interval between theminandmaxpositions are contained by the specifiedLocation.static final FeatureFilterConstruct a filter which matches features with locations where the interval between theminandmaxpositions are contained by or overlap the specifiedLocation.static final FeatureFiltertopLevel()Return a filter which matches all top-level features.static FeatureFilterThis is a general framework method for transforming one filter into another.static ObjectvisitFilter(FeatureFilter filter, Visitor visitor) Applies a visitor to a filter, and returns the visitor's result or null.
-
Method Details
-
areProperSubset
Determines if the set of features matched by sub can beprovento be a proper subset of the features matched by sup.If the filter sub matches only features that are matched by sup, then it is a proper subset. It is still a proper subset if it does not match every feature in sup, as long as no feature matches sub that is rejected by sup.
- Parameters:
sub- the subset filtersup- the superset filter- Returns:
trueifsubis a proper subset ofsup
-
areDisjoint
Determines if two queries can be proven to be disjoint.They are disjoint if there is no element that is matched by both filters - that is, they have an empty intersection. Order of arguments to this method is not significant.
- Parameters:
a- the first FeatureFilterb- the second FeatureFilter- Returns:
trueif they are proved to be disjoint,falseotherwise
-
extractOverlappingLocation
Try to determine the minimal location which all features matching a given filter must overlap.- Parameters:
ff- A feature filter- Returns:
- the minimal location which any features matching
ffmust overlap, ornullif no proof is possible (normally indicates that the filter has nothing to do with location). - Since:
- 1.2
-
areEqual
Decide if two feature filters accept exactly the same set of features.Two feature filters are equal if it can be proven that
f1.accept(feature) == f2.accept(feature)for all values offeature. If areEqual returns false, this may indicate that they accept clearly different sets of features. It may also, howerver, indicate that the method was unable to prove that they were equal.Note that given a finite set of features, f1 and f2 may match the same sub-set of those features even if they are not equal.
- Parameters:
f1- the first filterf2- the second filter- Returns:
- true if they can be proven to be equivalent
-
byType
Construct a filter which matches features with a specifictypevalue. -
bySource
Construct a filter which matches features with a specificsourcevalue. -
byClass
Construct a filter which matches features which are assignable to the specified class or interface.- Throws:
ClassCastException
-
containedByLocation
Construct a filter which matches features with locations wholly contained by the specifiedLocation. -
overlapsLocation
Construct a filter which matches features with locations contained by or overlapping the specifiedLocation. -
shadowOverlapsLocation
Construct a filter which matches features with locations where the interval between theminandmaxpositions are contained by or overlap the specifiedLocation. -
shadowContainedByLocation
Construct a filter which matches features with locations where the interval between theminandmaxpositions are contained by the specifiedLocation. -
bySequenceName
Match features attached to sequences with a specified name. -
not
Construct a new filter which is the negation offilter. -
and
Construct a new filter which matches the intersection of two other filters. -
and
Constructs a new filter which matches the intersection of a set of filters. -
or
Construct a new filter which matches the union of two filters. -
or
Construct a new filter which matches the intersection of two filters. -
byAnnotationType
Match features with annotations matching the specifiedAnnotationType -
byAnnotation
Match features where the annotation property namedkeyis equal tovalue. -
byAnnotationType
Match features where the annotation property namedkeyis an instance ofvalClass. -
hasAnnotation
Match features where the propertykeyhas been defined as having some value, regardless of the exact value. -
byStrand
Match StrandedFeatures on the specified strand. -
byParent
Match features where the parent feature matches the specified filter. This cannot match top-level features. -
byAncestor
Match features where at least one of the ancestors matches the specified filter. This cannot match top-level features. -
byChild
Match features where at least one child feature matches the supplied filter. This does not match leafFeatures. -
byDescendant
Match features where at least one decendant feature -- possibly but not necessarily an immediate child -- matches the specified filter. -
onlyChildren
Construct a filter which matches features whose children all match the specified filter. This filter always matches leaf features. -
onlyDescendants
Construct a filter which matches features whose decendants all match the specified filter. This filter always matches leaf features. -
byFrame
Construct a filter which matches FramedFeatures with the specified reading frame. -
byPairwiseScore
Match SeqSimilaritiy features with scores in the specified range. -
byComponentName
Construct a filter which matches all features which implement theComponentFeatureinterface and have acomponentNameproperty equal to the specified value -
topLevel
Return a filter which matches all top-level features. These are features which are direct children of aSequencerather than anotherFeature. -
leaf
Return a filter which matches features with zero children. -
all
Return a filter which matches all features. -
none
Return a filter which matches no features. -
optimize
Attempts to reduce a FeatureFilter to an equivalent FeatureFilter with fewer terms.This will attempt to push all leaf constraints as far from the root of the filter expression as possible, in an attept to prove an empty or universal set. It will then propogate these through the logical operators in an attempt to reduce the entire expression to the empty or universal set. If filters can be combined (for example, overlapping constraints), then this will happen on the way.
The resulting filter is guaranteed to accept exactly the same set of\ features that is accepted by the argument. In particular,
areEqual(filter, optimize(filter))is always true.- Parameters:
filter- the FeatureFilter to optimize- Returns:
- an optimized version
-
transformFilter
This is a general framework method for transforming one filter into another. This method will handle the logical elements of a query (and, or, not) and delegate all the domain-specific munging to a FilterTransformer object.
The transformer could flip strands and locations of elements of a filter, add or remove attributes required in annotations, or systematically alter feature types or sources.
- Parameters:
ff- the FeatureFilter to transformtrans- a FilterTransformer encapsulating rules about how to transform filters
-
visitFilter
Applies a visitor to a filter, and returns the visitor's result or null.- Parameters:
filter- the filter to scanvisitor- the visitor to scan with- Returns:
- the result of the visitor or null
- Throws:
BioException- if the required walker could not be created
-