Package vcf

Class RefGT

  • All Implemented Interfaces:
    GT

    public class RefGT
    extends java.lang.Object
    implements GT

    Class RefGT stores a list of samples and a haplotype pair for each sample.

    Instances of class BasicRefGT are immutable.

    • Constructor Summary

      Constructors 
      Constructor Description
      RefGT​(Markers markers, Samples samples, RefGTRec[] refVcfRecs)
      Constructs a new RefGT instance.
      RefGT​(RefGTRec[] refVcfRecs)
      Constructs a new RefHapPairs instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int allele​(int marker, int haplotype)
      Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing.
      int allele1​(int marker, int hapPair)
      Returns the first allele for the specified marker and sample or return -1 if the allele is missing.
      int allele2​(int marker, int hapPair)
      Returns the second allele for the specified marker and sample or return -1 if the allele is missing.
      RefGTRec get​(int marker)
      Returns the RefGTRec for the specified marker.
      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.
      RefGT restrict​(int start, int end)
      Returns a new GT instance restricted to genotype data for the specified markers.
      RefGT restrict​(Markers markers, int[] indices)
      Returns a GT instance restricted to genotype data for the specified markers.
      static RefGT restrict​(RefGT refGT, int[] indices)
      Returns a RefGT instance restricted to genotype data for the specified markers.
      Samples samples()
      Returns the list of samples.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RefGT

        public RefGT​(Markers markers,
                     Samples samples,
                     RefGTRec[] refVcfRecs)
        Constructs a new RefGT instance.
        Parameters:
        markers - the sequence of markers
        samples - the sequence of samples
        refVcfRecs - the sequence of per-marker genotype data
        Throws:
        java.lang.IllegalArgumentException - if markers.nMarkers() != refVcfRecs.length
        java.lang.IllegalArgumentException - if refVcfRecs[k].samples().equals(samples) == false for any k satisfying 0 <= k && k < refVcfRecs.length
        java.lang.IllegalArgumentException - if refVcfRecs[k].marker().equals(markers.marker(k)) == false for any k satisfying 0 <= k && k < refVcfRecs.length
        java.lang.IllegalArgumentException - if refVcfRecs[k].isPhased() == false for any k satisfying 0 <= k && k < refVcfRecs.length
        java.lang.NullPointerException - if markers == null || samples == null || refVcfRecs == null || refVcfRecs[k] == null for any k satisfying 0 <= k && k <= refVcfRecs.length
      • RefGT

        public RefGT​(RefGTRec[] refVcfRecs)
        Constructs a new RefHapPairs instance.
        Parameters:
        refVcfRecs - the sequence of per-marker genotype data
        Throws:
        java.lang.IllegalArgumentException - if refVcfRecs.length == 0
        java.lang.IllegalArgumentException - if refVcfRecs[k].samples().equals(samples) == false for any k satisfying 0 <= k && k < refVcfRecs.length
        java.lang.IllegalArgumentException - if refVcfRecs[k].isPhased() == false for any k satisfying 0 <= k && k < refVcfRecs.length
        java.lang.NullPointerException - if samples == null || refVcfRecs == null
        java.lang.NullPointerException - if (refVcfRecs[k] == null) for any k satisfying (0 <= k && k <= refVcfRecs.length)
    • Method Detail

      • isReversed

        public boolean isReversed()
        Description copied from interface: GT
        Returns true if the markers are ordered by decreasing chromosome base position, and returns false otherwise.
        Specified by:
        isReversed in interface GT
        Returns:
        true if the markers are ordered by decreasing chromosome base position
      • nMarkers

        public int nMarkers()
        Description copied from interface: GT
        Returns the number of markers.
        Specified by:
        nMarkers in interface GT
        Returns:
        the number of markers
      • marker

        public Marker marker​(int marker)
        Description copied from interface: GT
        Returns the specified marker.
        Specified by:
        marker in interface GT
        Parameters:
        marker - a marker index
        Returns:
        the specified marker
      • markers

        public Markers markers()
        Description copied from interface: GT
        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())
        Specified by:
        markers in interface GT
        Returns:
        the list of markers in order of increasing chromosome position
      • nHaps

        public int nHaps()
        Description copied from interface: GT
        Returns the number of haplotypes. The returned value is equal to 2*this.nSamples().
        Specified by:
        nHaps in interface GT
        Returns:
        the number of haplotypes
      • nSamples

        public int nSamples()
        Description copied from interface: GT
        Returns the number of samples.
        Specified by:
        nSamples in interface GT
        Returns:
        the number of samples
      • samples

        public Samples samples()
        Description copied from interface: GT
        Returns the list of samples.
        Specified by:
        samples in interface GT
        Returns:
        the list of samples
      • isPhased

        public boolean isPhased()
        Description copied from interface: GT
        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.
        Specified by:
        isPhased in interface GT
        Returns:
        true if the genotype for each marker and sample is a phased, non-missing genotype
      • allele1

        public int allele1​(int marker,
                           int hapPair)
        Description copied from interface: GT
        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.
        Specified by:
        allele1 in interface GT
        Parameters:
        marker - the marker index
        hapPair - the sample index
        Returns:
        the first allele for the specified marker and sample
      • allele2

        public int allele2​(int marker,
                           int hapPair)
        Description copied from interface: GT
        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.
        Specified by:
        allele2 in interface GT
        Parameters:
        marker - the marker index
        hapPair - the sample index
        Returns:
        the allele for the specified marker and sample
      • allele

        public int allele​(int marker,
                          int haplotype)
        Description copied from interface: GT
        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.
        Specified by:
        allele in interface GT
        Parameters:
        marker - the marker index
        haplotype - the haplotype index
        Returns:
        the allele on the specified haplotype for the specified marker
      • restrict

        public static RefGT restrict​(RefGT refGT,
                                     int[] indices)
        Returns a RefGT instance restricted to genotype data for the specified markers.
        Parameters:
        refGT - the RefGT instance to be restricted
        indices - a list of distinct marker indices (from this.markers()) in increasing order
        Returns:
        a RefGT 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] >= gt.nMarkers())
        java.lang.IllegalArgumentException - if there exists j such that (1 <= j && j < indices.length) such that (indices[j] <= indice[j - 1])
        java.lang.NullPointerException - if gt == null || indices == null
      • restrict

        public RefGT restrict​(Markers markers,
                              int[] indices)
        Description copied from interface: GT
        Returns a GT instance restricted to genotype data for the specified markers.
        Specified by:
        restrict in interface GT
        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
      • restrict

        public RefGT restrict​(int start,
                              int end)
        Description copied from interface: GT
        Returns a new GT instance restricted to genotype data for the specified markers.
        Specified by:
        restrict in interface GT
        Parameters:
        start - the start marker (inclusive)
        end - the end marker (exclusive)
        Returns:
        a GT instance restricted to genotype data for the specified markers
      • get

        public RefGTRec get​(int marker)
        Returns the RefGTRec for the specified marker.
        Parameters:
        marker - the marker index
        Returns:
        the RefGTRec for the specified marker
        Throws:
        java.lang.IndexOutOfBoundsException - if marker < 0 || marker >= this.nMarkers()