## org.biojava.bio.seq
Class FilterUtils

    java.lang.Object
      org.biojava.bio.seq.FilterUtils

public class FilterUtils
extends java.lang.Object

A set of FeatureFilter algebraic operations.

Since:
  1.2
Author:
  Matthew Pocock, Thomas Down

Nested Class Summary
`class` `FilterUtils.DelegatingTransformer` An implementation of FilterTransformer that attempts to transform by one transformer, and if that fails, by another.
`static interface` `FilterUtils.FilterTransformer` An object able to transform some FeatureFilter instances sytematically into others.

Constructor Summary
`FilterUtils()`

Method Summary
`static FeatureFilter` `all()`
`static FeatureFilter` `and(FeatureFilter[] filters)`
`static FeatureFilter` `and(FeatureFilter c1, FeatureFilter c2)`
`static boolean` `areDisjoint(FeatureFilter a, FeatureFilter b)` Determines is two queries can be proven to be disjoint.
`static boolean` `areEqual(FeatureFilter f1, FeatureFilter f2)`
`static boolean` `areProperSubset(FeatureFilter sub, FeatureFilter sup)` Determines if the set of features matched by sub can be `proven` to be a proper subset of the features matched by sup.
`static FeatureFilter` `byAncestor(FeatureFilter ancestorFilter)`
`static FeatureFilter` `byAnnotation(java.lang.Object key, java.lang.Object value)`
`static FeatureFilter` `byAnnotationType(AnnotationType type)`
`static FeatureFilter` `byAnnotationType(java.lang.Object key, java.lang.Class valClass)`
`static FeatureFilter` `byChild(FeatureFilter childFilter)`
`static FeatureFilter` `byClass(java.lang.Class clazz)`
`static FeatureFilter` `byComponentName(java.lang.String compName)`
`static FeatureFilter` `byDescendant(FeatureFilter descFilter)`
`static FeatureFilter` `byFrame(FramedFeature.ReadingFrame frame)`
`static FeatureFilter` `byPairwiseScore(double minScore, double maxScore)`
`static FeatureFilter` `byParent(FeatureFilter parentFilter)`
`static FeatureFilter` `bySequenceName(java.lang.String name)`
`static FeatureFilter` `bySource(java.lang.String source)`
`static FeatureFilter` `byStrand(StrandedFeature.Strand strand)`
`static FeatureFilter` `byType(java.lang.String type)`
`static FeatureFilter` `containedByLocation(Location loc)`
`static Location` `extractOverlappingLocation(FeatureFilter ff)` Try to determine the minimal location which all features matching a given filter must overlap.
`static FeatureFilter` `hasAnnotation(java.lang.Object key)`
`static FeatureFilter` `leaf()`
`static FeatureFilter` `none()`
`static FeatureFilter` `not(FeatureFilter filter)`
`static FeatureFilter` `optimize(FeatureFilter filter)`
`static FeatureFilter` `or(FeatureFilter[] filters)`
`static FeatureFilter` `or(FeatureFilter c1, FeatureFilter c2)`
`static FeatureFilter` `overlapsLocation(Location loc)`
`static FeatureFilter` `topLevel()`
`static FeatureFilter` `transformFilter(FeatureFilter ff, FilterUtils.FilterTransformer trans)` This is a general framework method for transforming one filter into another.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FilterUtils

    public FilterUtils()

Method Detail

### areProperSubset

    public static boolean areProperSubset(FeatureFilter sub,
                                          FeatureFilter sup)

  Determines if the set of features matched by sub can be `proven` to 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 filter
    `sup` - the superset filter
  Returns:
    `true` if `sub` is a proper subset of `sup`

### areDisjoint

    public static boolean areDisjoint(FeatureFilter a,
                                      FeatureFilter b)

  Determines is 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 FeatureFilter
    `b` - the second FeatureFilter
  Returns:
    `true` if they are proved to be disjoint, `false` otherwise

### extractOverlappingLocation

    public static Location extractOverlappingLocation(FeatureFilter ff)

  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 `ff` must overlap, or `null` if no proof is possible (normally indicates that the filter has nothing to do with location).
  Since:
    1.2

### areEqual

    public static final boolean areEqual(FeatureFilter f1,
                                         FeatureFilter f2)

### byType

    public static final FeatureFilter byType(java.lang.String type)

### bySource

    public static final FeatureFilter bySource(java.lang.String source)

### byClass

    public static final FeatureFilter byClass(java.lang.Class clazz)
                                       throws java.lang.ClassCastException

  Throws:
    `java.lang.ClassCastException`

### containedByLocation

    public static final FeatureFilter containedByLocation(Location loc)

### overlapsLocation

    public static final FeatureFilter overlapsLocation(Location loc)

### bySequenceName

    public static final FeatureFilter bySequenceName(java.lang.String name)

### not

    public static final FeatureFilter not(FeatureFilter filter)

### and

    public static final FeatureFilter and(FeatureFilter c1,
                                          FeatureFilter c2)

### and

    public static final FeatureFilter and(FeatureFilter[] filters)

### or

    public static final FeatureFilter or(FeatureFilter c1,
                                         FeatureFilter c2)

### or

    public static final FeatureFilter or(FeatureFilter[] filters)

### byAnnotationType

    public static final FeatureFilter byAnnotationType(AnnotationType type)

### byAnnotation

    public static final FeatureFilter byAnnotation(java.lang.Object key,
                                                   java.lang.Object value)

### byAnnotationType

    public static final FeatureFilter byAnnotationType(java.lang.Object key,
                                                       java.lang.Class valClass)

### hasAnnotation

    public static final FeatureFilter hasAnnotation(java.lang.Object key)

### byStrand

    public static final FeatureFilter byStrand(StrandedFeature.Strand strand)

### byParent

    public static final FeatureFilter byParent(FeatureFilter parentFilter)

### byAncestor

    public static final FeatureFilter byAncestor(FeatureFilter ancestorFilter)

### byChild

    public static final FeatureFilter byChild(FeatureFilter childFilter)

### byDescendant

    public static final FeatureFilter byDescendant(FeatureFilter descFilter)

### byFrame

    public static final FeatureFilter byFrame(FramedFeature.ReadingFrame frame)

### byPairwiseScore

    public static final FeatureFilter byPairwiseScore(double minScore,
                                                      double maxScore)

### byComponentName

    public static final FeatureFilter byComponentName(java.lang.String compName)

### topLevel

    public static final FeatureFilter topLevel()

### leaf

    public static final FeatureFilter leaf()

### all

    public static final FeatureFilter all()

### none

    public static final FeatureFilter none()

### optimize

    public static final FeatureFilter optimize(FeatureFilter filter)

### transformFilter

    public static FeatureFilter transformFilter(FeatureFilter ff,
                                                FilterUtils.FilterTransformer trans)

  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 transform
    `trans` - a FilterTransformer encapsulating rules about how to transform filters