Package vcf
Class VcfRecGTParser
- java.lang.Object
-
- vcf.VcfRecGTParser
-
public final class VcfRecGTParser extends java.lang.ObjectClass
VcfRecGTParserparses VCF records and extracts the GT format field.Instances of class
VcfRecGTParserare immutable.
-
-
Constructor Summary
Constructors Constructor Description VcfRecGTParser(VcfHeader vcfHeader, java.lang.String vcfRec)Constructs a newVcfRecGTParserobject from the specified VCF record.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Markermarker()Returns the marker.intnAlleles()Returnsthis.marker().nAlleles().int[][]nonMajRefIndices()Returns an array of lengththis.nAlleles()whosek-th element is the list of haplotype indices carrying thek-th allele ifkis a non-major allele, and whosek-th element isnullifkis the major allele.intnSamples()Returns the number of samples.Samplessamples()Returns the list of samples.voidstoreAlleles(long[] allele1, long[] allele2, long[] isMissing1, long[] isMissing2, long[] isPhased)Stores the genotypes genotypes in the specified long arrays.VcfHeadervcfHeader()Returns the VCF meta-information lines and header line for the backing VCF recordjava.lang.StringvcfRecord()Returns the backing VCF record.
-
-
-
Constructor Detail
-
VcfRecGTParser
public VcfRecGTParser(VcfHeader vcfHeader, java.lang.String vcfRec)
Constructs a newVcfRecGTParserobject from the specified VCF record.- Parameters:
vcfHeader- the VCF meta-information lines and header linevcfRec- the VCF record- Throws:
java.lang.IllegalArgumentException- ifvcfHeader.nSamples() == 0java.lang.IllegalArgumentException- if a format error is detected in thevcfRecordjava.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 in an array is set when the method is invoked, or if any array does not have sufficient length for storing the record data.- 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
-
nonMajRefIndices
public int[][] nonMajRefIndices()
Returns an array of lengththis.nAlleles()whosek-th element is the list of haplotype indices carrying thek-th allele ifkis a non-major allele, and whosek-th element isnullifkis 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
-
-