Package vcf

Interface GT

  • All Known Implementing Classes:
    BasicGT, RefGT, RestrictedGT, SplicedGT, XRefGT

    public interface GT

    Interface GT represents genotype data for a list of markers and a list of samples.

    All instances of GT are required to be immutable.

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int allele​(int marker, int hap)
      Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing.
      int allele1​(int marker, int sample)
      Returns the first allele for the specified marker and sample or return -1 if the allele is missing.
      int allele2​(int marker, int sample)
      Returns the second allele for the specified marker and sample or return -1 if the allele is missing.
      static float gl​(GT gt, int marker, int sample, int allele1, int allele2)
      Returns the probability of the observed data for the specified marker and sample if the specified pair of unordered alleles is the true genotype.
      boolean isPhased()
      Returns true if the genotype for each marker and sample has non-missing alleles and is either haploid or diploid with a phased allele separator, and returns false otherwise.
      boolean isReversed()
      Returns true if the markers are ordered by decreasing chromosome base position, and returns false otherwise.
      Marker marker​(int marker)
      Returns the specified marker.
      Markers markers()
      Returns the list of markers in order of increasing chromosome position.
      int nHaps()
      Returns the number of haplotypes.
      int nMarkers()
      Returns the number of markers.
      int nSamples()
      Returns the number of samples.
      GT restrict​(int start, int end)
      Returns a new GT instance restricted to genotype data for the specified markers.
      GT restrict​(Markers markers, int[] indices)
      Returns a GT instance restricted to genotype data for the specified markers.
      Samples samples()
      Returns the list of samples.
    • Method Detail

      • isReversed

        boolean isReversed()
        Returns true if the markers are ordered by decreasing chromosome base position, and returns false otherwise.
        Returns:
        true if the markers are ordered by decreasing chromosome base position
      • nMarkers

        int nMarkers()
        Returns the number of markers.
        Returns:
        the number of markers
      • marker

        Marker marker​(int marker)
        Returns the specified marker.
        Parameters:
        marker - a marker index
        Returns:
        the specified marker
        Throws:
        java.lang.IndexOutOfBoundsException - if marker < 0 || marker >= this.nMarkers()
      • markers

        Markers markers()
        Returns the list of markers in order of increasing chromosome position. If (this.isReversed() == false) then (this.markers().marker(j).equals(this.marker(j)) == true) for all (0 <= j && j < this.nMarkers()). If (this.isReversed() == true) then (this.markers().marker(this.nMarkers() - 1 - j).equals(this.marker(j)) == true) for all (0 <= j && j < this.nMarkers())
        Returns:
        the list of markers in order of increasing chromosome position
      • nHaps

        int nHaps()
        Returns the number of haplotypes. The returned value is equal to 2*this.nSamples().
        Returns:
        the number of haplotypes
      • nSamples

        int nSamples()
        Returns the number of samples.
        Returns:
        the number of samples
      • samples

        Samples samples()
        Returns the list of samples.
        Returns:
        the list of samples
      • isPhased

        boolean isPhased()
        Returns true if the genotype for each marker and sample has non-missing alleles and is either haploid or diploid with a phased allele separator, and returns false otherwise.
        Returns:
        true if the genotype for each marker and sample is a phased, non-missing genotype
      • allele1

        int allele1​(int marker,
                    int sample)
        Returns the first allele for the specified marker and sample or return -1 if the allele is missing. The order of the two alleles is unspecified if this.isPhased() == false.
        Parameters:
        marker - the marker index
        sample - the sample index
        Returns:
        the first allele for the specified marker and sample
        Throws:
        java.lang.IndexOutOfBoundsException - if marker < 0 || marker >= this.nMarkers()
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= this.nSamples()
      • allele2

        int allele2​(int marker,
                    int sample)
        Returns the second allele for the specified marker and sample or return -1 if the allele is missing. The order of the two alleles is unspecified if this.isPhased() == false.
        Parameters:
        marker - the marker index
        sample - the sample index
        Returns:
        the allele for the specified marker and sample
        Throws:
        java.lang.IndexOutOfBoundsException - if marker < 0 || marker >= this.nMarkers()
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= this.nSamples()
      • allele

        int allele​(int marker,
                   int hap)
        Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing. The order of the two alleles is unspecified if this.isPhased() == false.
        Parameters:
        marker - the marker index
        hap - the haplotype index
        Returns:
        the allele on the specified haplotype for the specified marker
        Throws:
        java.lang.IndexOutOfBoundsException - if marker < 0 || marker >= this.nMarkers()
        java.lang.IndexOutOfBoundsException - if hap < 0 || hap >= this.nHaps()
      • restrict

        GT restrict​(Markers markers,
                    int[] indices)
        Returns a GT instance restricted to genotype data for the specified markers.
        Parameters:
        markers - the list of markers in the returned instance
        indices - a list of distinct marker indices (from this.markers()) in increasing order
        Returns:
        a GT instance restricted to genotype data for the specified markers
        Throws:
        java.lang.IndexOutOfBoundsException - if there exists j such that (0 <= j && j < indices.length) such that (indices[j] < 0 || indices[j] >= this.nMarkers())
        java.lang.IllegalArgumentException - if there exists j such that (1 <= j && j < indices.length) such that (indices[j] <= indice[j - 1])
        java.lang.IllegalArgumentException - if there exists j such that (0 <= j && j < indices.length) such that (this.marker(indices[j]).equals(markers.marker(j)) == false)
        java.lang.NullPointerException - if indices == null
        java.lang.UnsupportedOperationException - if this.isReversed() == true
      • restrict

        GT restrict​(int start,
                    int end)
        Returns a new GT instance restricted to genotype data for the specified markers.
        Parameters:
        start - the start marker (inclusive)
        end - the end marker (exclusive)
        Returns:
        a GT instance restricted to genotype data for the specified markers
        Throws:
        java.lang.IllegalArgumentException - if start >= end
        java.lang.IndexOutOfBoundsException - if start < 0 || end > this.markers()
      • gl

        static float gl​(GT gt,
                        int marker,
                        int sample,
                        int allele1,
                        int allele2)
        Returns the probability of the observed data for the specified marker and sample if the specified pair of unordered alleles is the true genotype. Returns 1.0f if the corresponding genotype determined by the isPhased(), allele1(), and allele2() methods is consistent with the specified ordered genotype, and returns 0.0f otherwise.
        Parameters:
        gt - the genotype data
        marker - the marker index
        sample - the sample index
        allele1 - the first allele index
        allele2 - the second allele index
        Returns:
        the probability of the observed data for the specified marker and sample if the specified pair of ordered alleles is the true ordered genotype
        Throws:
        java.lang.IndexOutOfBoundsException - if marker < 0 || marker >= this.nMarkers()
        java.lang.IndexOutOfBoundsException - if samples < 0 || samples >= this.nSamples()
        java.lang.IndexOutOfBoundsException - if allele1 < 0 || allele1 >= this.marker(marker).nAlleles()
        java.lang.IndexOutOfBoundsException - if allele2 < 0 || allele2 >= this.marker(marker).nAlleles()