Package vcf
Class Markers
java.lang.Object
vcf.Markers
Class Markers represent a list of markers in chromosome order.
Instances of class Markers are immutable.
-
Method Summary
Modifier and TypeMethodDescriptionintReturns the specified allelevoidallelesToBits(int[] alleles, BitArray bitList) Stores the specified alleles in the specifiedbitListint[]bitsToAlleles(BitArray hapBits) Returns the specified allele stored in the specifiedhapBitsarray.booleanReturnstrueif the specified marker is notnulland is an element in the list of markers represented bythis, and returnsfalseotherwise.static MarkersReturns a newMarkersinstance that is constructed from the specified data.int[]Return an array of lengththis.size() + 1whosek-th value is the the sum of the number of possible genotypes for markers with index less thankbooleanReturnstrueif the specified object is aMarkersinstance which represents the same list of markers asthis, and returnsfalseotherwise.inthashCode()Returns a hash code value for the object.marker(int marker) Returns the specified marker.Marker[]markers()Returns the list of markers.restrict(int[] indices) Returns aMarkersinstance that represents the specified markers.restrict(int start, int end) Returns aMarkersinstance that represents the specified range of marker indices.voidStores the specified alleles in the specifiedbitListintsize()Returns the number of markers.intReturnsthis.sumAlleles(this.nMarkers()).intsumAlleles(int marker) Returns the sum of the number of alleles for the markers with index less than the specified index.intReturnsthis.sumHaplotypeBits(this.nMarkers()).intsumHapBits(int marker) Returns the number of bits requires to store a haplotype for the markers with index less than the specified index.toString()Returns a string representation ofthis.
-
Method Details
-
create
Returns a newMarkersinstance that is constructed from the specified data.- Parameters:
markers- a list of markers in chromosome order- Returns:
- a new
Markersinstance corresponding to the specified list of markers - Throws:
IllegalArgumentException- if markers on a chromosome are not in chromosome orderIllegalArgumentException- if there are duplicate markersIllegalArgumentException- if the markers on a chromosome do not form a contiguous set of entries within the arrayNullPointerException- ifmarkers == nullor ifmarkers[j] == nullfor anyjsatisfying(0 <= j && j < markers.length)
-
cumSumGenotypes
public int[] cumSumGenotypes()Return an array of lengththis.size() + 1whosek-th value is the the sum of the number of possible genotypes for markers with index less thank- Returns:
- an array whose
k-th value is the the sum of the number of possible genotypes for markers with index less thank
-
hashCode
public int hashCode()Returns a hash code value for the object. The returned hash code equalsArrays.deepHashCode(this.markers()). -
equals
Returnstrueif the specified object is aMarkersinstance which represents the same list of markers asthis, and returnsfalseotherwise. Two lists of markers are the same if the lists have the same size and if markers with the same index in the two lists are equal. -
size
public int size()Returns the number of markers.- Returns:
- the number of markers
-
marker
Returns the specified marker.- Parameters:
marker- a marker index- Returns:
- the specified marker
- Throws:
IndexOutOfBoundsException- ifmarker < 0 || marker >= this.nMarkers()
-
markers
Returns the list of markers.- Returns:
- the list of markers
-
contains
Returnstrueif the specified marker is notnulland is an element in the list of markers represented bythis, and returnsfalseotherwise.- Parameters:
marker- a marker- Returns:
trueif the specified marker is notnulland is an element in the list of markers represented bythis
-
restrict
Returns aMarkersinstance that represents the specified range of marker indices.- Parameters:
start- the starting marker index (inclusive)end- the ending marker index (exclusive)- Returns:
- a
Markersinstance that represents the specified range of marker indices - Throws:
IndexOutOfBoundsException- ifstart < 0 || end > this.nMarkers()IllegalArgumentException- ifstart >= end
-
restrict
Returns aMarkersinstance that represents the specified markers.- Parameters:
indices- a list of distinct marker indices in increasing order- Returns:
- a new
Markersinstance that represents the specified markers - Throws:
IndexOutOfBoundsException- if there existsjsuch that(0 <= j && j < indices.length)such that(indices[j] < 0 || indices[j] >= this.nMarkers())IllegalArgumentException- if there existsjsuch that(1 <= j && j < indices.length)such that(indices[j] <= indice[j - 1])NullPointerException- ifindices == null
-
sumAlleles
public int sumAlleles(int marker) Returns the sum of the number of alleles for the markers with index less than the specified index.- Parameters:
marker- a marker index- Returns:
- the sum of the number of alleles for the markers with index less than the specified index
- Throws:
IndexOutOfBoundsException- ifmarker < 0 || marker > this.nMarkers()
-
sumAlleles
public int sumAlleles()Returnsthis.sumAlleles(this.nMarkers()).- Returns:
this.sumAlleles(this.nMarkers())
-
sumHapBits
public int sumHapBits(int marker) Returns the number of bits requires to store a haplotype for the markers with index less than the specified index.- Parameters:
marker- a marker index- Returns:
- the number of bits requires to store a haplotype for the markers with index less than the specified index
- Throws:
IndexOutOfBoundsException- ifmarker < 0 || marker > this.nMarkers()
-
sumHapBits
public int sumHapBits()Returnsthis.sumHaplotypeBits(this.nMarkers()).- Returns:
this.sumHaplotypeBits(this.nMarkers())
-
bitsToAlleles
Returns the specified allele stored in the specifiedhapBitsarray. The contract for this method is undefined if the specifiedhapBitsarray was not created with thethis.allelesToBits()method.- Parameters:
hapBits- the bit array storing the haplotype alleles- Returns:
- the specified allele stored in the specified
hapBitsarray. - Throws:
NullPointerException- ifhapBits == null
-
allelesToBits
Stores the specified alleles in the specifiedbitList- Parameters:
alleles- a sequence of allelesbitList- a sequence of bits- Throws:
IllegalArgumentException- ifalleles.length != this.nMarkers()IllegalArgumentException- ifbitList.size() != this.sumHaplotypeBits()IllegalArgumentException- if there exists aksuch that(0 < k && k < alleles.length)and(alleles[k] < 0 || alleles[k] >= this.marker(k).nAlleles())NullPointerException- ifalleles == null || bitList == null
-
setAllele
Stores the specified alleles in the specifiedbitList- Parameters:
marker- a marker indexallele- an allele indexbitList- a sequence of bits- Throws:
IllegalArgumentException- ifalleles.length != this.nMarkers()IllegalArgumentException- ifbitList.size() != this.sumHaplotypeBits()IndexOutOfBoundsException- ifmarker < 0 || marker >= this.nMarkers()IndexOutOfBoundsException- ifallele < 0 || allele >= this.marker(marker).nAlleles()NullPointerException- ifbitList == null
-
allele
Returns the specified allele- Parameters:
hapBits- a haplotype encoded as bits with thethis.allelesToBits() methodmarker- a marker index- Returns:
- the specified allele
- Throws:
IndexOutOfBoundsException- ifmarker < 0 || marker >= this.nMarkers()IndexOutOfBoundsException- ifhapBits.size() < this.sumHaplotypeBits(marker + 1)NullPointerException- ifhapBits == null
-
toString
Returns a string representation ofthis. The exact details of the representation are unspecified and subject to change.
-