Package vcf
Class Markers
- java.lang.Object
-
- vcf.Markers
-
public final class Markers extends java.lang.Object
Class
Markers
represent a list of markers in chromosome order.Instances of class
Markers
are immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LongArray
allelesToBits(int[] alleles)
Returns a bit array storing the specified haplotype.int
bitsToAllele(LongArray hapBits, int marker)
Returns the specified allele stored in the specifiedhapBits
array.boolean
contains(Marker marker)
Returnstrue
if the specified marker is notnull
and is an element in the list of markers represented bythis
, and returnsfalse
otherwise.static Markers
create(Marker[] markers)
Returns a newMarkers
instance that is constructed from the specified data.boolean
equals(java.lang.Object obj)
Returnstrue
if the specified object is aMarkers
instance which represents the same list of markers asthis
, and returnsfalse
otherwise.int
hashCode()
Returns a hash code value for the object.Marker
marker(int marker)
Returns the specified marker.Marker[]
markers()
Returns the list of markers.int
nMarkers()
Returns the number of markers.Markers
restrict(int start, int end)
Returns aMarkers
instance that represents the specified range of marker indices.int
sumAlleles()
Returnsthis.sumAlleles(this.nMarkers())
.int
sumAlleles(int marker)
Returns the sum of the number of alleles for the markers with index less than the specified index.int
sumGenotypes()
Returnsthis.sumGenotypes(this.nMarkers())
.int
sumGenotypes(int marker)
Returns the sum of the number of possible genotypes for the markers with index less than the specified index.int
sumHaplotypeBits()
Returnsthis.sumHaplotypeBits(this.nMarkers())
.int
sumHaplotypeBits(int marker)
Returns the number of bits requires to store a haplotype for the markers with index less than the specified index.java.lang.String
toString()
Returns a string representation ofthis
.
-
-
-
Method Detail
-
create
public static Markers create(Marker[] markers)
Returns a newMarkers
instance that is constructed from the specified data.- Parameters:
markers
- a list of markers in chromosome order- Returns:
- a new
Markers
instance 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 == null
or ifmarkers[j] == null
for anyj
satisfying(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:
hashCode
in classjava.lang.Object
- Returns:
- a hash code value for the object
-
equals
public boolean equals(java.lang.Object obj)
Returnstrue
if the specified object is aMarkers
instance which represents the same list of markers asthis
, and returnsfalse
otherwise. 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:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to be tested for equality withthis
- Returns:
true
if the specified object is aMarkers
instance which represents the same list of markers asthis
-
nMarkers
public int nMarkers()
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)
Returnstrue
if the specified marker is notnull
and is an element in the list of markers represented bythis
, and returnsfalse
otherwise.- Parameters:
marker
- a marker- Returns:
true
if the specified marker is notnull
and is an element in the list of markers represented bythis
-
restrict
public Markers restrict(int start, int end)
Returns aMarkers
instance that represents the specified range of marker indices.- Parameters:
start
- the starting marker index (inclusive)end
- the ending marker index (exclusive)- Returns:
- a
Markers
instance that represents the specified range of marker indices - Throws:
java.lang.IndexOutOfBoundsException
- ifstart < 0 || end > this.nMarkers()
java.lang.IllegalArgumentException
- ifstart >= end
.
-
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())
-
sumHaplotypeBits
public int sumHaplotypeBits(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()
-
sumHaplotypeBits
public int sumHaplotypeBits()
Returnsthis.sumHaplotypeBits(this.nMarkers())
.- Returns:
this.sumHaplotypeBits(this.nMarkers())
-
allelesToBits
public LongArray allelesToBits(int[] alleles)
Returns a bit array storing the specified haplotype.- Parameters:
alleles
- the alleles at each marker- Returns:
- a bit array storing the specified haplotype.
- Throws:
java.lang.IllegalArgumentException
- ifalleles.length != this.nMarkers()
java.lang.NullPointerException
- ifalleles == null
-
bitsToAllele
public int bitsToAllele(LongArray hapBits, int marker)
Returns the specified allele stored in the specifiedhapBits
array. The contract for this method is undefined if the specified array was not created with thethis.allelesToBits()
method.- Parameters:
hapBits
- the bit array storing the haplotype allelesmarker
- a marker index- Returns:
- Throws:
java.lang.IndexOutOfBoundsException
- ifmarker < 0 || marker >= this.nMarkers()
-
toString
public java.lang.String toString()
Returns a string representation ofthis
. The exact details of the representation are unspecified and subject to change.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of
this
-
-