Class: CompositeMolecule

CompositeMolecule

new CompositeMolecule(id, name)

A molecule composited by a few sub molecules.
Parameters:
Name Type Description
id String Id of this molecule.
name String Name of molecule.
Properties:
Name Type Description
name String Name of molecule.
Source:

Extends

Methods

appendAnchorNode(node)

Add anchor node of container. If node not in nodes container, nothing will be done.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:

appendBond(nodesOrIndexes, bondOrder, bondType) → {Kekule.Bond}

A util method to create a new bond object connected with nodes and append to current connection table.
Parameters:
Name Type Description
nodesOrIndexes Array Array of connected nodes or indexes of those nodes
bondOrder Int Order of bond.
bondType Int Type of bond.
Inherited From:
Source:
Returns:
Type
Kekule.Bond

appendChild(obj) → {Int}

Append obj to children list of root. If obj already inside, nothing will be done.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Index of obj after appending.
Type
Int

appendConnector(connector)

Add connector to container.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:

appendLinkedConnector(connector)

Link a connector to this node.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:

appendNode(node)

Add node to container. If node already in container, nothing will be done.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:

calcFormula() → {Kekule.MolecularFormula}

Calculate molecular formula from this connection table.
Inherited From:
Source:
Returns:
Type
Kekule.MolecularFormula

clean(options)

Clean the structure in ctab, removing illegal nodes and connectors.
Parameters:
Name Type Description
options Hash An option hash, can including fields: {orphanChemNode, hangingChemConnector}.
Inherited From:
Source:

clear()

Clear all CTab and formula struuctures.
Inherited From:
Source:

clearAnchorNodes()

Remove all anchor nodes.
Inherited From:
Source:

clearConnectors()

Remove all connectors.
Inherited From:
Source:

clearNodes()

Remove all nodes.
Inherited From:
Source:

compareStructure(targetObj, options) → {Int}

Explicit set compare method to chem structure and compare to targetObj.
Parameters:
Name Type Description
targetObj Kekule.ChemObject
options Hash
Inherited From:
Source:
Returns:
Type
Int

equalStructure(targetObj, options) → {Bool}

Check if this object and targetObj has equivalent chem structure.
Parameters:
Name Type Description
targetObj Kekule.ChemObject
options Hash
Inherited From:
Source:
Returns:
Type
Bool

fetchChargeMarker() → {Kekule.ChemMarker.ChemPropertyMarker}

Get charge marker of node. If no such a marker currently and canCreate is true, a new marker will be created.
Inherited From:
Source:
Returns:
Type
Kekule.ChemMarker.ChemPropertyMarker

fetchRadicalMarker() → {Kekule.ChemMarker.ChemPropertyMarker}

Get radical marker of node. If no such a marker currently and canCreate is true, a new marker will be created.
Inherited From:
Source:
Returns:
Type
Kekule.ChemMarker.ChemPropertyMarker

findDirectChildOfObj(originObj) → {Kekule.ChemStructureNode}

Returns the direct node/substructure that contains originObj. originObj may be a child node or connector of substructure in this structure fragment. If originObj is actually not in this ctab, null will be returned.
Parameters:
Name Type Description
originObj Kekule.ChemStructureObject
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureNode

getAllChildConnectors() → {Array}

Return all bonds in structure as well as in sub structure.
Inherited From:
Source:
Returns:
Array of {Kekule.ChemStructureConnector}.
Type
Array

getAllContainingConnectors() → {Array}

Return all bonds in structure as well as in sub structure.
Source:
Returns:
Array of {Kekule.ChemStructureConnector}.
Type
Array

getAnchorNodeAt(index) → {Kekule.ChemStructureNode}

Get anchor node at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureNode

getAnchorNodeCount() → {Int}

Return count of anchorNodes.
Inherited From:
Source:
Returns:
Type
Int

getChildAt(index) → {Variant}

Get child object at index.
Parameters:
Name Type Description
index Int
Source:
Returns:
Type
Variant

getChildCount() → {Int}

Get count of child molecules.
Source:
Returns:
Type
Int

getConnectorAt(index) → {Kekule.ChemStructureConnector}

Get connector at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getConnectorById(id) → {Kekule.ChemStructureConnector}

Get a structure connector object with a specified id.
Parameters:
Name Type Description
id String
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getConnectorCount() → {Int}

Return count of connectors.
Inherited From:
Source:
Returns:
Type
Int

getConnectorTo(obj) → {Kekule.ChemStructureConnector}

Get connector between this object and another object.
Parameters:
Name Type Description
obj Kekule.ChemStructureObject
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getContainerBox(coordMode) → {Hash}

Calculate the box to fit all sub molecule.
Parameters:
Name Type Description
coordMode Int Determine to calculate 2D or 3D box. Value from Kekule.CoordMode.
Source:
Returns:
Box information. {x1, y1, z1, x2, y2, z2} (in 2D mode z1 and z2 will not be set).
Type
Hash

getContainerBox2D(allowCoordBorrow) → {Hash}

Calculate the 2D box to contain the object.
Parameters:
Name Type Description
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Box information. {x1, y1, z1, x2, y2, z2} (in 2D mode z1 and z2 will not be set).
Type
Hash

getContainerBox3D(allowCoordBorrow) → {Hash}

Calculate the 3D box to contain the object.
Parameters:
Name Type Description
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Box information. {x1, y1, z1, x2, y2, z2} (in 2D mode z1 and z2 will not be set).
Type
Hash

getDirectChildOfNestedNode() → {Kekule.StructureFragment}

Returns direct child object of ctab which hold node as nested child.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

getFlattenedShadowFragment(autoCreate) → {Kekule.StructureFragment}

Returns the shadow fragment with all subgroups unmarshalled
Parameters:
Name Type Description
autoCreate Bool Whether allow to create new one when the shadow does not exists.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

getFlatternedShadowShadowObj(srcObj) → {Kekule.ChemStructureObject}

Returns the flatterned shadowed object of source.
Parameters:
Name Type Description
srcObj Kekule.ChemStructureObject
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureObject

getFlatternedShadowShadowObjs(srcObjs) → {Array}

Returns the flatterned shadowed objects of source.
Parameters:
Name Type Description
srcObjs Array
Inherited From:
Source:
Returns:
Type
Array

getFlatternedShadowSourceObj(shadowObj) → {Kekule.ChemStructureObject}

Returns the source object from flatterned shadow.
Parameters:
Name Type Description
shadowObj Kekule.ChemStructureObject
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureObject

getFlatternedShadowSourceObjs(shadowObjs) → {Array}

Returns the source objects from flatterned shadow.
Parameters:
Name Type Description
shadowObjs Array
Inherited From:
Source:
Returns:
Type
Array

getLabel() → {String}

Returns a label that represents current node. Desendants should override this method.
Inherited From:
Source:
Returns:
Type
String

getLeafNodes() → {Array}

Get all leaf nodes (node that do not have children, usually atom). Note if a sub group has no children, it will be regarded as leaf node too.
Inherited From:
Source:
Returns:
Type
Array

getLinkedBonds(bondType) → {Array}

Returns linked instances of Kekule.Bond to this node.
Parameters:
Name Type Description
bondType Int
Inherited From:
Source:
Returns:
Type
Array

getLinkedChemNodes(ignoreHydrogenAtoms) → {Array}

Returns neighbor nodes linked to this node through proper connectors.
Parameters:
Name Type Description
ignoreHydrogenAtoms Bool Whether explicit hydrogen atoms are returned. Default is false.
Inherited From:
Source:
Returns:
Type
Array

getLinkedConnectorAt(index) → {Kekule.ChemStructureConnector}

Get linked connector object at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getLinkedConnectorCount() → {Int}

Return count of linkedConnectors.
Inherited From:
Source:
Returns:
Type
Int

getLinkedDoubleBonds() → {Array}

Returns linked double covalent bond to this node.
Inherited From:
Source:
Returns:
Type
Array

getLinkedHydrogenAtoms() → {Array}

Returns linked hydrogen atoms.
Inherited From:
Source:
Returns:
Type
Array

getLinkedMultipleBonds() → {Array}

Returns linked multiple covalent bond to this node.
Inherited From:
Source:
Returns:
Type
Array

getLinkedNonHydrogenConnectors() → {Array}

Returns connectors that connected to a non hydrogen node.
Inherited From:
Source:
Returns:
Type
Array

getLinkedNonHydrogenObjs() → {Array}

Returns linked objects except hydrogen atoms.
Inherited From:
Source:
Returns:
Type
Array

getLinkedObjsOnConnector() → {Array}

Returns other objects connected to this one through connector.
Inherited From:
Source:
Returns:
Type
Array

getNextSiblingOfChild(childObj) → {Object}

Returns next sibling object to childObj.
Parameters:
Name Type Description
childObj Object
Source:
Returns:
Type
Object

getNodeAt(index) → {Kekule.ChemStructureNode}

Get node at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureNode

getNodeAtIndexStack(indexStack) → {Kekule.ChemStructureNode}

Get node at indexStack. For example, indexStack is [2, 3, 1], then this.getNodeAt(2).getNodeAt(3).getNodeAt(1) will be returned.
Parameters:
Name Type Description
indexStack Array Array of integers.
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureNode

getNodeById(id) → {Kekule.ChemStructureNode}

Get a structure node object with a specified id.
Parameters:
Name Type Description
id String
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureNode

getNodeCount() → {Int}

Return count of nodes.
Inherited From:
Source:
Returns:
Type
Int

getObjectById(id) → {Kekule.ChemStructureObject}

Get a structure node or connector object with a specified id.
Parameters:
Name Type Description
id String
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureObject

getParentFragment() → {Kekule.StructureFragment}

If Kekule.ChemStructureObject#parent is a Kekule.StructureFragment, returns this fragment.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

getPrimaryIsotope() → {Kekule.Isotope}

Returns the most possible isotope of node. To Kekule.Atom, this should be simplely the isotope of atom while variable atom or pseudoatom may has its own implementation. This method returns null if isotope is uncertain to this node. Descendants need to override this method.
Inherited From:
Source:
Returns:
Type
Kekule.Isotope

getRootFragment() → {Kekule.StructureFragment}

Returns the root parent of Kekule.StructureFragment, rather than subgroups.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

getSubFragments() → {Array}

Get all sub fragments (node that have children, usually SubGroup). Note if a sub group has no children, it will not be regarded as sub fragment.
Inherited From:
Source:
Returns:
Type
Array

getSubMoleculeCount() → {Int}

Returns the number of sub molecules.
Source:
Returns:
Type
Int

hasChildObj(childObj) → {Bool}

Check if childObj is a child node or connector of this fragment's ctab.
Parameters:
Name Type Description
childObj Kekule.ChemObject
Inherited From:
Source:
Returns:
Type
Bool

hasConnector(connector, checkNestedStructure) → {Bool}

Check if a connector exists in structure.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector Connector to seek.
checkNestedStructure Bool If true the nested sub groups will also be checked.
Inherited From:
Source:
Returns:
Type
Bool

hasCtab() → {Bool}

Check whether a connection table is used to represent this fragment.
Source:
Returns:
Type
Bool

hasFormula() → {Bool}

Check whether a formula is used to represent this fragment.
Source:
Returns:
Type
Bool

hasNode(node, checkNestedStructure) → {Bool}

Check if a node exists in structure.
Parameters:
Name Type Description
node Kekule.ChemStructureNode Node to seek.
checkNestedStructure Bool If true the nested sub groups will also be checked.
Inherited From:
Source:
Returns:
Type
Bool

hasSubFragments() → {Bool}

Returns whether there are sub fragment(s) (node that have children, usually SubGroup) in this fragment. Note if a sub group has no children, it will not be regarded as sub fragment.
Inherited From:
Source:
Returns:
Type
Bool

indexOfAnchorNode(node) → {Int}

Get index of anchor node.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:
Returns:
Type
Int

indexOfChild(obj) → {Int}

Get the index of obj in children list of root.
Parameters:
Name Type Description
obj Variant
Source:
Returns:
Index of obj or -1 when not found.
Type
Int

indexOfConnector(connector) → {Int}

Get index of connector inside fragment.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:
Returns:
Type
Int

indexOfLinkedConnector(connector) → {Int}

Returns index of connector connected to node.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:
Returns:
Type
Int

indexOfNode(node) → {Int}

Get index of node.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:
Returns:
Type
Int

indexStackOfNode(node) → {Variant}

Returns index of node. If node exists in nested sub group, index in sub group will be pushed to stack as well.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:
Returns:
If node is the direct child of this structure, returns {Int}, otherwise stack {Array} will be returned.
Type
Variant

insertBefore(obj, refChild) → {Int}

Insert obj before refChild in list of root. If refChild is null or does not exists, obj will be append to tail of list.
Parameters:
Name Type Description
obj Object
refChild Object
Source:
Returns:
Index of obj after inserting.
Type
Int

insertChild(obj, index) → {Int}

Insert obj to index of children list of root. If obj already inside, its position will be changed.
Parameters:
Name Type Description
obj Object
index Object
Source:
Returns:
Index of obj after inserting.
Type
Int

insertConnectorAt(connector, index)

Insert connector to index. If index is not set, node will be inserted as the first connector of ctab.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
index Int
Inherited From:
Source:

insertNodeAt(node, index)

Insert node to index. If index is not set, node will be inserted as the first node of ctab.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
index Int
Inherited From:
Source:

isConnectorInAromaticRing(connector) → {Bool}

Check if a connector is in aromatic ring stored in aromaticRings property.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:
Returns:
Type
Bool

isCtabEmpty() → {Bool}

Returns if the ctab of this structure fragment has no nodes or connectors.
Inherited From:
Source:
Returns:
Type
Bool

isEmpty() → {Bool}

Returns if this fragment has no formula or ctab, or ctab has no nodes or connectors.
Inherited From:
Source:
Returns:
Type
Bool

isHydrogenAtom() → {Bool}

Returns whether this node is a H atom (but not D or T).
Inherited From:
Source:
Returns:
Type
Bool

isNodeInAromaticRing(node) → {Bool}

Check if a node is in aromatic ring stored in aromaticRings property.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:
Returns:
Type
Bool

isSubFragment(node) → {Bool}

Check if a node has a sub structure (has child nodes). Note if a sub group has no children, it will not be regarded as sub fragment.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:
Returns:
Type
Bool

marshalSubFragment(groupNodes, subFragment) → {Kekule.StructureFragment}

Group up nodes and turn them into a new sub Kekule.StructureFragment.
Parameters:
Name Type Description
groupNodes Array A set of Kekule.ChemStructureNode, must in target structure.
subFragment Kekule.StructureFragment new sub group.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

nodesHasCoord2D(allowCoordBorrow) → {Bool}

Check if child nodes has 2D coord.
Parameters:
Name Type Description
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Bool

nodesHasCoord3D(allowCoordBorrow) → {Bool}

Check if child nodes has 3D coord.
Parameters:
Name Type Description
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Bool

recalcCoords()

Recalculate coords of group and child notes. The coords of child nodes are based on group coord, while group coord is calculated by anchorNodes. So those value may need to be recalculate when anchor nodes changed.
Inherited From:
Source:

removeAnchorNode(node)

Remove a node in anchorNodes.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:

removeAnchorNodeAt(index)

Remove node at index of anchorNodes.
Parameters:
Name Type Description
index Int
Inherited From:
Source:

removeChild(obj) → {Variant}

Remove obj from children list of root.
Parameters:
Name Type Description
obj Variant
Source:
Returns:
Child object removed.
Type
Variant

removeChildAt(index) → {Variant}

Remove a child at index.
Parameters:
Name Type Description
index Int
Source:
Returns:
Child object removed.
Type
Variant

removeChildObj(childObj, cascadeRemove, freeRemoved)

Remove childObj from connection table.
Parameters:
Name Type Description
childObj Variant A child node or connector.
cascadeRemove Bool Whether remove related objects (e.g., bond connected to an atom).
freeRemoved Bool Whether free all removed objects.
Inherited From:
Source:

removeConnector(connector, preserveConnectedObjs)

Remove a connector in container.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
preserveConnectedObjs Bool Whether delte relations between this connector and related nodes.
Inherited From:
Source:

removeConnectorAt(index, preserveConnectedObjs)

Remove connector at index of connectors.
Parameters:
Name Type Description
index Int
preserveConnectedObjs Bool Whether delte relations between this connector and related nodes.
Inherited From:
Source:

removeCtab()

Delete ctab info from this fragment.
Inherited From:
Source:

removeFormula()

Delete formula info from this fragment.
Inherited From:
Source:

removeLinkedConnector(connector)

Remove a connector in linkedContainer.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:

removeLinkedConnectorAt(index)

Remove connector at index of linkedConnectors.
Parameters:
Name Type Description
index Int
Inherited From:
Source:

removeNode(node, preserveLinkedConnectors)

Remove a node in container.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
preserveLinkedConnectors Bool Whether remove relations between this node and linked connectors.
Inherited From:
Source:

removeNodeAt(index, preserveLinkedConnectors)

Remove node at index in container.
Parameters:
Name Type Description
index Int
preserveLinkedConnectors Bool Whether remove relations between this node and linked connectors.
Inherited From:
Source:

removeThisFromLinkedConnector()

Remove this node from all linked connectors. Ths method should be called before a object is removed from a structure.
Inherited From:
Source:

replaceNode(oldNode, newNode)

Replace oldNode with new one, preserve coords and all linked connectors.
Parameters:
Name Type Description
oldNode Kekule.ChemStructureNode Must be direct child of current fragment (node in nested structure fragment will be ignored).
newNode Kekule.ChemStructureNode
Inherited From:
Source:

sortConnectors(sortFunc)

Sort direct child connectors in structure fragment.
Parameters:
Name Type Description
sortFunc function Function to determine the priority of nodes.
Inherited From:
Source:

sortNodes(sortFunc)

Sort direct child nodes in structure fragment.
Parameters:
Name Type Description
sortFunc function Function to determine the priority of nodes.
Inherited From:
Source:

traverse(callback, startingNode, breadthFirst, partialNodes) → {Hash}

Traverse the nodes in connection tab through a depth or breadth first spanning tree algorithm.
Parameters:
Name Type Description
callback Func Function called when meet a new node or connector, has two params: callback(currNodeOrConnector, isConnector)
startingNode Kekule.StructureNode Starting position of travers.
breadthFirst Bool Set to true to use breadth first algorithm or false to use depth first algorithm.
partialNodes Array If this param is set, only part of the structure will be traversed.
Inherited From:
Source:
Returns:
A hash object containing all the nodes and connectors sequence traversed. {nodes, connectors}. Note that all nodes but not all connectors (e.g., the one in ring) may be traversed. If the structure has no ctab, null will be returned.
Type
Hash

unmarshalAllSubFragments(cascade)

Remove all sub Kekule.StructureFragment and move their nodes and connectors into this fragment.
Parameters:
Name Type Description
cascade Bool If subfragments should also unmarshal their children fragments.
Inherited From:
Source:

unmarshalSubFragment(subFragment, cascade)

Remove sub Kekule.StructureFragment and move its nodes and connectors into this fragment.
Parameters:
Name Type Description
subFragment Kekule.StructureFragment Sub fragment to be ungrouped.
cascade Bool If subfragment should also unmarshal its children fragments.
Inherited From:
Source:

Events

structureChange

Invoked when object is changed and the change is related with structure (e.g. modify a bond, change a atomic number...). Event has field: {origin: the change source object (may be a child of event.target}.
Inherited From:
Source:

CompositeMolecule

new CompositeMolecule()

Source:

Methods

appendAnchorNode(node)

Add anchor node of container. If node not in nodes container, nothing will be done.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:

appendBond(nodesOrIndexes, bondOrder, bondType) → {Kekule.Bond}

A util method to create a new bond object connected with nodes and append to current connection table.
Parameters:
Name Type Description
nodesOrIndexes Array Array of connected nodes or indexes of those nodes
bondOrder Int Order of bond.
bondType Int Type of bond.
Inherited From:
Source:
Returns:
Type
Kekule.Bond

appendChild(obj) → {Int}

Append obj to children list of root. If obj already inside, nothing will be done.
Parameters:
Name Type Description
obj Object
Source:
Returns:
Index of obj after appending.
Type
Int

appendConnector(connector)

Add connector to container.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:

appendLinkedConnector(connector)

Link a connector to this node.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:

appendNode(node)

Add node to container. If node already in container, nothing will be done.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:

calcFormula() → {Kekule.MolecularFormula}

Calculate molecular formula from this connection table.
Inherited From:
Source:
Returns:
Type
Kekule.MolecularFormula

clean(options)

Clean the structure in ctab, removing illegal nodes and connectors.
Parameters:
Name Type Description
options Hash An option hash, can including fields: {orphanChemNode, hangingChemConnector}.
Inherited From:
Source:

clear()

Clear all CTab and formula struuctures.
Inherited From:
Source:

clearAnchorNodes()

Remove all anchor nodes.
Inherited From:
Source:

clearConnectors()

Remove all connectors.
Inherited From:
Source:

clearNodes()

Remove all nodes.
Inherited From:
Source:

compareStructure(targetObj, options) → {Int}

Explicit set compare method to chem structure and compare to targetObj.
Parameters:
Name Type Description
targetObj Kekule.ChemObject
options Hash
Inherited From:
Source:
Returns:
Type
Int

equalStructure(targetObj, options) → {Bool}

Check if this object and targetObj has equivalent chem structure.
Parameters:
Name Type Description
targetObj Kekule.ChemObject
options Hash
Inherited From:
Source:
Returns:
Type
Bool

fetchChargeMarker() → {Kekule.ChemMarker.ChemPropertyMarker}

Get charge marker of node. If no such a marker currently and canCreate is true, a new marker will be created.
Inherited From:
Source:
Returns:
Type
Kekule.ChemMarker.ChemPropertyMarker

fetchRadicalMarker() → {Kekule.ChemMarker.ChemPropertyMarker}

Get radical marker of node. If no such a marker currently and canCreate is true, a new marker will be created.
Inherited From:
Source:
Returns:
Type
Kekule.ChemMarker.ChemPropertyMarker

findDirectChildOfObj(originObj) → {Kekule.ChemStructureNode}

Returns the direct node/substructure that contains originObj. originObj may be a child node or connector of substructure in this structure fragment. If originObj is actually not in this ctab, null will be returned.
Parameters:
Name Type Description
originObj Kekule.ChemStructureObject
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureNode

getAllChildConnectors() → {Array}

Return all bonds in structure as well as in sub structure.
Inherited From:
Source:
Returns:
Array of {Kekule.ChemStructureConnector}.
Type
Array

getAllContainingConnectors() → {Array}

Return all bonds in structure as well as in sub structure.
Source:
Returns:
Array of {Kekule.ChemStructureConnector}.
Type
Array

getAnchorNodeAt(index) → {Kekule.ChemStructureNode}

Get anchor node at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureNode

getAnchorNodeCount() → {Int}

Return count of anchorNodes.
Inherited From:
Source:
Returns:
Type
Int

getChildAt(index) → {Variant}

Get child object at index.
Parameters:
Name Type Description
index Int
Source:
Returns:
Type
Variant

getChildCount() → {Int}

Get count of child molecules.
Source:
Returns:
Type
Int

getConnectorAt(index) → {Kekule.ChemStructureConnector}

Get connector at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getConnectorById(id) → {Kekule.ChemStructureConnector}

Get a structure connector object with a specified id.
Parameters:
Name Type Description
id String
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getConnectorCount() → {Int}

Return count of connectors.
Inherited From:
Source:
Returns:
Type
Int

getConnectorTo(obj) → {Kekule.ChemStructureConnector}

Get connector between this object and another object.
Parameters:
Name Type Description
obj Kekule.ChemStructureObject
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getContainerBox(coordMode) → {Hash}

Calculate the box to fit all sub molecule.
Parameters:
Name Type Description
coordMode Int Determine to calculate 2D or 3D box. Value from Kekule.CoordMode.
Source:
Returns:
Box information. {x1, y1, z1, x2, y2, z2} (in 2D mode z1 and z2 will not be set).
Type
Hash

getContainerBox2D(allowCoordBorrow) → {Hash}

Calculate the 2D box to contain the object.
Parameters:
Name Type Description
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Box information. {x1, y1, z1, x2, y2, z2} (in 2D mode z1 and z2 will not be set).
Type
Hash

getContainerBox3D(allowCoordBorrow) → {Hash}

Calculate the 3D box to contain the object.
Parameters:
Name Type Description
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Box information. {x1, y1, z1, x2, y2, z2} (in 2D mode z1 and z2 will not be set).
Type
Hash

getDirectChildOfNestedNode() → {Kekule.StructureFragment}

Returns direct child object of ctab which hold node as nested child.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

getFlattenedShadowFragment(autoCreate) → {Kekule.StructureFragment}

Returns the shadow fragment with all subgroups unmarshalled
Parameters:
Name Type Description
autoCreate Bool Whether allow to create new one when the shadow does not exists.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

getFlatternedShadowShadowObj(srcObj) → {Kekule.ChemStructureObject}

Returns the flatterned shadowed object of source.
Parameters:
Name Type Description
srcObj Kekule.ChemStructureObject
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureObject

getFlatternedShadowShadowObjs(srcObjs) → {Array}

Returns the flatterned shadowed objects of source.
Parameters:
Name Type Description
srcObjs Array
Inherited From:
Source:
Returns:
Type
Array

getFlatternedShadowSourceObj(shadowObj) → {Kekule.ChemStructureObject}

Returns the source object from flatterned shadow.
Parameters:
Name Type Description
shadowObj Kekule.ChemStructureObject
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureObject

getFlatternedShadowSourceObjs(shadowObjs) → {Array}

Returns the source objects from flatterned shadow.
Parameters:
Name Type Description
shadowObjs Array
Inherited From:
Source:
Returns:
Type
Array

getLabel() → {String}

Returns a label that represents current node. Desendants should override this method.
Inherited From:
Source:
Returns:
Type
String

getLeafNodes() → {Array}

Get all leaf nodes (node that do not have children, usually atom). Note if a sub group has no children, it will be regarded as leaf node too.
Inherited From:
Source:
Returns:
Type
Array

getLinkedBonds(bondType) → {Array}

Returns linked instances of Kekule.Bond to this node.
Parameters:
Name Type Description
bondType Int
Inherited From:
Source:
Returns:
Type
Array

getLinkedChemNodes(ignoreHydrogenAtoms) → {Array}

Returns neighbor nodes linked to this node through proper connectors.
Parameters:
Name Type Description
ignoreHydrogenAtoms Bool Whether explicit hydrogen atoms are returned. Default is false.
Inherited From:
Source:
Returns:
Type
Array

getLinkedConnectorAt(index) → {Kekule.ChemStructureConnector}

Get linked connector object at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureConnector

getLinkedConnectorCount() → {Int}

Return count of linkedConnectors.
Inherited From:
Source:
Returns:
Type
Int

getLinkedDoubleBonds() → {Array}

Returns linked double covalent bond to this node.
Inherited From:
Source:
Returns:
Type
Array

getLinkedHydrogenAtoms() → {Array}

Returns linked hydrogen atoms.
Inherited From:
Source:
Returns:
Type
Array

getLinkedMultipleBonds() → {Array}

Returns linked multiple covalent bond to this node.
Inherited From:
Source:
Returns:
Type
Array

getLinkedNonHydrogenConnectors() → {Array}

Returns connectors that connected to a non hydrogen node.
Inherited From:
Source:
Returns:
Type
Array

getLinkedNonHydrogenObjs() → {Array}

Returns linked objects except hydrogen atoms.
Inherited From:
Source:
Returns:
Type
Array

getLinkedObjsOnConnector() → {Array}

Returns other objects connected to this one through connector.
Inherited From:
Source:
Returns:
Type
Array

getNextSiblingOfChild(childObj) → {Object}

Returns next sibling object to childObj.
Parameters:
Name Type Description
childObj Object
Source:
Returns:
Type
Object

getNodeAt(index) → {Kekule.ChemStructureNode}

Get node at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureNode

getNodeAtIndexStack(indexStack) → {Kekule.ChemStructureNode}

Get node at indexStack. For example, indexStack is [2, 3, 1], then this.getNodeAt(2).getNodeAt(3).getNodeAt(1) will be returned.
Parameters:
Name Type Description
indexStack Array Array of integers.
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureNode

getNodeById(id) → {Kekule.ChemStructureNode}

Get a structure node object with a specified id.
Parameters:
Name Type Description
id String
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureNode

getNodeCount() → {Int}

Return count of nodes.
Inherited From:
Source:
Returns:
Type
Int

getObjectById(id) → {Kekule.ChemStructureObject}

Get a structure node or connector object with a specified id.
Parameters:
Name Type Description
id String
Inherited From:
Source:
Returns:
Type
Kekule.ChemStructureObject

getParentFragment() → {Kekule.StructureFragment}

If Kekule.ChemStructureObject#parent is a Kekule.StructureFragment, returns this fragment.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

getPrimaryIsotope() → {Kekule.Isotope}

Returns the most possible isotope of node. To Kekule.Atom, this should be simplely the isotope of atom while variable atom or pseudoatom may has its own implementation. This method returns null if isotope is uncertain to this node. Descendants need to override this method.
Inherited From:
Source:
Returns:
Type
Kekule.Isotope

getRootFragment() → {Kekule.StructureFragment}

Returns the root parent of Kekule.StructureFragment, rather than subgroups.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

getSubFragments() → {Array}

Get all sub fragments (node that have children, usually SubGroup). Note if a sub group has no children, it will not be regarded as sub fragment.
Inherited From:
Source:
Returns:
Type
Array

getSubMoleculeCount() → {Int}

Returns the number of sub molecules.
Source:
Returns:
Type
Int

hasChildObj(childObj) → {Bool}

Check if childObj is a child node or connector of this fragment's ctab.
Parameters:
Name Type Description
childObj Kekule.ChemObject
Inherited From:
Source:
Returns:
Type
Bool

hasConnector(connector, checkNestedStructure) → {Bool}

Check if a connector exists in structure.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector Connector to seek.
checkNestedStructure Bool If true the nested sub groups will also be checked.
Inherited From:
Source:
Returns:
Type
Bool

hasCtab() → {Bool}

Check whether a connection table is used to represent this fragment.
Source:
Returns:
Type
Bool

hasFormula() → {Bool}

Check whether a formula is used to represent this fragment.
Source:
Returns:
Type
Bool

hasNode(node, checkNestedStructure) → {Bool}

Check if a node exists in structure.
Parameters:
Name Type Description
node Kekule.ChemStructureNode Node to seek.
checkNestedStructure Bool If true the nested sub groups will also be checked.
Inherited From:
Source:
Returns:
Type
Bool

hasSubFragments() → {Bool}

Returns whether there are sub fragment(s) (node that have children, usually SubGroup) in this fragment. Note if a sub group has no children, it will not be regarded as sub fragment.
Inherited From:
Source:
Returns:
Type
Bool

indexOfAnchorNode(node) → {Int}

Get index of anchor node.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:
Returns:
Type
Int

indexOfChild(obj) → {Int}

Get the index of obj in children list of root.
Parameters:
Name Type Description
obj Variant
Source:
Returns:
Index of obj or -1 when not found.
Type
Int

indexOfConnector(connector) → {Int}

Get index of connector inside fragment.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:
Returns:
Type
Int

indexOfLinkedConnector(connector) → {Int}

Returns index of connector connected to node.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:
Returns:
Type
Int

indexOfNode(node) → {Int}

Get index of node.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:
Returns:
Type
Int

indexStackOfNode(node) → {Variant}

Returns index of node. If node exists in nested sub group, index in sub group will be pushed to stack as well.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:
Returns:
If node is the direct child of this structure, returns {Int}, otherwise stack {Array} will be returned.
Type
Variant

insertBefore(obj, refChild) → {Int}

Insert obj before refChild in list of root. If refChild is null or does not exists, obj will be append to tail of list.
Parameters:
Name Type Description
obj Object
refChild Object
Source:
Returns:
Index of obj after inserting.
Type
Int

insertChild(obj, index) → {Int}

Insert obj to index of children list of root. If obj already inside, its position will be changed.
Parameters:
Name Type Description
obj Object
index Object
Source:
Returns:
Index of obj after inserting.
Type
Int

insertConnectorAt(connector, index)

Insert connector to index. If index is not set, node will be inserted as the first connector of ctab.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
index Int
Inherited From:
Source:

insertNodeAt(node, index)

Insert node to index. If index is not set, node will be inserted as the first node of ctab.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
index Int
Inherited From:
Source:

isConnectorInAromaticRing(connector) → {Bool}

Check if a connector is in aromatic ring stored in aromaticRings property.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:
Returns:
Type
Bool

isCtabEmpty() → {Bool}

Returns if the ctab of this structure fragment has no nodes or connectors.
Inherited From:
Source:
Returns:
Type
Bool

isEmpty() → {Bool}

Returns if this fragment has no formula or ctab, or ctab has no nodes or connectors.
Inherited From:
Source:
Returns:
Type
Bool

isHydrogenAtom() → {Bool}

Returns whether this node is a H atom (but not D or T).
Inherited From:
Source:
Returns:
Type
Bool

isNodeInAromaticRing(node) → {Bool}

Check if a node is in aromatic ring stored in aromaticRings property.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:
Returns:
Type
Bool

isSubFragment(node) → {Bool}

Check if a node has a sub structure (has child nodes). Note if a sub group has no children, it will not be regarded as sub fragment.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:
Returns:
Type
Bool

marshalSubFragment(groupNodes, subFragment) → {Kekule.StructureFragment}

Group up nodes and turn them into a new sub Kekule.StructureFragment.
Parameters:
Name Type Description
groupNodes Array A set of Kekule.ChemStructureNode, must in target structure.
subFragment Kekule.StructureFragment new sub group.
Inherited From:
Source:
Returns:
Type
Kekule.StructureFragment

nodesHasCoord2D(allowCoordBorrow) → {Bool}

Check if child nodes has 2D coord.
Parameters:
Name Type Description
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Bool

nodesHasCoord3D(allowCoordBorrow) → {Bool}

Check if child nodes has 3D coord.
Parameters:
Name Type Description
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Bool

recalcCoords()

Recalculate coords of group and child notes. The coords of child nodes are based on group coord, while group coord is calculated by anchorNodes. So those value may need to be recalculate when anchor nodes changed.
Inherited From:
Source:

removeAnchorNode(node)

Remove a node in anchorNodes.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
Inherited From:
Source:

removeAnchorNodeAt(index)

Remove node at index of anchorNodes.
Parameters:
Name Type Description
index Int
Inherited From:
Source:

removeChild(obj) → {Variant}

Remove obj from children list of root.
Parameters:
Name Type Description
obj Variant
Source:
Returns:
Child object removed.
Type
Variant

removeChildAt(index) → {Variant}

Remove a child at index.
Parameters:
Name Type Description
index Int
Source:
Returns:
Child object removed.
Type
Variant

removeChildObj(childObj, cascadeRemove, freeRemoved)

Remove childObj from connection table.
Parameters:
Name Type Description
childObj Variant A child node or connector.
cascadeRemove Bool Whether remove related objects (e.g., bond connected to an atom).
freeRemoved Bool Whether free all removed objects.
Inherited From:
Source:

removeConnector(connector, preserveConnectedObjs)

Remove a connector in container.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
preserveConnectedObjs Bool Whether delte relations between this connector and related nodes.
Inherited From:
Source:

removeConnectorAt(index, preserveConnectedObjs)

Remove connector at index of connectors.
Parameters:
Name Type Description
index Int
preserveConnectedObjs Bool Whether delte relations between this connector and related nodes.
Inherited From:
Source:

removeCtab()

Delete ctab info from this fragment.
Inherited From:
Source:

removeFormula()

Delete formula info from this fragment.
Inherited From:
Source:

removeLinkedConnector(connector)

Remove a connector in linkedContainer.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
Inherited From:
Source:

removeLinkedConnectorAt(index)

Remove connector at index of linkedConnectors.
Parameters:
Name Type Description
index Int
Inherited From:
Source:

removeNode(node, preserveLinkedConnectors)

Remove a node in container.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
preserveLinkedConnectors Bool Whether remove relations between this node and linked connectors.
Inherited From:
Source:

removeNodeAt(index, preserveLinkedConnectors)

Remove node at index in container.
Parameters:
Name Type Description
index Int
preserveLinkedConnectors Bool Whether remove relations between this node and linked connectors.
Inherited From:
Source:

removeThisFromLinkedConnector()

Remove this node from all linked connectors. Ths method should be called before a object is removed from a structure.
Inherited From:
Source:

replaceNode(oldNode, newNode)

Replace oldNode with new one, preserve coords and all linked connectors.
Parameters:
Name Type Description
oldNode Kekule.ChemStructureNode Must be direct child of current fragment (node in nested structure fragment will be ignored).
newNode Kekule.ChemStructureNode
Inherited From:
Source:

sortConnectors(sortFunc)

Sort direct child connectors in structure fragment.
Parameters:
Name Type Description
sortFunc function Function to determine the priority of nodes.
Inherited From:
Source:

sortNodes(sortFunc)

Sort direct child nodes in structure fragment.
Parameters:
Name Type Description
sortFunc function Function to determine the priority of nodes.
Inherited From:
Source:

traverse(callback, startingNode, breadthFirst, partialNodes) → {Hash}

Traverse the nodes in connection tab through a depth or breadth first spanning tree algorithm.
Parameters:
Name Type Description
callback Func Function called when meet a new node or connector, has two params: callback(currNodeOrConnector, isConnector)
startingNode Kekule.StructureNode Starting position of travers.
breadthFirst Bool Set to true to use breadth first algorithm or false to use depth first algorithm.
partialNodes Array If this param is set, only part of the structure will be traversed.
Inherited From:
Source:
Returns:
A hash object containing all the nodes and connectors sequence traversed. {nodes, connectors}. Note that all nodes but not all connectors (e.g., the one in ring) may be traversed. If the structure has no ctab, null will be returned.
Type
Hash

unmarshalAllSubFragments(cascade)

Remove all sub Kekule.StructureFragment and move their nodes and connectors into this fragment.
Parameters:
Name Type Description
cascade Bool If subfragments should also unmarshal their children fragments.
Inherited From:
Source:

unmarshalSubFragment(subFragment, cascade)

Remove sub Kekule.StructureFragment and move its nodes and connectors into this fragment.
Parameters:
Name Type Description
subFragment Kekule.StructureFragment Sub fragment to be ungrouped.
cascade Bool If subfragment should also unmarshal its children fragments.
Inherited From:
Source:

Events

structureChange

Invoked when object is changed and the change is related with structure (e.g. modify a bond, change a atomic number...). Event has field: {origin: the change source object (may be a child of event.target}.
Inherited From:
Source: