Package vcf

Class VcfRecGTParser

java.lang.Object
vcf.VcfRecGTParser

public final class VcfRecGTParser extends 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 Details

    • VcfRecGTParser

      public VcfRecGTParser(VcfHeader vcfHeader, String vcfRec, MarkerParser markerParser)
      Constructs a new VcfRecGTParser object from the specified VCF record.
      Parameters:
      vcfHeader - the VCF meta-information lines and header line
      vcfRec - the VCF record
      markerParser - a filter for a VCF record's ID, QUAL, FILTER, and INFO subfields
      Throws:
      IllegalArgumentException - if vcfHeader.size() == 0
      IllegalArgumentException - if a format error is detected in the vcfRecord
      NullPointerException - if (vcfHeader == null) || (vcfRec == null) || (filter == null}
  • Method Details

    • 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 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:
      IllegalArgumentException - if a format error is detected in the VCF record
      IllegalArgumentException - if isMissing.size() != this.samples().size()
      IllegalArgumentException - if alleles.size() != 2*this.samples().size()*this.marker.bitsPerAllele()
      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:
      IllegalArgumentException - if a format error is detected in the VCF record
      IllegalArgumentException - if alleles.length != 2*this.samples().size()
      IllegalArgumentException - if isPhased.length != this.samples().size()
      NullPointerException - if any parameter is alleles == null || isPhased == null
    • hapListRep

      public VcfRecGTParser.HapListRep hapListRep()
    • 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:
      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.
      NullPointerException - if vcfRec == null || rec == null