Package vcf

Class VcfRecGTParser


  • public final class VcfRecGTParser
    extends java.lang.Object

    Class VcfRecGTParser parses VCF records and extracts the GT format field.

    Instances of class VcfRecGTParser are immutable.

    • Constructor Summary

      Constructors 
      Constructor Description
      VcfRecGTParser​(VcfHeader vcfHeader, java.lang.String vcfRec)
      Constructs a new VcfRecGTParser object from the specified VCF record.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Marker marker()
      Returns the marker.
      int nAlleles()
      Returns this.marker().nAlleles().
      int[][] nonMajRefIndices()
      Returns an array of length this.nAlleles() whose k-th element is the list of haplotype indices carrying the k-th allele if k is a non-major allele, and whose k-th element is null if k is the major allele.
      int nSamples()
      Returns the number of samples.
      Samples samples()
      Returns the list of samples.
      void storeAlleles​(long[] allele1, long[] allele2, long[] isMissing1, long[] isMissing2, long[] isPhased)
      Stores the genotypes genotypes in the specified long arrays.
      VcfHeader vcfHeader()
      Returns the VCF meta-information lines and header line for the backing VCF record
      java.lang.String vcfRecord()
      Returns the backing VCF record.
      • Methods inherited from class java.lang.Object

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

      • VcfRecGTParser

        public VcfRecGTParser​(VcfHeader vcfHeader,
                              java.lang.String vcfRec)
        Constructs a new VcfRecGTParser object from the specified VCF record.
        Parameters:
        vcfHeader - the VCF meta-information lines and header line
        vcfRec - the VCF record
        Throws:
        java.lang.IllegalArgumentException - if vcfHeader.nSamples() == 0
        java.lang.IllegalArgumentException - if a format error is detected in the vcfRecord
        java.lang.NullPointerException - if vcfHeader == null || vcfRec == null
    • Method Detail

      • vcfHeader

        public VcfHeader vcfHeader()
        Returns the VCF meta-information lines and header line for the backing VCF record
        Returns:
        the VCF meta-information lines and header line
      • vcfRecord

        public java.lang.String vcfRecord()
        Returns the backing VCF record.
        Returns:
        the backing VCF record
      • marker

        public Marker marker()
        Returns the marker.
        Returns:
        the marker
      • nAlleles

        public int nAlleles()
        Returns this.marker().nAlleles().
        Returns:
        the number of alleles
      • samples

        public Samples samples()
        Returns the list of samples.
        Returns:
        the list of samples
      • nSamples

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

        public void storeAlleles​(long[] allele1,
                                 long[] allele2,
                                 long[] isMissing1,
                                 long[] isMissing2,
                                 long[] isPhased)
        Stores the genotypes genotypes in the specified long arrays. The contract for this method is undefined if any bit in an array is set when the method is invoked, or if any array does not have sufficient length for storing the record data.
        Parameters:
        allele1 - a long array in which the first allele for each sample is stored
        allele2 - a long array set in which the second allele for each sample is stored
        isMissing1 - a long array whose k-th bit will be set if the first allele of the k-th sample is missing
        isMissing2 - a long array set whose k-th bit will be set if the second allele of the k-th sample is missing
        isPhased - a along array whose k-th bit will be set if the phased allele separator is present in the k-th sample
        Throws:
        java.lang.IllegalArgumentException - if a format error is detected in the VCF record
        java.lang.NullPointerException - if any parameter is null
      • nonMajRefIndices

        public int[][] nonMajRefIndices()
        Returns an array of length this.nAlleles() whose k-th element is the list of haplotype indices carrying the k-th allele if k is a non-major allele, and whose k-th element is null if k is the major allele. If there is more than one allele with maximal count, the allele with maximal count having the smallest index is defined to be the major allele.
        Returns:
        the indices of the haplotypes carrying each non-major allele
        Throws:
        java.lang.IllegalArgumentException - if a format error is detected in the specified VCF record or if the specified VCF header is inconsistent with the specified VCF header.
        java.lang.NullPointerException - if vcfRec == null || rec == null