Package vcf
Class VcfRecGTParser
java.lang.Object
vcf.VcfRecGTParser
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 -
Constructor Summary
ConstructorsConstructorDescriptionVcfRecGTParser
(VcfHeader vcfHeader, String vcfRec, MarkerParser markerParser) Constructs a newVcfRecGTParser
object from the specified VCF record. -
Method Summary
Modifier and TypeMethodDescriptionmarker()
Returns the marker.int
nAlleles()
Returnsthis.marker().nAlleles()
.int[][]
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()
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.Returns the VCF meta-information lines and header line for the backing VCF recordReturns the backing VCF record.
-
Constructor Details
-
VcfRecGTParser
Constructs a newVcfRecGTParser
object from the specified VCF record.- Parameters:
vcfHeader
- the VCF meta-information lines and header linevcfRec
- the VCF recordmarkerParser
- a filter for a VCF record's ID, QUAL, FILTER, and INFO subfields- Throws:
IllegalArgumentException
- ifvcfHeader.size() == 0
IllegalArgumentException
- if a format error is detected in thevcfRecord
NullPointerException
- if(vcfHeader == null) || (vcfRec == null) || (filter == null
}
-
-
Method Details
-
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
Returns the backing VCF record.- Returns:
- the backing VCF record
-
marker
Returns the marker.- Returns:
- the marker
-
nAlleles
public int nAlleles()Returnsthis.marker().nAlleles()
.- Returns:
- the number of alleles
-
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
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:
IllegalArgumentException
- if a format error is detected in the VCF recordIllegalArgumentException
- ifisMissing.size() != this.samples().size()
IllegalArgumentException
- ifalleles.size() != 2*this.samples().size()*this.marker.bitsPerAllele()
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:
IllegalArgumentException
- if a format error is detected in the VCF recordIllegalArgumentException
- ifalleles.length != 2*this.samples().size()
IllegalArgumentException
- ifisPhased.length != this.samples().size()
NullPointerException
- if any parameter isalleles == null || isPhased == null
-
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:
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
- ifvcfRec == null || rec == null
-