Package vcf
Class VcfRecGTParser
- java.lang.Object
-
- vcf.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
VcfRecGTParser.HapListRep
-
Constructor Summary
Constructors Constructor Description VcfRecGTParser(VcfHeader vcfHeader, java.lang.String vcfRec)
Constructs a newVcfRecGTParser
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()
Returnsthis.marker().nAlleles()
.int[][]
nonMajRefIndices()
Returns an array of lengththis.nAlleles()
whosek
-th element is the list of haplotype indices carrying thek
-th allele ifk
is a non-major allele, and whosek
-th element isnull
ifk
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 recordjava.lang.String
vcfRecord()
Returns the backing VCF record.
-
-
-
Constructor Detail
-
VcfRecGTParser
public VcfRecGTParser(VcfHeader vcfHeader, java.lang.String vcfRec)
Constructs a newVcfRecGTParser
object from the specified VCF record.- Parameters:
vcfHeader
- the VCF meta-information lines and header linevcfRec
- the VCF record- Throws:
java.lang.IllegalArgumentException
- ifvcfHeader.size() == 0
java.lang.IllegalArgumentException
- if a format error is detected in thevcfRecord
java.lang.NullPointerException
- ifvcfHeader == 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()
Returnsthis.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 specifiedalleles
andisMissing
parameters is set when this method is invoked.- Parameters:
alleles
- a BitArray in which the allele for each haplotype is storedisMissing
- a BitArray whosek
-th bit will be set if any allele of thek
-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 recordjava.lang.IllegalArgumentException
- ifisMissing.size() != this.samples().size()
java.lang.IllegalArgumentException
- ifalleles.size() != 2*this.samples().size()*this.marker.bitsPerAllele()
java.lang.NullPointerException
- ifalleles == 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 storedisPhased
- a boolean array whosek
-th element istrue
if the genotype of thek
-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 recordjava.lang.IllegalArgumentException
- ifalleles.length != 2*this.samples().size()
java.lang.IllegalArgumentException
- ifisPhased.length != this.samples().size()
java.lang.NullPointerException
- if any parameter isalleles == null || isPhased == null
-
hapListRep
public VcfRecGTParser.HapListRep hapListRep()
-
nonMajRefIndices
public int[][] nonMajRefIndices()
Returns an array of lengththis.nAlleles()
whosek
-th element is the list of haplotype indices carrying thek
-th allele ifk
is a non-major allele, and whosek
-th element isnull
ifk
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
- ifvcfRec == null || rec == null
-
-