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.Instances of class
VcfRecGTParser
are immutable.
-
-
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 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.int[]
phasedAlleles()
Returns the list of phased alleles in the backing VCF record.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 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.nSamples() == 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 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 is set in an array is set when the method is invoked, or if any array is not sufficiently long.- Parameters:
allele1
- a long array in which the first allele for each sample is storedallele2
- a long array set in which the second allele for each sample is storedisMissing1
- a long array whosek
-th bit will be set if the first allele of thek
-th sample is missingisMissing2
- a long array set whosek
-th bit will be set if the second allele of thek
-th sample is missingisPhased
- a along array whosek
-th bit will be set if the phased allele separator is present in thek
-th sample- Throws:
java.lang.IllegalArgumentException
- if a format error is detected in the VCF recordjava.lang.NullPointerException
- if any parameter isnull
-
phasedAlleles
public int[] phasedAlleles()
Returns the list of phased alleles in the backing VCF record.- Returns:
- the list of phased alleles in the backing VCF record
- Throws:
java.lang.IllegalArgumentException
- if the VCF record contains an unphased or missing genotypejava.lang.IllegalArgumentException
- if a format error is detected in the VCF record
-
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
-
-