public class PSTree
extends java.lang.Object
Designed to be constructed on-the-fly while parsing the NCBI taxonomy dump, which specifies each node and its parent. As a result, invalid trees may be constructed (e.g. multiple roots or cycles). Use checkStructure() to confirm its validity.
Note the tree root is initialized in the constructor and cannot be modified (except adding children with addNode()).
Modifier and Type | Class and Description |
---|---|
static class |
PSTree.Serializer |
Modifier and Type | Field and Description |
---|---|
static int |
NULL_NODE |
Modifier | Constructor and Description |
---|---|
|
PSTree(int rootId) |
protected |
PSTree(com.esotericsoftware.kryo.Kryo kryo,
com.esotericsoftware.kryo.io.Input input) |
Modifier and Type | Method and Description |
---|---|
void |
addNode(int id,
java.lang.String name,
int parent,
long length,
java.lang.String rank)
Adds a node to the tree.
|
void |
checkStructure()
Because of the piecemeal way we allow the tree to be constructed, we can end up with invalid tree structures.
|
boolean |
equals(java.lang.Object o) |
java.util.Collection<java.lang.Integer> |
getChildrenOf(int id) |
int |
getLCA(java.util.Collection<java.lang.Integer> nodes)
Get lowest common ancester of the set of given nodes.
|
long |
getLengthOf(int id) |
java.lang.String |
getNameOf(int id) |
java.util.Set<java.lang.Integer> |
getNodeIDs() |
int |
getParentOf(int id) |
java.util.List<java.lang.Integer> |
getPathOf(int id)
Returns path of node id's from the input id to the root.
|
java.lang.String |
getRankOf(int id) |
int |
hashCode() |
boolean |
hasNode(int id) |
java.util.Set<java.lang.Integer> |
removeUnreachableNodes()
Deletes nodes unreachable from the root and returns the set of deleted nodes.
|
void |
retainNodes(java.util.Set<java.lang.Integer> idsToKeep)
Removes all nodes not in the given set
|
protected void |
serialize(com.esotericsoftware.kryo.Kryo kryo,
com.esotericsoftware.kryo.io.Output output) |
void |
setLengthOf(int id,
long length) |
void |
setNameOf(int id,
java.lang.String name) |
void |
setRankOf(int id,
java.lang.String rank) |
java.lang.String |
toString() |
public static final int NULL_NODE
public PSTree(int rootId)
protected PSTree(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input)
protected void serialize(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output)
public void addNode(int id, java.lang.String name, int parent, long length, java.lang.String rank)
public java.util.Set<java.lang.Integer> removeUnreachableNodes()
public void checkStructure()
public int getLCA(java.util.Collection<java.lang.Integer> nodes)
public java.util.Collection<java.lang.Integer> getChildrenOf(int id)
public java.util.Set<java.lang.Integer> getNodeIDs()
public java.lang.String getNameOf(int id)
public int getParentOf(int id)
public long getLengthOf(int id)
public java.lang.String getRankOf(int id)
public boolean hasNode(int id)
public void retainNodes(java.util.Set<java.lang.Integer> idsToKeep)
public void setNameOf(int id, java.lang.String name)
public void setRankOf(int id, java.lang.String rank)
public void setLengthOf(int id, long length)
public java.util.List<java.lang.Integer> getPathOf(int id)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object