Package vcf
Class AlleleRefGTRec
java.lang.Object
vcf.AlleleRefGTRec
Class AlleleRefGTRec
represent represents phased, non-missing
genotypes for a list of reference samples at a single marker.
Class AlleleRefGTRec
stores the haplotypes that carry each
non-major allele.
Instances of class AlleleRefGTRec
are immutable.
-
Constructor Summary
ConstructorsConstructorDescriptionAlleleRefGTRec
(Marker marker, Samples samples, int[][] hapIndices) Constructs a newAlleleRefGTRec
instance from the specified data.AlleleRefGTRec
(RefGTRec rec) Constructs a newAlleleRefGTRec
instance from the specified data.Constructs a newAlleleRefGTRc
instance from the specified data. -
Method Summary
Modifier and TypeMethodDescriptionint
alleleCount
(int allele) Returns the number of haplotypes that carry the specified non-major allele.int[]
Returns an array of lengththis.nAlleles()
whosej
-th element is the allele count of thej
-th allele.int[][]
Returns an array of lengththis.marker().nAlleles()
whosej
-th element isnull
or is a list of the haplotypes in increasing order that carry allelej
.int
get
(int hap) Returns the specified allele for the specified haplotype or -1 if the allele is missing.int
hapIndex
(int allele, int copy) Returns index of the haplotype that carries the specified copy of the specified allele.Returns anIndexArray
withthis.size()
elements that maps haplotype to allele.boolean
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
Returns the major allele with lowest index.map
(int index) Returnsthis.maps()[index]
.IntArray[]
maps()
Returns an array of maps, which when composed map haplotype indices to alleles.marker()
Returns the marker.int
Returns the sum of the lengths of non-null rows ofthis.alleleToHaps()
.int
nMaps()
Returnsthis.maps().length
samples()
Returns the list of samples.int
size()
Returns the number of haplotypes.toString()
Returns the data represented bythis
as a VCF record with a GT format field.
-
Constructor Details
-
AlleleRefGTRec
Constructs a newAlleleRefGTRec
instance from the specified data.- Parameters:
rec
- the phased, non-missing genotype data- Throws:
NullPointerException
- ifrec == null
-
AlleleRefGTRec
Constructs a newAlleleRefGTRc
instance from the specified data.- Parameters:
gtp
- a VCF record parser that extracts sample genotypes- Throws:
IllegalArgumentException
- if the VCF record contains an unphased genotype or missing alleleIllegalArgumentException
- if a format error is detected in the VCF recordNullPointerException
- ifgtp == null
-
AlleleRefGTRec
Constructs a newAlleleRefGTRec
instance from the specified data. The specifiedhapIndices
array is required to contain exactly onenull
element. Thenull
element should be the major allele because this is most memory-efficient, but this requirement is not enforced. A haplotype index should be an element of only one array inhapIndices
. If a haplotype index is an element of more than one array inhapIndices
, it is assigned to the array with smallest index.- 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:
IllegalArgumentException
- if the(hapIndices
does not contain exactly onenull
elementIllegalArgumentException
- if any non-null element ofhapIndices
is not a sorted list of distinct haplotype indices between 0 (inclusive) and2*samples.size()
(exclusive)IllegalArgumentException
- ifmarker.nAlleles() != hapIndices.length
NullPointerException
- ifmarker == null || samples == null || hapIndices == null
-
-
Method Details
-
alleleToHaps
public int[][] alleleToHaps()Description copied from interface:RefGTRec
Returns an array of lengththis.marker().nAlleles()
whosej
-th element isnull
or is a list of the haplotypes in increasing order that carry allelej
. Exactly one element of the returned array must benull
. It is recommended that thenull
element correspond to the major allele with lowest index, but this is not a requirement for implementations of this method.- Specified by:
alleleToHaps
in interfaceRefGTRec
- Returns:
- Returns an array of length
this..marker().nAlleles()
whosej
-th element isnull
or is a list of the haplotypes in increasing order that carry allelej
-
hapToAllele
Description copied from interface:RefGTRec
Returns anIndexArray
withthis.size()
elements that maps haplotype to allele.- Specified by:
hapToAllele
in interfaceRefGTRec
- Returns:
- an
IndexArray
withthis.size()
elements that maps haplotype to allele
-
nAlleleCodedHaps
public int nAlleleCodedHaps()Description copied from interface:RefGTRec
Returns the sum of the lengths of non-null rows ofthis.alleleToHaps()
.- Specified by:
nAlleleCodedHaps
in interfaceRefGTRec
- Returns:
- the sum of the lengths of non-null rows of
this.alleleToHaps()
-
isPhased
public boolean isPhased(int sample) Description copied from interface:RefGTRec
Returnstrue
. -
isPhased
public boolean isPhased()Returnstrue
. -
samples
Description copied from interface:GTRec
Returns the list of samples. -
size
public int size()Description copied from interface:GTRec
Returns the number of haplotypes. -
marker
Description copied from interface:GTRec
Returns the marker. -
get
public int get(int hap) Description copied from interface:GTRec
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
. -
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 major allele with lowest index.- Specified by:
majorAllele
in interfaceRefGTRec
- Returns:
- the major allele with lowest index
-
alleleCounts
public int[] alleleCounts()Description copied from interface:RefGTRec
Returns an array of lengththis.nAlleles()
whosej
-th element is the allele count of thej
-th allele.- Specified by:
alleleCounts
in interfaceRefGTRec
- Returns:
- an array of allele counts
-
alleleCount
public int alleleCount(int allele) Description copied from interface:RefGTRec
Returns the number of haplotypes that carry the specified non-major allele.- Specified by:
alleleCount
in 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: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
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. -
nMaps
public int nMaps()Description copied from interface:RefGTRec
Returnsthis.maps().length
-
maps
Description copied from interface:RefGTRec
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
-
map
Description copied from interface:RefGTRec
Returnsthis.maps()[index]
.
-