Package vcf
Class Markers
- java.lang.Object
-
- vcf.Markers
-
public final class Markers extends java.lang.ObjectClass
Markersrepresent a list of markers in chromosome order.Instances of class
Markersare immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intallele(BitArray hapBits, int marker)Returns 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.booleancontains(Marker marker)Returnstrueif the specified marker is notnulland is an element in the list of markers represented bythis, and returnsfalseotherwise.static Markerscreate(Marker[] markers)Returns a newMarkersinstance that is constructed from the specified data.booleanequals(java.lang.Object obj)Returnstrueif the specified object is aMarkersinstance which represents the same list of markers asthis, and returnsfalseotherwise.inthashCode()Returns a hash code value for the object.Markermarker(int marker)Returns the specified marker.Marker[]markers()Returns the list of markers.Markersrestrict(int[] indices)Returns aMarkersinstance that represents the specified markers.Markersrestrict(int start, int end)Returns aMarkersinstance that represents the specified range of marker indices.voidsetAllele(int marker, int allele, BitArray bitList)Stores the specified alleles in the specifiedbitListintsize()Returns the number of markers.intsumAlleles()Returnsthis.sumAlleles(this.nMarkers()).intsumAlleles(int marker)Returns the sum of the number of alleles for the markers with index less than the specified index.intsumGenotypes()Returnsthis.sumGenotypes(this.nMarkers()).intsumGenotypes(int marker)Returns the sum of the number of possible genotypes for the markers with index less than the specified index.intsumHapBits()Returnsthis.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.java.lang.StringtoString()Returns a string representation ofthis.
-
-
-
Method Detail
-
create
public static Markers create(Marker[] markers)
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:
java.lang.IllegalArgumentException- if markers on a chromosome are not in chromosome orderjava.lang.IllegalArgumentException- if there are duplicate markersjava.lang.IllegalArgumentException- if the markers on a chromosome do not form a contiguous set of entries within the arrayjava.lang.NullPointerException- ifmarkers == nullor ifmarkers[j] == nullfor anyjsatisfying(0 <= j && j < markers.length)
-
hashCode
public int hashCode()
Returns a hash code value for the object. The returned hash code equalsArrays.deepHashCode(this.markers()).- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hash code value for the object
-
equals
public boolean equals(java.lang.Object obj)
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.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to be tested for equality withthis- Returns:
trueif the specified object is aMarkersinstance which represents the same list of markers asthis
-
size
public int size()
Returns the number of markers.- Returns:
- the number of markers
-
marker
public Marker marker(int marker)
Returns the specified marker.- Parameters:
marker- a marker index- Returns:
- the specified marker
- Throws:
java.lang.IndexOutOfBoundsException- ifmarker < 0 || marker >= this.nMarkers()
-
markers
public Marker[] markers()
Returns the list of markers.- Returns:
- the list of markers
-
contains
public boolean contains(Marker marker)
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
public Markers restrict(int start, int end)
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:
java.lang.IndexOutOfBoundsException- ifstart < 0 || end > this.nMarkers()java.lang.IllegalArgumentException- ifstart >= end
-
restrict
public Markers restrict(int[] indices)
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:
java.lang.IndexOutOfBoundsException- if there existsjsuch that(0 <= j && j < indices.length)such that(indices[j] < 0 || indices[j] >= this.nMarkers())java.lang.IllegalArgumentException- if there existsjsuch that(1 <= j && j < indices.length)such that(indices[j] <= indice[j - 1])java.lang.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:
java.lang.IndexOutOfBoundsException- ifmarker < 0 || marker > this.nMarkers()
-
sumAlleles
public int sumAlleles()
Returnsthis.sumAlleles(this.nMarkers()).- Returns:
this.sumAlleles(this.nMarkers())
-
sumGenotypes
public int sumGenotypes(int marker)
Returns the sum of the number of possible genotypes for the markers with index less than the specified index.- Parameters:
marker- a marker index- Returns:
- the sum of the number of possible genotypes for the markers with index less than the specified index
- Throws:
java.lang.IndexOutOfBoundsException- ifmarker < 0 || marker > this.nMarkers()
-
sumGenotypes
public int sumGenotypes()
Returnsthis.sumGenotypes(this.nMarkers()).- Returns:
this.sumGenotypes(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:
java.lang.IndexOutOfBoundsException- ifmarker < 0 || marker > this.nMarkers()
-
sumHapBits
public int sumHapBits()
Returnsthis.sumHaplotypeBits(this.nMarkers()).- Returns:
this.sumHaplotypeBits(this.nMarkers())
-
bitsToAlleles
public int[] bitsToAlleles(BitArray hapBits)
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:
java.lang.NullPointerException- ifhapBits == null
-
allelesToBits
public void allelesToBits(int[] alleles, BitArray bitList)Stores the specified alleles in the specifiedbitList- Parameters:
alleles- a sequence of allelesbitList- a sequence of bits- Throws:
java.lang.IllegalArgumentException- ifalleles.length != this.nMarkers()java.lang.IllegalArgumentException- ifbitList.size() != this.sumHaplotypeBits()java.lang.IllegalArgumentException- if there exists aksuch that(0 < k && k < alleles.length)and(alleles[k] < 0 || alleles[k] >= this.marker(k).nAlleles())java.lang.NullPointerException- ifalleles == null || bitList == null
-
setAllele
public void setAllele(int marker, int allele, BitArray bitList)Stores the specified alleles in the specifiedbitList- Parameters:
marker- a marker indexallele- an allele indexbitList- a sequence of bits- Throws:
java.lang.IllegalArgumentException- ifalleles.length != this.nMarkers()java.lang.IllegalArgumentException- ifbitList.size() != this.sumHaplotypeBits()java.lang.IndexOutOfBoundsException- ifmarker < 0 || marker >= this.nMarkers()java.lang.IndexOutOfBoundsException- ifallele < 0 || allele >= this.marker(marker).nAlleles()java.lang.NullPointerException- ifbitList == null
-
allele
public int allele(BitArray hapBits, int marker)
Returns the specified allele- Parameters:
hapBits- a haplotype encoded as bits with thethis.allelesToBits() methodmarker- a marker index- Returns:
- the specified allele
- Throws:
java.lang.IndexOutOfBoundsException- ifmarker < 0 || marker >= this.nMarkers()java.lang.IndexOutOfBoundsException- ifhapBits.size() < this.sumHaplotypeBits(marker + 1)java.lang.NullPointerException- ifhapBits == null
-
toString
public java.lang.String toString()
Returns a string representation ofthis. The exact details of the representation are unspecified and subject to change.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of
this
-
-