public class MergeableDagLevel
extends java.lang.Object
Class MergeableDagLevel
represents a level of a leveled
directed acyclic graph (DAG). The class includes a public method for
merging parent nodes.
Instances of class MergebleDagLevel
are not thread-safe.
Constructor and Description |
---|
MergeableDagLevel(HapsMarker data)
Constructs a new
MergeableDagLevel instance from the specified
phased genotype data. |
MergeableDagLevel(HapsMarker data,
float[] weights)
Constructs a new
MergeableDagLevel instance from the specified
phased genotype data and haplotype weights. |
MergeableDagLevel(MergeableDagLevel prevLevel,
HapsMarker data)
Constructs a new
MergeableDagLevel instance with the
specified previous MergeableDagLevel and the
specified phased genotype data. |
Modifier and Type | Method and Description |
---|---|
int |
childNode(int edge)
Returns the child node of the specified edge or -1 if the edge does
not exist
|
float |
edgeCount(int edge)
Returns the sum of weights for the sequences that pass
through the specified edge or 0 if the edge does not exist.
|
boolean |
hasSibling(int parentNode)
Returns
true if the specified parent node has a
sibling and returns false otherwise. |
int |
index()
Returns the marker index.
|
void |
mergeParentNodes(int retainedNode,
int removedNode)
Merges the two specified parent nodes and assigns the specified
retainedNode index to the merged node. |
int |
nAlleles()
Returns the number of alleles.
|
MergeableDagLevel |
next()
Returns the next DAG level or
null if no next level is stored. |
int |
nHaps()
Returns the number of sequences used to construct the DAG.
|
float |
nodeCount(int parentNode)
Returns the sum of weights for the sequences that pass
through the specified parent node or 0 if the parent node
does not exist.
|
int |
outEdge(int parentNode,
int symbol)
Returns the edge that is the outgoing edge of the specified
parent parent node having the specified symbol, or
returns -1 if no such edge exists.
|
int |
parentNode(int edge)
Returns the parent node of the specified edge or -1 if the edge does
not exist.
|
int[] |
parentNodeArray()
Returns an array of parent node indices.
|
MergeableDagLevel |
previous()
Returns the previous DAG level or
null if no previous level
is stored. |
void |
setNextLevel(MergeableDagLevel nextLevel)
Sets the next level to the specified
MergeableDagLevel . |
MergeableDagLevel |
setPreviousToNull()
Sets the previous DAG level to
null , and returns
the previous DAG level that existed immediately prior to the invocation
of this method. |
DagLevel |
toDagLevel()
Returns an immutable
DagLevel corresponding to
this . |
java.lang.String |
toString()
Returns a string representation of
this . |
public MergeableDagLevel(HapsMarker data)
MergeableDagLevel
instance from the specified
phased genotype data. The previous()
method of the
constructed instance will return null
. Each haplotype
will be assigned a weight of 1.data
- the phased genotype datajava.lang.NullPointerException
- if data == null
public MergeableDagLevel(HapsMarker data, float[] weights)
MergeableDagLevel
instance from the specified
phased genotype data and haplotype weights. The previous()
method of the constructed instance will return null
.data
- the phased genotype dataweights
- an array mapping haplotype indices to non-negative
weightsjava.lang.IllegalArgumentException
- if
weights.length != data.nHaps()
java.lang.NullPointerException
- if data==null || weights==null
public MergeableDagLevel(MergeableDagLevel prevLevel, HapsMarker data)
MergeableDagLevel
instance with the
specified previous MergeableDagLevel
and the
specified phased genotype data. This constructor does not alter
any field of the specified prevLevel
object.prevLevel
- the previous MergeableDagLevel
data
- the phased genotype datajava.lang.IllegalArgumentException
- if
prevLevel.nextLevel() != null
java.lang.IllegalArgumentException
- if
parent.nHaps() != data.nHaps()
java.lang.NullPointerException
- if
parent == null || data == null
public MergeableDagLevel setPreviousToNull()
null
, and returns
the previous DAG level that existed immediately prior to the invocation
of this method.public void setNextLevel(MergeableDagLevel nextLevel)
MergeableDagLevel
.nextLevel
- the next leveljava.lang.IllegalArgumentException
- if
nextLevel.previousLevel() != this
public MergeableDagLevel previous()
null
if no previous level
is stored.public MergeableDagLevel next()
null
if no next level is stored.public boolean hasSibling(int parentNode)
true
if the specified parent node has a
sibling and returns false
otherwise.
Two parent nodes are siblings if they are connected by an
edge to the same parent node at the previous level of the DAG.parentNode
- a parent node indextrue
if the specified parent node has a
siblingpublic DagLevel toDagLevel()
DagLevel
corresponding to
this
. The parent node, edge, and child node indices
in the returned DagLevel
are the ranks of the
parent node, edge, and child node indices for this
,
with rank 0 corresponding to the smallest index.DagLevel
corresponding to this
public void mergeParentNodes(int retainedNode, int removedNode)
retainedNode
index to the merged node.retainedNode
- a parent node which will receive ingoing and
outgoing edges of removedNode
removedNode
- a parent node that will be deleted after merging.java.lang.IllegalArgumentException
- if retainedNode
or returnedNode
is not a valid parent node index.public int index()
public int nHaps()
public int nAlleles()
public float edgeCount(int edge)
edge
- index of the edgejava.lang.IndexOutOfBoundsException
- if
edge < 0 || edge >= this.nHaps()
public float nodeCount(int parentNode)
parentNode
- index of the parent nodejava.lang.IndexOutOfBoundsException
- if
parentNode < 0 || parentNode >= this.nHaps()
public int[] parentNodeArray()
public int parentNode(int edge)
edge
- index of the edgejava.lang.IndexOutOfBoundsException
- if
edge < 0 || edge >= this.nHaps()
public int childNode(int edge)
edge
- the edgejava.lang.IndexOutOfBoundsException
- if
edge < 0 || edge >= this.Haplotypes()
public int outEdge(int parentNode, int symbol)
parentNode
- the parent nodesymbol
- symbol labeling the outgoing edgejava.lang.IndexOutOfBoundsException
- if
parentNode < 0 || parentNode >= this.nHaps()
java.lang.IndexOutOfBoundsException
- if
symbol < 0 || symbol >= this.nAlleles()
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