Package vcf
Class LowMafRefGT
- java.lang.Object
-
- vcf.LowMafRefGT
-
- All Implemented Interfaces:
IntArray
,DuplicatesGTRec
,GTRec
,MarkerContainer
,RefGTRec
public final class LowMafRefGT extends java.lang.Object implements RefGTRec
Class
LowMafRefGT
represent represents phased, non-missing genotypes for a list of reference samples at a single marker. Genotype emission probabilities are determined by the sample genotypes.Class
LowMafRefGT
stores the non-major allele indices.Instances of class
LowMemRefGT
are immutable.
-
-
Constructor Summary
Constructors Constructor Description LowMafRefGT(Marker marker, Samples samples, int[][] hapIndices)
Constructs a newLowMafRefGT
instance from the specified data.LowMafRefGT(RefGTRec rec)
Constructs a newLowMafRefGT
instance with phased non-missing genotypes from the specified data.LowMafRefGT(VcfRecGTParser gtp)
Constructs a newLowMafRefGT
instance with phased non-missing genotypes from the specifiedVcfRecGTParser
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
allele1(int sample)
Returns the first allele for the specified sample or -1 if the allele is missing.int
allele2(int sample)
Returns the second allele for the specified sample or -1 if the allele is missing.int
alleleCount(int allele)
Returns the number of haplotypes that carry the specified allele.int[]
alleles()
Returns an array of lengththis.size()
whosej
-th element is equal tothis.allele(j
}int
get(int hap)
Returns the specified allele for the specified haplotype or -1 if the allele is missing.float
gl(int sample, int allele1, int allele2)
Returns the probability of the observed data for the specified sample if the specified pair of ordered alleles is the true ordered genotype.int
hapIndex(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 isnull
ifj
is the major allele with lowest index, and otherwise is an array of indices of haplotypes that carry thej
-th allele sorted in increasing orderboolean
isAlleleCoded()
Returnstrue
if this instance stores the indices of haplotypes that carry non-major alleles, and returnsfalse
otherwise.boolean
isCarrier(int allele, int hap)
Returnstrue
if the specified haplotype carries the specified allele and returnfalse
otherwise.boolean
isGTData()
Returnstrue
if the value returned bythis.gl()
is determined by a called or missing genotype, and returnsfalse
otherwise.boolean
isPhased()
Returnstrue
.boolean
isPhased(int sample)
Returnstrue
.int
majorAllele()
Returns the index of the major allele.IntArray
map(int index)
Returnsthis.maps()[index]
.IntArray[]
maps()
Returns an array of maps, which when composed map haplotype indices to values.Marker
marker()
Returns the marker.int
nAlleles()
Returns the number of marker alleles.int
nMaps()
Returnsthis.maps().length
int
nSamples()
Returns the number of samples.Samples
samples()
Returns the list of samples.int
size()
Returns the number of haplotypes.java.lang.String
toString()
Returns the data represented bythis
as a VCF record with a GT format field.
-
-
-
Constructor Detail
-
LowMafRefGT
public LowMafRefGT(RefGTRec rec)
Constructs a newLowMafRefGT
instance with phased non-missing genotypes from the specified data.- Parameters:
rec
- the phased, non-missing genotype data- Throws:
java.lang.NullPointerException
- ifrec == null
-
LowMafRefGT
public LowMafRefGT(VcfRecGTParser gtp)
Constructs a newLowMafRefGT
instance with phased non-missing genotypes from the specifiedVcfRecGTParser
object.- 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
- if a format error is detected in the VCF recordjava.lang.NullPointerException
- ifgtp == null
-
LowMafRefGT
public LowMafRefGT(Marker marker, Samples samples, int[][] hapIndices)
Constructs a newLowMafRefGT
instance from the specified data. The contract for this class is unspecified if a haplotype index is duplicated in the specifiedhapIndices
array.- Parameters:
marker
- the markersamples
- the sampleshapIndices
- an array whosej
-th element isnull
ifj
is the major allele with lowest index, and otherwise is an array of indices of haplotypes that carry thej
-th allele sorted in increasing order- Throws:
java.lang.IllegalArgumentException
- if the(hapIndices[j] == null)
andj
is not the major allele with lowest index, or if(hapIndices[j] != null)
andj
is the major allele with lowest indexjava.lang.IllegalArgumentException
- if any element ofhapIndices
is not not a sorted array of distinct haplotype indices between 0 (inclusive) and2*samples.nSamples()
(exclusive)java.lang.IllegalArgumentException
- ifmarker.nAlleles() != hapIndices.length
java.lang.NullPointerException
- ifmarker == null || samples == null || hapIndices == null
-
-
Method Detail
-
hapIndices
public int[][] hapIndices()
Description copied from interface:RefGTRec
Returns an array whosej
-th element isnull
ifj
is 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:
hapIndices
in interfaceRefGTRec
- Returns:
- an array whose
j
-th element isnull
ifj
is 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:RefGTRec
Returnstrue
.- Specified by:
isPhased
in interfaceDuplicatesGTRec
- Specified by:
isPhased
in interfaceRefGTRec
- Parameters:
sample
- the sample index- Returns:
true
-
isPhased
public boolean isPhased()
Returnstrue
.- Specified by:
isPhased
in interfaceDuplicatesGTRec
- Specified by:
isPhased
in interfaceRefGTRec
- Returns:
true
-
samples
public Samples samples()
Description copied from interface:GTRec
Returns the list of samples.
-
nSamples
public int nSamples()
Description copied from interface:DuplicatesGTRec
Returns the number of samples. The returned value is equal tothis.size()/2
.- Specified by:
nSamples
in interfaceDuplicatesGTRec
- Returns:
- the number of samples
-
size
public int size()
Description copied from interface:DuplicatesGTRec
Returns the number of haplotypes. The returned value is equal to2*this.nSamples()
.- Specified by:
size
in interfaceDuplicatesGTRec
- Specified by:
size
in interfaceIntArray
- Returns:
- the number of haplotypes
-
marker
public Marker marker()
Description copied from interface:MarkerContainer
Returns the marker.- Specified by:
marker
in interfaceMarkerContainer
- Returns:
- the marker
-
isGTData
public boolean isGTData()
Description copied from interface:GTRec
Returnstrue
if the value returned bythis.gl()
is determined by a called or missing genotype, and returnsfalse
otherwise.
-
gl
public float gl(int sample, int allele1, int allele2)
Description copied from interface:GTRec
Returns the probability of the observed data for the specified sample if the specified pair of ordered alleles is the true ordered genotype.
-
allele1
public int allele1(int sample)
Description copied from interface:DuplicatesGTRec
Returns 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:
allele1
in interfaceDuplicatesGTRec
- Parameters:
sample
- a sample index- Returns:
- the first allele for the specified sample
-
allele2
public int allele2(int sample)
Description copied from interface:DuplicatesGTRec
Returns 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:
allele2
in interfaceDuplicatesGTRec
- Parameters:
sample
- a sample index- Returns:
- the second allele for the specified sample
-
get
public int get(int hap)
Description copied from interface:DuplicatesGTRec
Returns 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:
get
in interfaceDuplicatesGTRec
- Specified by:
get
in interfaceIntArray
- Parameters:
hap
- a haplotype index- Returns:
- the specified allele for the specified sample
-
alleles
public int[] alleles()
Description copied from interface:DuplicatesGTRec
Returns an array of lengththis.size()
whosej
-th element is equal tothis.allele(j
}- Specified by:
alleles
in interfaceDuplicatesGTRec
- Returns:
- an array of length
this.size()
whosej
-th element is equal tothis.allele(j
}
-
nAlleles
public int nAlleles()
Description copied from interface:MarkerContainer
Returns the number of marker alleles.- Specified by:
nAlleles
in interfaceMarkerContainer
- Returns:
- the number of marker alleles.
-
isAlleleCoded
public boolean isAlleleCoded()
Description copied from interface:RefGTRec
Returnstrue
if this instance stores the indices of haplotypes that carry non-major alleles, and returnsfalse
otherwise.- Specified by:
isAlleleCoded
in interfaceRefGTRec
- Returns:
true
if this instance stores the indices of haplotypes that carry non-major alleles
-
majorAllele
public int majorAllele()
Description copied from interface:RefGTRec
Returns the index of the major allele.- Specified by:
majorAllele
in interfaceRefGTRec
- Returns:
- the index of the major allele
-
alleleCount
public int alleleCount(int allele)
Description copied from interface:RefGTRec
Returns the number of haplotypes that carry the specified allele.- Specified by:
alleleCount
in interfaceRefGTRec
- Parameters:
allele
- an allele index- Returns:
- the number of haplotypes that carry the specified allele
-
hapIndex
public int hapIndex(int allele, int copy)
Description copied from interface:RefGTRec
Returns 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:RefGTRec
Returnstrue
if the specified haplotype carries the specified allele and returnfalse
otherwise.
-
toString
public java.lang.String toString()
Returns the data represented bythis
as 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:
toString
in classjava.lang.Object
- Returns:
- the data represented by
this
as a VCF record with a GT format field
-
nMaps
public int nMaps()
Description copied from interface:RefGTRec
Returnsthis.maps().length
-
maps
public IntArray[] maps()
Description copied from interface:RefGTRec
Returns an array of maps, which when composed map haplotype indices to values. The allele stored at haplotypeh
is 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
-
-