Package vcf

Class FilterUtil

java.lang.Object
vcf.FilterUtil

public final class FilterUtil extends Object
Class FilterUtil contains static methods for constructing marker filters.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Filter<Marker>
    Returns a filter that excludes markers that are not contained in the specified chromosome interval, or returns a filter that accepts all markers if the chromInterval parameter is null.
    static Filter<Marker>
    Returns a filter that accepts all markers which do not have an identifier or chromomsome position present in the specified collection.
    static Filter<Marker>
    markerFilter(File excludeMarkersFile)
    Returns a filter that excludes markers that have an identifier or genome coordinates that matches a line of the specified file, or returns a filter that accepts all markers if the excludeMarkersFile parameter is null.
    static boolean
    markerIsInSet(Marker marker, Set<String> set)
    Returns true if the specified marker has an identifier is in the specified set, or if ("marker.chrom()" + ":" + "marker.pos()") is in the specified set, and returns false otherwise.
    static Filter<String>
    sampleFilter(File excludeSamplesFile)
    Returns a filter that excludes samples that have an identifier that matches a line of the specified file, or returns a filter that accepts all strings if the excludeSamplesFile parameter is null
    static Filter<String>
    sampleFilter(File sampleFile, boolean includeFilter)
    Returns a string filter determined by the specified parameters.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • markerFilter

      public static Filter<Marker> markerFilter(File excludeMarkersFile)
      Returns a filter that excludes markers that have an identifier or genome coordinates that matches a line of the specified file, or returns a filter that accepts all markers if the excludeMarkersFile parameter is null. Genome coordinates must be in "CHROM:POS" format.
      Parameters:
      excludeMarkersFile - a file that contains an identifier or genome coordinate of one excluded marker on each line
      Returns:
      a filter that excludes markers that have an identifier or genome coordinates that matches a line of the specified file, or null if the excludeMarkersFile parameter is null
      Throws:
      IllegalArgumentException - if the specified file does not exist
      IllegalArgumentException - if the specified file is a directory
      IllegalArgumentException - if any line of the specified file contains two non-white-space characters separated by one or more white-space characters
    • chromIntFilter

      public static Filter<Marker> chromIntFilter(ChromInterval chromInterval)
      Returns a filter that excludes markers that are not contained in the specified chromosome interval, or returns a filter that accepts all markers if the chromInterval parameter is null.
      Parameters:
      chromInterval - a chromosome interval or null
      Returns:
      a filter that excludes markers that are not contained in the specified chromosome interval
    • sampleFilter

      public static Filter<String> sampleFilter(File excludeSamplesFile)
      Returns a filter that excludes samples that have an identifier that matches a line of the specified file, or returns a filter that accepts all strings if the excludeSamplesFile parameter is null
      Parameters:
      excludeSamplesFile - a file which contains an identifier of one excluded sample on each line
      Returns:
      a filter that excludes samples that have an identifier that matches a line of the specified file, or null if the excludeSamplesFile parameter is null
      Throws:
      IllegalArgumentException - if the specified file does not exist
      IllegalArgumentException - if the specified file is a directory
      IllegalArgumentException - if any line of the specified file contains two non-white-space characters separated by one or more white-space characters
    • sampleFilter

      public static Filter<String> sampleFilter(File sampleFile, boolean includeFilter)
      Returns a string filter determined by the specified parameters. The returned filter will accept all strings if (sampleFile == null). Otherwise, the returned filter will accept only strings found in sampleFile if (includeFilter == true) and will reject only strings found in sampleFile if (includeFilter == false). Each line in sampleFile can contain at most one white-space delimited field.
      Parameters:
      sampleFile - a file containing one string per line
      includeFilter - true if the filter should accept string identifiers found in sampleFile and false if the filter should reject string identifiers found in sampleFile.
      Returns:
      a string filter
      Throws:
      IllegalArgumentException - if the specified file does not exist
      IllegalArgumentException - if the specified file is a directory
      IllegalArgumentException - if any line of the specified file contains two non-white-space characters separated by one or more white-space characters
    • markerIsInSet

      public static boolean markerIsInSet(Marker marker, Set<String> set)
      Returns true if the specified marker has an identifier is in the specified set, or if ("marker.chrom()" + ":" + "marker.pos()") is in the specified set, and returns false otherwise.
      Parameters:
      marker - a marker
      set - a set of marker identifiers and chromosome positions in "CHROM:POS" format
      Returns:
      true if the specified marker has an identifier is in the specified set or if ("marker.chrom()" + ":" + "marker.pos()") is in the specified set
      Throws:
      NullPointerException - if marker == null || set == null
    • excludeIdFilter

      public static Filter<Marker> excludeIdFilter(Collection<String> exclude)
      Returns a filter that accepts all markers which do not have an identifier or chromomsome position present in the specified collection. A marker is excluded if exclude.contains(marker.id(j)) == true for any 0 <= j < marker.nIds() or if exclude.contains(marker.chrom() + ":" + marker.pos()) == true.
      Parameters:
      exclude - a collection of marker identifiers and chromosome positions in "CHROM:POS" format
      Returns:
      a filter that accepts all markers which do not have an identifier or chromomsome position present in the specified collection
      Throws:
      NullPointerException - if exclude == null