Class ScaffoldNodeCollectionBase

java.lang.Object
org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase
Direct Known Subclasses:
ScaffoldNetwork, ScaffoldTree

public abstract class ScaffoldNodeCollectionBase extends Object
Base class of node collection objects. Top-level class to organise the ScaffoldNodeBase objects.
Version:
1.0.2.0
Author:
Julian Zander, Jonas Schaub (zanderjulian@gmx.de, jonas.schaub@uni-jena.de)
  • Field Details

    • NODE_MAPS_INIT_CAPACITY

      protected static final int NODE_MAPS_INIT_CAPACITY
      Initial capacity for hash maps storing nodes.
      See Also:
    • NODE_MAPS_LOAD_FACTOR

      protected static final float NODE_MAPS_LOAD_FACTOR
      Load factor for hash maps storing nodes.
      See Also:
    • nodeMap

      protected HashMap<Integer,ScaffoldNodeBase> nodeMap
      Saves all ScaffoldNodes and numbers them in ascending order. Starts at 0. reverseNodeMap with key and value swapped. Key:Number, Value:ScaffoldNodeBase
    • reverseNodeMap

      protected HashMap<ScaffoldNodeBase,Integer> reverseNodeMap
      Saves all ScaffoldNodes and numbers them in ascending order. Starts at 0. nodeMap with key and value swapped. Key:ScaffoldNodeBase, Value:Number
    • smilesMap

      protected HashMap<String,ScaffoldNodeBase> smilesMap
      Saves all ScaffoldNodes according to their SMILES. Key:SMILES, Value:ScaffoldNodeBase
    • levelMap

      protected HashMap<Integer,HashSet<ScaffoldNodeBase>> levelMap
      Saves all ScaffoldNodes according to their level. Key:Level, Value:HashSet of ScaffoldNodeBase
    • smilesGenerator

      protected org.openscience.cdk.smiles.SmilesGenerator smilesGenerator
      Generator for the creation of SMILES
    • nodeCounter

      protected int nodeCounter
      Shows how many nodes have been added so far. Removing nodes has no effect on it.
  • Constructor Details

    • ScaffoldNodeCollectionBase

      protected ScaffoldNodeCollectionBase(org.openscience.cdk.smiles.SmilesGenerator aSmilesGenerator)
      Constructor
      Parameters:
      aSmilesGenerator - Used SMILES Generator
    • ScaffoldNodeCollectionBase

      protected ScaffoldNodeCollectionBase()
      Default Constructor
  • Method Details

    • addNode

      public abstract void addNode(ScaffoldNodeBase aNode) throws org.openscience.cdk.exception.CDKException, IllegalArgumentException, NullPointerException
      Add ScaffoldNodeBase to the ScaffoldNodeCollectionBase. The same node can also be added several times. It may therefore be necessary to check whether the node already exists. See containsMolecule();
      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 abstract 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.
      Parameters:
      aNode - Node to remove. 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 is not in the scaffold node collection
      NullPointerException - if parameter is null
    • containsMolecule

      public boolean containsMolecule(org.openscience.cdk.interfaces.IAtomContainer aMolecule) throws org.openscience.cdk.exception.CDKException, NullPointerException
      Checks with the SMILES string whether the molecule is already present in the Scaffold Collection.
      Parameters:
      aMolecule - Molecule to check
      Returns:
      Whether the molecule is located in the Scaffold Collection
      Throws:
      org.openscience.cdk.exception.CDKException - In case of a problem with the SmilesGenerator
      NullPointerException - if parameter is null
    • containsNode

      public boolean containsNode(int aNumber)
      Indicates whether there is a node with this number in the collection.
      Parameters:
      aNumber - Number of the node to be checked
      Returns:
      Is the node in the collection
    • getNode

      public ScaffoldNodeBase getNode(org.openscience.cdk.interfaces.IAtomContainer aMolecule) throws org.openscience.cdk.exception.CDKException, IllegalArgumentException, NullPointerException
      Return the ScaffoldNode that belongs to a specific molecule. Check whether it is the same molecule using the SMILES. If a molecule occurs more than once in the Scaffold, only one corresponding ScaffoldNode is returned.
      Parameters:
      aMolecule - molecule that is being searched for
      Returns:
      ScaffoldNode of the searched molecule
      Throws:
      org.openscience.cdk.exception.CDKException - In case of a problem with the SmilesGenerator
      IllegalArgumentException - if the node is not in the ScaffoldCollection
      NullPointerException - if parameter is null
    • getMaxLevel

      public int getMaxLevel()
      Outputs the maximum level of the collection
      Returns:
      the maximum level of the collection
    • getAllNodesOnLevel

      public List<ScaffoldNodeBase> getAllNodesOnLevel(int aLevel) throws IllegalArgumentException
      Return all ScaffoldNodes that are at a certain level in the ScaffoldCollection.
      Parameters:
      aLevel - Level whose ScaffoldNodes are to be returned
      Returns:
      ScaffoldNodes that are at a certain level
      Throws:
      IllegalArgumentException - if the level does not exist
    • getMatrix

      public abstract 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.
      Returns:
      the adjacency matrix
      Throws:
      IllegalStateException - if the tree is not connected
    • getMatrixNodes

      public Map<Integer,ScaffoldNodeBase> getMatrixNodes()
      Returns the number of the nodes and the nodes of the matrix in ascending order.
      Returns:
      HashMap with the number of the nodes and the ScaffoldNodes in the order they appear in the matrix
    • getMatrixNode

      public ScaffoldNodeBase getMatrixNode(int aNumber)
      Returns the node that belongs to a certain row and column number of the matrix. Returns zero if the node is not in the ScaffoldCollection.
      Parameters:
      aNumber - Row and column number whose node is requested
      Returns:
      Node that belongs to the requested column and row number
    • getAllNodes

      public List<ScaffoldNodeBase> getAllNodes()
      Get all ScaffoldNodes of the Scaffold
      Returns:
      all ScaffoldNodes of the Scaffold
    • getMatrixNodesNumbers

      public List<Integer> getMatrixNodesNumbers()
      Gives the number of nodes as they occur in the matrix. Number of missing Nodes have been removed.
      Returns:
      List with all node numbers of the matrix
    • addNodeToCollections

      protected void addNodeToCollections(ScaffoldNodeBase aNode) throws org.openscience.cdk.exception.CDKException
      Adds the node to the internal node collections node map, reverse node map, smiles map, and level map. Does not test anything!
      Parameters:
      aNode - node to be added
      Throws:
      org.openscience.cdk.exception.CDKException - if SMILES code of the molecule the node contains cannot be created