public final class Markers
extends java.lang.Object
Class Markers
represent a list of markers in chromosome order.
Instances of class Markers
are immutable.
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 specified
hapBits
array. |
boolean |
contains(Marker marker) |
Returns
true if the specified marker is not null
and is an element in the list of markers represented by this ,
and returns false otherwise. |
static Markers |
create(Marker[] markers) |
Returns a new
Markers instance that is constructed from
the specified data. |
boolean |
equals(java.lang.Object obj) |
Returns
true if the specified object is a Markers
instance which represents the same list of markers as this ,
and returns false 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 a
Markers instance that represents
the specified range of marker indices. |
int |
sumAlleles() |
Returns
this.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() |
Returns
this.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() |
Returns
this.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 of
this . |
public static Markers create(Marker[] markers)
Markers
instance that is constructed from
the specified data.markers
- a list of markers in chromosome orderMarkers
instance corresponding to the
specified list of markersjava.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
- if
markers == null
or if markers[j] == null
for any j
satisfying (0 <= j && j < markers.length)
public int hashCode()
Arrays.deepHashCode(this.markers())
.hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
true
if the specified object is a Markers
instance which represents the same list of markers as this
,
and returns false
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.equals
in class java.lang.Object
obj
- the object to be tested for equality with this
true
if the specified object is a Markers
instance which represents the same list of markers as this
public int nMarkers()
public Marker marker(int marker)
marker
- a marker indexjava.lang.IndexOutOfBoundsException
- if
marker < 0 || marker >= this.nMarkers()
public Marker[] markers()
public boolean contains(Marker marker)
true
if the specified marker is not null
and is an element in the list of markers represented by this
,
and returns false
otherwise.marker
- a markertrue
if the specified marker is not null
and
is an element in the list of markers represented by this
public Markers restrict(int start, int end)
Markers
instance that represents
the specified range of marker indices.start
- the starting marker index (inclusive)end
- the ending marker index (exclusive)Markers
instance that represents
the specified range of marker indicesjava.lang.IndexOutOfBoundsException
- if
start < 0 || end > this.nMarkers()
java.lang.IllegalArgumentException
- if start >= end
.public int sumAlleles(int marker)
marker
- a marker indexjava.lang.IndexOutOfBoundsException
- if
marker < 0 || marker > this.nMarkers()
public int sumAlleles()
this.sumAlleles(this.nMarkers())
.this.sumAlleles(this.nMarkers())
public int sumGenotypes(int marker)
marker
- a marker indexjava.lang.IndexOutOfBoundsException
- if
marker < 0 || marker > this.nMarkers()
public int sumGenotypes()
this.sumGenotypes(this.nMarkers())
.this.sumGenotypes(this.nMarkers())
public int sumHaplotypeBits(int marker)
marker
- a marker indexjava.lang.IndexOutOfBoundsException
- if
marker < 0 || marker > this.nMarkers()
public int sumHaplotypeBits()
this.sumHaplotypeBits(this.nMarkers())
.this.sumHaplotypeBits(this.nMarkers())
public LongArray allelesToBits(int[] alleles)
alleles
- the alleles at each markerjava.lang.IllegalArgumentException
- if
alleles.length != this.nMarkers()
java.lang.NullPointerException
- if alleles == null
public int bitsToAllele(LongArray hapBits, int marker)
hapBits
array. The contract for this method is undefined if the specified
array was not created with the this.allelesToBits()
method.hapBits
- the bit array storing the haplotype allelesmarker
- a marker indexjava.lang.IndexOutOfBoundsException
- if
marker < 0 || marker >= this.nMarkers()
public java.lang.String toString()
this
.
The exact details of the representation are unspecified and
subject to change.toString
in class java.lang.Object
this