Package vcf
Class LowMafRefDiallelicGTRec
- java.lang.Object
-
- vcf.LowMafRefDiallelicGTRec
-
- All Implemented Interfaces:
IntArray,DuplicatesGTRec,GTRec,MarkerContainer,RefGTRec
public final class LowMafRefDiallelicGTRec extends java.lang.Object implements RefGTRec
Class
LowMafRefDiallelicGTRecrepresent represents phased, non-missing genotypes for a list of reference samples at a single diallelic marker.Class
LowMafRefDiallelicGTRecstores haplotypes that carry the minor allele.Instances of class
LowMemRefDiallelicGTRecare immutable.
-
-
Constructor Summary
Constructors Constructor Description LowMafRefDiallelicGTRec(Marker marker, Samples samples, int[][] hapIndices)Constructs a newLowMafRefDiallelicGTRecinstance from the specified data.LowMafRefDiallelicGTRec(RefGTRec rec)Constructs a newLowMafRefDiallelicGTRecinstance from the specified data.LowMafRefDiallelicGTRec(VcfRecGTParser gtp)Constructs a newLowMafRefDiallelicGTRecinstance from the specified data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intallele1(int sample)Returns the first allele for the specified sample or -1 if the allele is missing.intallele2(int sample)Returns the second allele for the specified sample or -1 if the allele is missing.intalleleCount(int allele)Returns the number of haplotypes that carry the specified non-major allele.int[]alleleCounts()Returns an array of lengththis.nAlleles()whosej-th element is the allele count of thej-th allele.int[]alleles()Returns an array of lengththis.size()whosej-th element is equal tothis.allele(j}intget(int hap)Returns the specified allele for the specified haplotype or -1 if the allele is missing.inthapIndex(int allele, int copy)Returns index of the haplotype that carries the specified copy of the specified allele.int[][]hapIndices()Returns an array whosej-th element isnullifjis the major allele with lowest index, and otherwise is an array of indices of haplotypes that carry thej-th allele sorted in increasing orderbooleanisAlleleCoded()Returnstrueif this instance stores the indices of haplotypes that carry non-major alleles, and returnsfalseotherwise.booleanisCarrier(int allele, int hap)Returnstrueif the specified haplotype carries the specified allele and returnfalseotherwise.booleanisPhased()Returnstrue.booleanisPhased(int sample)Returnstrue.intmajorAllele()Returns the index of the major allele.IntArraymap(int index)Returnsthis.maps()[index].IntArray[]maps()Returns an array of maps, which when composed map haplotype indices to alleles.Markermarker()Returns the marker.intnMaps()Returnsthis.maps().lengthSamplessamples()Returns the list of samples.intsize()Returns the number of haplotypes.java.lang.StringtoString()Returns the data represented bythisas a VCF record with a GT format field.
-
-
-
Constructor Detail
-
LowMafRefDiallelicGTRec
public LowMafRefDiallelicGTRec(RefGTRec rec)
Constructs a newLowMafRefDiallelicGTRecinstance from the specified data.- Parameters:
rec- the phased, non-missing genotype data- Throws:
java.lang.IllegalArgumentException- ifrec.marker().nAlleles() != 2java.lang.NullPointerException- ifrec == null
-
LowMafRefDiallelicGTRec
public LowMafRefDiallelicGTRec(VcfRecGTParser gtp)
Constructs a newLowMafRefDiallelicGTRecinstance from the specified data.- Parameters:
gtp- a VCF record parser that extracts sample genotypes- Throws:
java.lang.IllegalArgumentException- if the VCF record contains an unphased genotype or missing allelejava.lang.IllegalArgumentException- ifgtp.nAlleles() != 2java.lang.IllegalArgumentException- if a format error is detected in the VCF recordjava.lang.NullPointerException- ifgtp == null
-
LowMafRefDiallelicGTRec
public LowMafRefDiallelicGTRec(Marker marker, Samples samples, int[][] hapIndices)
Constructs a newLowMafRefDiallelicGTRecinstance from the specified data. The specifiedhapIndicesarray is required to have length 2 and contain exactly onenullelement. Thenullelement should be the major allele because this is most memory-efficient, but this requirement is not enforced.- Parameters:
marker- the markersamples- the sampleshapIndices- whosej-th element is a list of haplotypes sorted in increasing order that carry thej-th allele, or isnull- Throws:
java.lang.IllegalArgumentException- ifmarker.nAlleles() != 2java.lang.IllegalArgumentException- ifmarker.nAlleles() != hapIndices.lengthjava.lang.IllegalArgumentException- if the(hapIndicesdoes not contain exactly onenullelementjava.lang.IllegalArgumentException- if the non-null element ofhapIndicesis not a sorted list of distinct haplotype indices between 0 (inclusive) and2*samples.size()(exclusive)java.lang.NullPointerException- ifmarker == null || samples == null || hapIndices == null
-
-
Method Detail
-
hapIndices
public int[][] hapIndices()
Description copied from interface:RefGTRecReturns an array whosej-th element isnullifjis the major allele with lowest index, and otherwise is an array of indices of haplotypes that carry thej-th allele sorted in increasing order- Specified by:
hapIndicesin interfaceRefGTRec- Returns:
- an array whose
j-th element isnullifjis the major allele with lowest index, and otherwise is an array of indices of haplotypes that carry thej-th allele sorted in increasing order
-
isPhased
public boolean isPhased(int sample)
Description copied from interface:RefGTRecReturnstrue.- Specified by:
isPhasedin interfaceDuplicatesGTRec- Specified by:
isPhasedin interfaceRefGTRec- Parameters:
sample- the sample index- Returns:
true
-
isPhased
public boolean isPhased()
Returnstrue.- Specified by:
isPhasedin interfaceDuplicatesGTRec- Specified by:
isPhasedin interfaceRefGTRec- Returns:
true
-
samples
public Samples samples()
Description copied from interface:GTRecReturns the list of samples.
-
size
public int size()
Description copied from interface:DuplicatesGTRecReturns the number of haplotypes.- Specified by:
sizein interfaceDuplicatesGTRec- Specified by:
sizein interfaceIntArray- Returns:
- the number of haplotypes
-
marker
public Marker marker()
Description copied from interface:MarkerContainerReturns the marker.- Specified by:
markerin interfaceMarkerContainer- Returns:
- the marker
-
allele1
public int allele1(int sample)
Description copied from interface:DuplicatesGTRecReturns the first allele for the specified sample or -1 if the allele is missing. The two alleles for a sample are arbitrarily ordered ifthis.unphased(marker, sample) == false.- Specified by:
allele1in interfaceDuplicatesGTRec- Parameters:
sample- a sample index- Returns:
- the first allele for the specified sample
-
allele2
public int allele2(int sample)
Description copied from interface:DuplicatesGTRecReturns the second allele for the specified sample or -1 if the allele is missing. The two alleles for a sample are arbitrarily ordered ifthis.unphased(marker, sample) == false.- Specified by:
allele2in interfaceDuplicatesGTRec- Parameters:
sample- a sample index- Returns:
- the second allele for the specified sample
-
get
public int get(int hap)
Description copied from interface:DuplicatesGTRecReturns the specified allele for the specified haplotype or -1 if the allele is missing. The two alleles for a sample at a marker are arbitrarily ordered ifthis.unphased(marker, hap/2) == false.- Specified by:
getin interfaceDuplicatesGTRec- Specified by:
getin interfaceIntArray- Parameters:
hap- a haplotype index- Returns:
- the specified allele for the specified sample
-
alleles
public int[] alleles()
Description copied from interface:DuplicatesGTRecReturns an array of lengththis.size()whosej-th element is equal tothis.allele(j}- Specified by:
allelesin interfaceDuplicatesGTRec- Returns:
- an array of length
this.size()whosej-th element is equal tothis.allele(j}
-
isAlleleCoded
public boolean isAlleleCoded()
Description copied from interface:RefGTRecReturnstrueif this instance stores the indices of haplotypes that carry non-major alleles, and returnsfalseotherwise.- Specified by:
isAlleleCodedin interfaceRefGTRec- Returns:
trueif this instance stores the indices of haplotypes that carry non-major alleles
-
majorAllele
public int majorAllele()
Description copied from interface:RefGTRecReturns the index of the major allele.- Specified by:
majorAllelein interfaceRefGTRec- Returns:
- the index of the major allele
-
alleleCounts
public int[] alleleCounts()
Description copied from interface:RefGTRecReturns an array of lengththis.nAlleles()whosej-th element is the allele count of thej-th allele.- Specified by:
alleleCountsin interfaceRefGTRec- Returns:
- an array of allele counts
-
alleleCount
public int alleleCount(int allele)
Description copied from interface:RefGTRecReturns the number of haplotypes that carry the specified non-major allele.- Specified by:
alleleCountin interfaceRefGTRec- Parameters:
allele- an allele index- Returns:
- the number of haplotypes that carry the specified non-major allele
-
hapIndex
public int hapIndex(int allele, int copy)Description copied from interface:RefGTRecReturns index of the haplotype that carries the specified copy of the specified allele.
-
isCarrier
public boolean isCarrier(int allele, int hap)Description copied from interface:RefGTRecReturnstrueif the specified haplotype carries the specified allele and returnfalseotherwise.
-
toString
public java.lang.String toString()
Returns the data represented bythisas a VCF record with a GT format field. The returned VCF record will have missing QUAL and INFO fields, will have "PASS" in the filter field, and will have a GT format field.- Overrides:
toStringin classjava.lang.Object- Returns:
- the data represented by
thisas a VCF record with a GT format field
-
nMaps
public int nMaps()
Description copied from interface:RefGTRecReturnsthis.maps().length
-
maps
public IntArray[] maps()
Description copied from interface:RefGTRecReturns an array of maps, which when composed map haplotype indices to alleles. The allele on haplotypehis determined by the following calculation:IntArray[] maps = this.maps(); int value = maps[0].get(h); for (int j=1; j<maps.length; ++j) { value = indexArrays[j].get(value); } int allele = value
-
-