Class ScaffoldTree
java.lang.Object
org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase
org.openscience.cdk.tools.scaffold.ScaffoldTree
Top-level class to organise the TreeNodes as a tree.
A tree can have one root and several leaves.
- Version:
- 1.0.2.0
- Author:
- Julian Zander, Jonas Schaub (zanderjulian@gmx.de, jonas.schaub@uni-jena.de)
-
Field Summary
Fields inherited from class org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase
levelMap, NODE_MAPS_INIT_CAPACITY, NODE_MAPS_LOAD_FACTOR, nodeCounter, nodeMap, reverseNodeMap, smilesGenerator, smilesMap
-
Constructor Summary
ConstructorsConstructorDescriptionDefault ConstructorScaffoldTree
(org.openscience.cdk.smiles.SmilesGenerator aSmilesGenerator) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNode
(ScaffoldNodeBase aNode) Add a node to the graph structure.Integer[][]
Outputs an adjacency matrix in which the parent node of each node is marked with a 1.getRoot()
Outputs root node of the tree.boolean
isValid()
Tests whether the tree is valid, i.e. has only one root and all nodes are connected.boolean
mergeTree
(ScaffoldTree aScaffoldTree) Adds another ScaffoldTree to the existing one if possible.void
removeNode
(ScaffoldNodeBase aNode) Removes a node.Methods inherited from class org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase
addNodeToCollections, containsMolecule, containsNode, getAllNodes, getAllNodesOnLevel, getMatrixNode, getMatrixNodes, getMatrixNodesNumbers, getMaxLevel, getNode
-
Constructor Details
-
ScaffoldTree
public ScaffoldTree(org.openscience.cdk.smiles.SmilesGenerator aSmilesGenerator) Constructor- Parameters:
aSmilesGenerator
- Used SMILES Generator
-
ScaffoldTree
public ScaffoldTree()Default Constructor
-
-
Method Details
-
addNode
public void addNode(ScaffoldNodeBase aNode) throws org.openscience.cdk.exception.CDKException, IllegalArgumentException, NullPointerException Add a node to the graph structure. The same node can also be added several times. It may therefore be necessary to check whether the node already exists. See containsMolecule(); Description copied fromScaffoldNodeCollectionBase
.- Specified by:
addNode
in classScaffoldNodeCollectionBase
- Parameters:
aNode
- Node to be added. Must match the scaffold node collection type. For example, a ScaffoldTree requires a TreeNode.- Throws:
org.openscience.cdk.exception.CDKException
- In case of a problem with the SmilesGeneratorIllegalArgumentException
- if the node does not match the scaffold node collection typeNullPointerException
- if parameter is null
-
removeNode
public void removeNode(ScaffoldNodeBase aNode) throws org.openscience.cdk.exception.CDKException, IllegalArgumentException, NullPointerException Removes a node. This does not change the order. The numbering does not change. Description copied fromScaffoldNodeCollectionBase
.- Specified by:
removeNode
in classScaffoldNodeCollectionBase
- Parameters:
aNode
- Node to remove. Must match the tree object. For example, a ScaffoldTree requires a TreeNode.- Throws:
org.openscience.cdk.exception.CDKException
- In case of a problem with the SmilesGeneratorIllegalArgumentException
- if the node is not in the ScaffoldNullPointerException
- if parameter is null
-
isValid
public boolean isValid()Tests whether the tree is valid, i.e. has only one root and all nodes are connected. For the transfer of the tree into the matrix, the tree must be valid.- Returns:
- true if tree has only one root and all nodes are connected
-
mergeTree
public boolean mergeTree(ScaffoldTree aScaffoldTree) throws org.openscience.cdk.exception.CDKException, NullPointerException Adds another ScaffoldTree to the existing one if possible. The new tree is inserted at the node that both trees have in common. All children of the new tree at this node are taken over if they do not already exist. The new tree is simply taken over if the existing tree is empty. If there is no match between the two trees, false is returned and the old tree is not changed. If a molecule does generate an empty scaffold, it is stored as a node with empty SMILES and is treated normally. All other empty nodes are then added to this tree accordingly. By querying the origins of this node, all molecules that do not produce a scaffold can be returned.- Parameters:
aScaffoldTree
- tree to be inserted into the existing ScaffoldTree.- Returns:
- false if the new tree has nodes and cannot be inserted because the two trees have no common nodes.
- Throws:
org.openscience.cdk.exception.CDKException
- In case of a problem with the SmilesGeneratorNullPointerException
- if parameter is null
-
getMatrix
Outputs an adjacency matrix in which the parent node of each node is marked with a 1. All others are marked with 0. Each row and column number in the matrix is assigned to a node. The assignment can be requested with getMatrixNodes/getMatrixNode. Description copied fromScaffoldNodeCollectionBase
.- Specified by:
getMatrix
in classScaffoldNodeCollectionBase
- Returns:
- the adjacency matrix
- Throws:
IllegalStateException
- if the tree is not connected
-
getRoot
Outputs root node of the tree.- Returns:
- root node of the tree
- Throws:
IllegalStateException
- if the tree has no clear root
-