Class ScaffoldNodeCollectionBase
java.lang.Object
org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase
- Direct Known Subclasses:
ScaffoldNetwork
,ScaffoldTree
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 Summary
FieldsModifier and TypeFieldDescriptionprotected HashMap<Integer,
HashSet<ScaffoldNodeBase>> Saves all ScaffoldNodes according to their level.protected static final int
Initial capacity for hash maps storing nodes.protected static final float
Load factor for hash maps storing nodes.protected int
Shows how many nodes have been added so far.protected HashMap<Integer,
ScaffoldNodeBase> Saves all ScaffoldNodes and numbers them in ascending order.protected HashMap<ScaffoldNodeBase,
Integer> Saves all ScaffoldNodes and numbers them in ascending order.protected org.openscience.cdk.smiles.SmilesGenerator
Generator for the creation of SMILESprotected HashMap<String,
ScaffoldNodeBase> Saves all ScaffoldNodes according to their SMILES. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Default Constructorprotected
ScaffoldNodeCollectionBase
(org.openscience.cdk.smiles.SmilesGenerator aSmilesGenerator) Constructor -
Method Summary
Modifier and TypeMethodDescriptionabstract void
addNode
(ScaffoldNodeBase aNode) Add ScaffoldNodeBase to the ScaffoldNodeCollectionBase.protected void
Adds the node to the internal node collections node map, reverse node map, smiles map, and level map.boolean
containsMolecule
(org.openscience.cdk.interfaces.IAtomContainer aMolecule) Checks with the SMILES string whether the molecule is already present in the Scaffold Collection.boolean
containsNode
(int aNumber) Indicates whether there is a node with this number in the collection.Get all ScaffoldNodes of the ScaffoldgetAllNodesOnLevel
(int aLevel) Return all ScaffoldNodes that are at a certain level in the ScaffoldCollection.abstract Integer[][]
Outputs an adjacency matrix in which the parent node of each node is marked with a 1.getMatrixNode
(int aNumber) Returns the node that belongs to a certain row and column number of the matrix.Returns the number of the nodes and the nodes of the matrix in ascending order.Gives the number of nodes as they occur in the matrix.int
Outputs the maximum level of the collectiongetNode
(org.openscience.cdk.interfaces.IAtomContainer aMolecule) Return the ScaffoldNode that belongs to a specific molecule.abstract void
removeNode
(ScaffoldNodeBase aNode) Removes a node.
-
Field Details
-
NODE_MAPS_INIT_CAPACITY
protected static final int NODE_MAPS_INIT_CAPACITYInitial capacity for hash maps storing nodes.- See Also:
-
NODE_MAPS_LOAD_FACTOR
protected static final float NODE_MAPS_LOAD_FACTORLoad factor for hash maps storing nodes.- See Also:
-
nodeMap
Saves all ScaffoldNodes and numbers them in ascending order. Starts at 0. reverseNodeMap with key and value swapped. Key:Number, Value:ScaffoldNodeBase -
reverseNodeMap
Saves all ScaffoldNodes and numbers them in ascending order. Starts at 0. nodeMap with key and value swapped. Key:ScaffoldNodeBase, Value:Number -
smilesMap
Saves all ScaffoldNodes according to their SMILES. Key:SMILES, Value:ScaffoldNodeBase -
levelMap
Saves all ScaffoldNodes according to their level. Key:Level, Value:HashSet of ScaffoldNodeBase -
smilesGenerator
protected org.openscience.cdk.smiles.SmilesGenerator smilesGeneratorGenerator for the creation of SMILES -
nodeCounter
protected int nodeCounterShows 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 SmilesGeneratorIllegalArgumentException
- if the node does not match the scaffold node collection typeNullPointerException
- 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 SmilesGeneratorIllegalArgumentException
- if the node is not in the scaffold node collectionNullPointerException
- 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 SmilesGeneratorNullPointerException
- 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 SmilesGeneratorIllegalArgumentException
- if the node is not in the ScaffoldCollectionNullPointerException
- if parameter is null
-
getMaxLevel
public int getMaxLevel()Outputs the maximum level of the collection- Returns:
- the maximum level of the collection
-
getAllNodesOnLevel
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
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
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
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
Get all ScaffoldNodes of the Scaffold- Returns:
- all ScaffoldNodes of the Scaffold
-
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
-