Class ScaffoldTree


public class ScaffoldTree extends ScaffoldNodeCollectionBase
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)
  • 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 from ScaffoldNodeCollectionBase.
      Specified by:
      addNode in class ScaffoldNodeCollectionBase
      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 SmilesGenerator
      IllegalArgumentException - if the node does not match the scaffold node collection type
      NullPointerException - 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 from ScaffoldNodeCollectionBase.
      Specified by:
      removeNode in class ScaffoldNodeCollectionBase
      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 SmilesGenerator
      IllegalArgumentException - if the node is not in the Scaffold
      NullPointerException - 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 SmilesGenerator
      NullPointerException - if parameter is null
    • getMatrix

      public Integer[][] getMatrix() throws IllegalStateException
      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 from ScaffoldNodeCollectionBase.
      Specified by:
      getMatrix in class ScaffoldNodeCollectionBase
      Returns:
      the adjacency matrix
      Throws:
      IllegalStateException - if the tree is not connected
    • getRoot

      public TreeNode getRoot() throws IllegalStateException
      Outputs root node of the tree.
      Returns:
      root node of the tree
      Throws:
      IllegalStateException - if the tree has no clear root