Package vcf
Class IntArrayRefGTRec
java.lang.Object
vcf.IntArrayRefGTRec
Class IntArrayRefGT represents phased, non-missing
genotypes for a list of reference samples at a single marker.
Genotype emission probabilities are determined by the sample
genotypes.
Instances of class IntArrayRefGT are immutable.
-
Constructor Summary
ConstructorsConstructorDescriptionIntArrayRefGTRec(Marker marker, Samples samples, int[] alleles) Constructs a newIntArrayRefGTinstance from the specified phased genotype data.IntArrayRefGTRec(Marker marker, Samples samples, IndexArray alleles) Constructs a newIntArrayRefGTinstance from the specified phased genotype data. -
Method Summary
Modifier and TypeMethodDescriptionintalleleCount(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 isnullor is a list of the haplotypes in increasing order that carry allelej.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.Returns anIndexArraywiththis.size()elements that maps haplotype to allele.booleanReturnstrueif 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.intReturns 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.intReturns the sum of the lengths of non-null rows ofthis.alleleToHaps().intnMaps()Returnsthis.maps().lengthstatic intnonNullCnt(int[][] alleleToHaps) Returns the sum of the lengths of non-null rows of the specified two-dimensional array.samples()Returns the samples.intsize()Returns the number of haplotypes.toString()Returns the data represented bythisas a VCF record with a GT format field.
-
Constructor Details
-
IntArrayRefGTRec
Constructs a newIntArrayRefGTinstance from the specified phased genotype data.- Parameters:
marker- the markersamples- the list of samplesalleles- the list of phased alleles- Throws:
IllegalArgumentException- ifalleles.length != 2*samples.size()IllegalArgumentException- if(alleles[j] < 0 || alleles[j] >= marker.nAlleles())for anyjsatisfying0 <= j && j < allele1.lengthNullPointerException- ifmarker==null || samples==null || alleles==null
-
IntArrayRefGTRec
Constructs a newIntArrayRefGTinstance from the specified phased genotype data.- Parameters:
marker- the markersamples- the list of samplesalleles- the list of phased alleles- Throws:
IllegalArgumentException- ifalleles.size() != 2*samples.size()IllegalArgumentException- ifalleles.valueSize() >= marker.nAlleles()NullPointerException- ifmarker==null || samples==null || alleles==null
-
-
Method Details
-
isPhased
public boolean isPhased(int sample) Description copied from interface:RefGTRecReturnstrue. -
isPhased
public boolean isPhased()Returnstrue. -
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 major allele with lowest index.- Specified by:
majorAllelein interfaceRefGTRec- Returns:
- the major allele with lowest index
-
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
-
samples
Returns the samples. The returned samples are the filtered samples after all sample exclusions. -
size
public int size()Description copied from interface:GTRecReturns the number of haplotypes. -
marker
Description copied from interface:GTRecReturns the marker. -
alleleToHaps
public int[][] alleleToHaps()Description copied from interface:RefGTRecReturns an array of lengththis.marker().nAlleles()whosej-th element isnullor 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 thenullelement correspond to the major allele with lowest index, but this is not a requirement for implementations of this method.- Specified by:
alleleToHapsin interfaceRefGTRec- Returns:
- Returns an array of length
this..marker().nAlleles()whosej-th element isnullor is a list of the haplotypes in increasing order that carry allelej
-
hapToAllele
Description copied from interface:RefGTRecReturns anIndexArraywiththis.size()elements that maps haplotype to allele.- Specified by:
hapToAllelein interfaceRefGTRec- Returns:
- an
IndexArraywiththis.size()elements that maps haplotype to allele
-
nAlleleCodedHaps
public int nAlleleCodedHaps()Description copied from interface:RefGTRecReturns the sum of the lengths of non-null rows ofthis.alleleToHaps().- Specified by:
nAlleleCodedHapsin interfaceRefGTRec- Returns:
- the sum of the lengths of non-null rows of
this.alleleToHaps()
-
get
public int get(int hap) Description copied from interface:GTRecReturns 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. -
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
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. -
nMaps
public int nMaps()Description copied from interface:RefGTRecReturnsthis.maps().length -
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 -
map
Description copied from interface:RefGTRecReturnsthis.maps()[index]. -
nonNullCnt
public static int nonNullCnt(int[][] alleleToHaps) Returns the sum of the lengths of non-null rows of the specified two-dimensional array.- Parameters:
alleleToHaps- a two-dimensional array- Returns:
- the sum of the lengths of non-null rows
- Throws:
NullPointerException- ifalleleToHaps == null
-