Package vcf
Interface RefGTRec
-
- All Superinterfaces:
DuplicatesGTRec
,GTRec
,IntArray
,MarkerContainer
- All Known Implementing Classes:
LowMafRefDiallelicGTRec
,LowMafRefGTRec
,SeqCodedRefGTRec
public interface RefGTRec extends GTRec
Interface
RefGTRec
represents represents phased genotype data for one marker. For implementations of this interface, unless otherwise specified in the implementation documentation, if theisAlleleCoded()
method returnsfalse
, themajorAllele()
,alleleCount()
, andhapIndex()
methods will be computationally expensive with compute time proportional to the number of haplotypes. Alternatively if theisAlleleCoded()
method returnstrue
, themaps()
andmap()
methods will be computationally expensive with compute time proportional to the number of haplotypes.All instances of
RefGTRec
are required to be immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static RefGTRec
alleleCodedInstance(RefGTRec rec)
Returns an allele-codedRefGTRec
instance for the specified data.static RefGTRec
alleleCodedInstance(VcfRecGTParser gtp)
Constructs and returns a new allele-codedRefGTRec
instance from the specified data.int
alleleCount(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.static RefGTRec
hapCodedInstance(Marker marker, Samples samples, int[][] hapIndices)
Constructs and returns a new allele-codedRefGTRec
instance from the specified data.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
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 alleles.int
nMaps()
Returnsthis.maps().length
-
Methods inherited from interface vcf.MarkerContainer
marker
-
-
-
-
Method Detail
-
alleleCodedInstance
static RefGTRec alleleCodedInstance(RefGTRec rec)
Returns an allele-codedRefGTRec
instance for the specified data.- Parameters:
rec
- the phased, non-missing genotype data- Returns:
- an allele-coded
RefGTRec
instance for the specified data - Throws:
java.lang.NullPointerException
- ifrec == null
-
alleleCodedInstance
static RefGTRec alleleCodedInstance(VcfRecGTParser gtp)
Constructs and returns a new allele-codedRefGTRec
instance from the specified data.- Parameters:
gtp
- a VCF record parser that extracts sample genotypes- Returns:
- an allele-coded
RefGTRec
instance - 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
-
hapCodedInstance
static RefGTRec hapCodedInstance(Marker marker, Samples samples, int[][] hapIndices)
Constructs and returns a new allele-codedRefGTRec
instance from the specified data.- Parameters:
marker
- the markersamples
- the sampleshapIndices
- an array whosej
-th element isnull
ifj
is the major allele and otherwise is a list of haplotypes sorted in increasing order that carry thej
-th allele. If there is more than one allele with a maximal allele count, the major allele is the smallest allele with maximal allele count. If a haplotype is contained in a list for more than one non-major allele, the haplotype will be assumed to carry the smallest allele.- Returns:
- an allele-coded
RefGTRec
instance - Throws:
java.lang.IllegalArgumentException
- if the(hapIndices[j] == null)
andj
is not the major allele or if(hapIndices[j] != null)
andj
is the major allelejava.lang.IllegalArgumentException
- if any non-null element ofhapIndices
is not a sorted list of distinct haplotype indices between 0 (inclusive) and2*samples.size()
(exclusive)java.lang.IllegalArgumentException
- ifmarker.nAlleles() != hapIndices.length
java.lang.NullPointerException
- ifmarker == null || samples == null || hapIndices == null
-
hapIndices
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 order- 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
boolean isPhased(int sample)
Returnstrue
.- Specified by:
isPhased
in interfaceDuplicatesGTRec
- Parameters:
sample
- the sample index- Returns:
true
- Throws:
java.lang.IndexOutOfBoundsException
- ifsample < 0 || sample >= this.nSamples()
-
isPhased
boolean isPhased()
Returnstrue
.- Specified by:
isPhased
in interfaceDuplicatesGTRec
- Returns:
true
-
isAlleleCoded
boolean isAlleleCoded()
Returnstrue
if this instance stores the indices of haplotypes that carry non-major alleles, and returnsfalse
otherwise.- Returns:
true
if this instance stores the indices of haplotypes that carry non-major alleles
-
majorAllele
int majorAllele()
Returns the index of the major allele.- Returns:
- the index of the major allele
-
alleleCounts
int[] alleleCounts()
Returns an array of lengththis.nAlleles()
whosej
-th element is the allele count of thej
-th allele.- Returns:
- an array of allele counts
-
alleleCount
int alleleCount(int allele)
Returns the number of haplotypes that carry the specified non-major allele.- Parameters:
allele
- an allele index- Returns:
- the number of haplotypes that carry the specified non-major allele
- Throws:
java.lang.IllegalArgumentException
- ifallele == this.majorAllele()
java.lang.IndexOutOfBoundsException
- ifallele < 0 || allele >= this.nAlleles()
-
hapIndex
int hapIndex(int allele, int copy)
Returns index of the haplotype that carries the specified copy of the specified allele.- Parameters:
allele
- an allele indexcopy
- a copy index- Returns:
- index of the haplotype that carries the specified allele
- Throws:
java.lang.IllegalArgumentException
- ifallele == this.majorAllele()
java.lang.IndexOutOfBoundsException
- ifallele < 0 || allele >= this.nAlleles()
java.lang.IndexOutOfBoundsException
- ifcopy < 0 || copy >= this.alleleCount(allele)
-
isCarrier
boolean isCarrier(int allele, int hap)
Returnstrue
if the specified haplotype carries the specified allele and returnfalse
otherwise.- Parameters:
allele
- an allele indexhap
- a haplotype index- Returns:
true
if the specified haplotype carries the specified allele- Throws:
java.lang.IndexOutOfBoundsException
- ifhap < 0 || hap >= this.size()
java.lang.IndexOutOfBoundsException
- ifallele < 0 || allele >= this.nAlleles()
-
nMaps
int nMaps()
Returnsthis.maps().length
- Returns:
- this.maps().length
-
maps
IntArray[] maps()
Returns an array of maps, which when composed map haplotype indices to alleles. The allele on 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
- Returns:
- an array of maps, which when composed map haplotype indices to alleles
-
map
IntArray map(int index)
Returnsthis.maps()[index]
.- Parameters:
index
- the index inthis.maps()
- Returns:
this.maps()[index]
- Throws:
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= this.nMaps()
-
-