public class Haplotype
extends java.lang.Object
Class Haplotype
represents a haplotype segment.
Haplotype
are immutable.Constructor and Description |
---|
Haplotype(SampleHapPairs haps,
int hap)
Constructs a new
Haplotype instance. |
Haplotype(SampleHapPairs haps,
int hap,
int start,
int end)
Constructs a new
Haplotype instance. |
Modifier and Type | Method and Description |
---|---|
int |
allele(int index)
Returns the specified allele on the haplotype.
|
boolean |
equals(java.lang.Object obj)
Compares the specified object with this
Haplotype for
equality. |
int |
hapIndex()
Returns the index of the haplotype.
|
int |
hashCode()
Returns a hash code value for the object.
|
int |
length()
Returns the number of alleles in this haplotype segment.
|
Marker |
marker(int index)
Returns the specified marker.
|
Haplotype |
restrict(int start,
int end)
Returns a new
Haplotype instance that is
obtained by restricting this haplotype to the specified marker interval. |
SampleHapPairs |
sampleHapPairs()
Returns the sample haplotype pairs.
|
java.lang.String |
toString()
Returns a string representation of
this . |
public Haplotype(SampleHapPairs haps, int hap)
Haplotype
instance. The haplotype will
include all markers in the specified SampleHapPairs
parameter.haps
- sample haplotype pairshap
- a haplotype indexjava.lang.IndexOutOfBoundsException
- if
hap < 0 || hap >= haps.nHaps()
java.lang.NullPointerException
- if haps == null
public Haplotype(SampleHapPairs haps, int hap, int start, int end)
Haplotype
instance.haps
- sample haplotype pairshap
- a haplotype indexstart
- the starting marker index for the haplotype segment
(inclusive)end
- the ending marker index for the haplotype segment (exclusive)java.lang.IndexOutOfBoundsException
- if
hap < 0 || hap >= haps.nHaps()
java.lang.IndexOutOfBoundsException
- if
start < 0 || start > end || end > haps.nMarkers()
java.lang.NullPointerException
- if haps == null
public Haplotype restrict(int start, int end)
Haplotype
instance that is
obtained by restricting this haplotype to the specified marker interval.start
- the starting marker index for the haplotype segment
(inclusive)end
- the ending marker index for the haplotype segment (exclusive)java.lang.IndexOutOfBoundsException
- if
start < 0 || start > end || end > this.length()
public int length()
public int hapIndex()
public SampleHapPairs sampleHapPairs()
public Marker marker(int index)
index
- a marker indexjava.lang.IndexOutOfBoundsException
- if
index < 0 || index >= this.length()
public int allele(int index)
index
- a marker indexjava.lang.IndexOutOfBoundsException
- if
index < 0 || index >= this.length()
public boolean equals(java.lang.Object obj)
Haplotype
for
equality. Returns true
if the specified object
is a Haplotype
that represents the same haplotype segment
as this
, and returns false
otherwise.equals
in class java.lang.Object
obj
- the object to be compared for equality with this
Haplotype
true
if the specified object is an Haplotype
that represents the same haplotype segment as this
public int hashCode()
Returns a hash code value for the object.
The hash code is defined by the following calculation:
int hash = 17; for (int j=0; j<this.length(); ++j) { hash += 29 * hash + haps.allele(j, this.hapIndex()); hash += 29 * hash + haps.marker(j).hashCode(); }
hashCode
in class java.lang.Object
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