Package vcf

Class VcfRecGTParser


  • public final class VcfRecGTParser
    extends java.lang.Object

    Class VcfRecGTParser parses VCF records and extracts the GT format field. If one allele in a diploid genotype is missing, then both alleles are set to missing.

    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
      VcfRecGTParser.HapListRep hapListRep()  
      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.
      boolean storeAlleles​(int[] alleles, boolean[] isPhased)
      Stores the genotypes and per-genotype phase data in the specified arrays and returns true if all genotypes are phased and non-missing.
      boolean storeAlleles​(BitArray alleles, BitArray isMissing)
      Stores the genotypes genotypes in the specified BitLists.
      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.size() == 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 boolean storeAlleles​(BitArray alleles,
                                    BitArray isMissing)
        Stores the genotypes genotypes in the specified BitLists. The contract for this method is unspecified if any bit of the specified alleles and isMissing parameters is set when this method is invoked.
        Parameters:
        alleles - a BitArray in which the allele for each haplotype is stored
        isMissing - a BitArray whose k-th bit will be set if any allele of the k-th sample is missing
        Returns:
        true if all genotypes are phased and non-missing
        Throws:
        java.lang.IllegalArgumentException - if a format error is detected in the VCF record
        java.lang.IllegalArgumentException - if isMissing.size() != this.samples().size()
        java.lang.IllegalArgumentException - if alleles.size() != 2*this.samples().size()*this.marker.bitsPerAllele()
        java.lang.NullPointerException - if alleles == null || isMissing == null
      • storeAlleles

        public boolean storeAlleles​(int[] alleles,
                                    boolean[] isPhased)
        Stores the genotypes and per-genotype phase data in the specified arrays and returns true if all genotypes are phased and non-missing.
        Parameters:
        alleles - an array in which alleles will be stored
        isPhased - a boolean array whose k-th element is true if the genotype of the k-th sample is haploid uses the phased allele separator
        Returns:
        true if all genotypes are phased and non-missing
        Throws:
        java.lang.IllegalArgumentException - if a format error is detected in the VCF record
        java.lang.IllegalArgumentException - if alleles.length != 2*this.samples().size()
        java.lang.IllegalArgumentException - if isPhased.length != this.samples().size()
        java.lang.NullPointerException - if any parameter is alleles == null || isPhased == 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