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. If one allele in a diploid genotype is missing, then both alleles are set to missing.Instances of class
VcfRecGTParserare immutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVcfRecGTParser.HapListRep
-
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 VcfRecGTParser.HapListRephapListRep()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.booleanstoreAlleles(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.booleanstoreAlleles(BitArray alleles, BitArray isMissing)Stores the genotypes genotypes in the specified BitLists.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.size() == 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 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 specifiedallelesandisMissingparameters 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:
trueif 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 istrueif the genotype of thek-th sample is haploid uses the phased allele separator- Returns:
trueif 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 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
-
-