DuplicatesGTRec
, GTRec
, IntArray
, MarkerContainer
LowMafRefDiallelicGT
, LowMafRefGT
, SeqCodedRefGT
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 the isAlleleCoded()
method returns false
, the majorAllele()
,
alleleCount()
, and hapIndex()
methods will be computationally
expensive with compute time proportional to the number of haplotypes.
Alternatively if the isAlleleCoded()
method returns
true
, the maps()
and map()
methods will be
computationally expensive with compute time proportional to the number
of haplotypes.
All instances of RefGTRec
are required to be immutable.
Modifier and Type | Method | Description |
---|---|---|
static RefGTRec |
alleleCodedInstance(Marker marker,
Samples samples,
int[][] hapIndices) |
Constructs and returns a new allele-coded
RefGTRec instance
from the specified data. |
static RefGTRec |
alleleCodedInstance(RefGTRec rec) |
Returns an allele-coded
RefGTRec instance for the
specified data. |
static RefGTRec |
alleleCodedInstance(VcfRecGTParser gtp) |
Constructs and returns a new allele-coded
RefGTRec instance
from the specified data. |
int |
alleleCount(int allele) |
Returns the number of haplotypes that carry the specified allele.
|
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 whose
j -th element is null
if j is the major allele with lowest index, and otherwise is
an array of indices of haplotypes that carry the j -th allele
sorted in increasing order |
boolean |
isAlleleCoded() |
Returns
true if this instance stores the indices of haplotypes
that carry non-major alleles, and returns false otherwise. |
boolean |
isCarrier(int allele,
int hap) |
Returns
true if the specified haplotype carries the specified
allele and return false otherwise. |
boolean |
isPhased() |
Returns
true . |
boolean |
isPhased(int sample) |
Returns
true . |
int |
majorAllele() |
Returns the index of the major allele.
|
IntArray |
map(int index) |
Returns
this.maps()[index] . |
IntArray[] |
maps() |
Returns an array of maps, which when composed map haplotype indices
to values.
|
int |
nMaps() |
Returns
this.maps().length |
marker, nAlleles
static RefGTRec alleleCodedInstance(RefGTRec rec)
RefGTRec
instance for the
specified data.rec
- the phased, non-missing genotype dataRefGTRec
instance for the
specified datajava.lang.NullPointerException
- if rec == null
static RefGTRec alleleCodedInstance(VcfRecGTParser gtp)
RefGTRec
instance
from the specified data.gtp
- a VCF record parser that extracts sample genotypesRefGTRec
instancejava.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
- if gtp == null
static RefGTRec alleleCodedInstance(Marker marker, Samples samples, int[][] hapIndices)
RefGTRec
instance
from the specified data. The contract for this class is unspecified
if a haplotype index is duplicated in the specified hapIndices
array.marker
- the markersamples
- the sampleshapIndices
- an array whose j
-th element is null
if j
is the major allele with lowest index, and otherwise is
an array of indices of haplotypes that carry the j
-th allele
sorted in increasing orderRefGTRec
instancejava.lang.IllegalArgumentException
- if the (hapIndices[j] == null)
and j
is not the major allele with lowest index, or if
(hapIndices[j] != null)
and j
is the major allele with
lowest indexjava.lang.IllegalArgumentException
- if any element of hapIndices
is not not a sorted array of distinct haplotype indices
between 0 (inclusive) and 2*samples.nSamples()
(exclusive)java.lang.IllegalArgumentException
- if
marker.nAlleles() != hapIndices.length
java.lang.NullPointerException
- if
marker == null || samples == null || hapIndices == null
int[][] hapIndices()
j
-th element is null
if j
is the major allele with lowest index, and otherwise is
an array of indices of haplotypes that carry the j
-th allele
sorted in increasing orderj
-th element is null
if j
is the major allele with lowest index, and otherwise is
an array of indices of haplotypes that carry the j
-th allele
sorted in increasing orderboolean isPhased(int sample)
true
.isPhased
in interface DuplicatesGTRec
sample
- the sample indextrue
java.lang.IndexOutOfBoundsException
- if
sample < 0 || sample >= this.nSamples()
boolean isPhased()
true
.isPhased
in interface DuplicatesGTRec
true
boolean isAlleleCoded()
true
if this instance stores the indices of haplotypes
that carry non-major alleles, and returns false
otherwise.true
if this instance stores the indices of haplotypes
that carry non-major allelesint majorAllele()
int alleleCount(int allele)
allele
- an allele indexjava.lang.IllegalArgumentException
- if
allele == this.majorAllele()
java.lang.IndexOutOfBoundsException
- if
allele < 0 || allele >= this.nAlleles()
int hapIndex(int allele, int copy)
allele
- an allele indexcopy
- a copy indexjava.lang.IllegalArgumentException
- if
allele == this.majorAllele()
java.lang.IndexOutOfBoundsException
- if
allele < 0 || allele >= this.nAlleles()
java.lang.IndexOutOfBoundsException
- if
copy < 0 || copy >= this.alleleCount(allele)
boolean isCarrier(int allele, int hap)
true
if the specified haplotype carries the specified
allele and return false
otherwise.allele
- an allele indexhap
- a haplotype indextrue
if the specified haplotype carries the specified
allelejava.lang.IndexOutOfBoundsException
- if
hap < 0 || hap >= this.size()
java.lang.IndexOutOfBoundsException
- if
allele < 0 || allele >= this.nAlleles()
int nMaps()
this.maps().length
IntArray[] maps()
h
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
IntArray map(int index)
this.maps()[index]
.index
- the index in this.maps()
this.maps()[index]
java.lang.IndexOutOfBoundsException
- if
index < 0 || index >= this.nMaps()