Class: Molecule

Kekule. Molecule

new Molecule(id, name, withCtab)

Represent an molecule.
Parameters:
Name Type Description
id String Id of this molecule.
name String Name of molecule.
withCtab Bool Create a new molecule with a new ctab.
Properties:
Name Type Description
name String Name of molecule.
Source:

Extends

Methods

analysisRings(options) → {Hash}

Returns ring system details of structure fragment.
Parameters:
Name Type Description
options Hash Options to find rings. Can include the following fields: { bondTypes: [] } If this param is not set, Kekule.globalOptions.algorithm.ringSearch will be used.
Inherited From:
Source:
Returns:
Ring info of ctab, now has one field {ringBlocks: []} in which ringBlocks is An array, each items in it is a cycle block detail. Item containing a series of hash with fields: { connectors: Array of all vertexes in cycle block. nodes: Array of all edges in cycle block. allRings: Array of all rings in cycle block, each item list connectors and nodes of one ring. sssrRings: Array, each item containing connectors and nodes in a SSSR member ring. }
Type
Hash

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

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

canonicalize(canonicalizerId)

Canonicalize a structure fragment by canonicalizer. If canonicalizerId is not set, the default one will be used.
Parameters:
Name Type Description
canonicalizerId String
Inherited From:
Source:

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

findAllRings() → {Array}

Returns all rings in a structure fragment.
Inherited From:
Source:
Returns:
An array containing a series of hash with fields: { connectors: Array of all found connectors. nodes: Array of all found nodes. } Each array item marks a ring.
Type
Array

findAromaticRings(allowUncertainRings, candidateRings) → {Array}

Perceive and all aromatic rings in molecule, same as method perceiveAromaticRings.
Parameters:
Name Type Description
allowUncertainRings Bool Whether uncertain rings (e.g., with variable atom) be included in result.
candidateRings Array Rings in ctab that the detection will be performed. If this param is not set, all memebers of SSSR of ctab will be checked.
Inherited From:
Source:
Returns:
Found aromatic rings.
Type
Array

findCycleBlocks(graph) → {Array}

Returns all connectors and nodes in cylce block.
Parameters:
Name Type Description
graph Kekule.Graph
Inherited From:
Source:
Returns:
An array containing a series of hash with fields: { connectors: Array of all found connectors. nodes: Array of all found nodes. } Each array item marks a cycle block.
Type
Array

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

findSSSR() → {Array}

Returns Smallest set of smallest rings of structure fragment.
Inherited From:
Source:
Returns:
An array containing a series of hash with fields: { nodes: Array of all found nodes. connectors: Array of all found connectors. } Each array item marks a SSSR ring.
Type
Array

getAbsBaseCoord(coordMode, allowCoordBorrow) → {Hash}

Get absolute center coord of object.
Parameters:
Name Type Description
coordMode Int
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Hash

getAllAutoScaleRefLengths(coordMode, allowCoordBorrow) → {Array}

Returns all length factors in object to help the scale ratio in autoscale mode. To molecule, typically this is the all of bond lengths. If no length can be found in this object, [] will be returned.
Parameters:
Name Type Description
coordMode Int
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Array

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.
Inherited From:
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

getAutoScaleRefLength(coordMode, allowCoordBorrow) → {Float}

Returns length factor in object to help the scale ratio in autoscale mode. To molecule, typically this is the median of bond length. If no length can be found in this object, null will be returned.
Parameters:
Name Type Description
coordMode Int
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Float

getBaseCoord(coordMode, allowCoordBorrow) → {Hash}

Get center coord of object.
Parameters:
Name Type Description
coordMode Int
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Hash

getBelongedRingMinSize() → {Int}

Returns the min size of all belonged rings.
Inherited From:
Source:
Returns:
Min ring node count. If the object is not belonged to any ring, null will be returned.
Type
Int

getBelongedSssrRings() → {Array}

Returns SSSR ring that this object belonged.
Inherited From:
Source:
Returns:
Type
Array

getChildAt(index) → {Variant}

Get child object (including both nodes and connectors) at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Variant

getChildCount() → {Int}

Get count of child objects (including both nodes and connectors).
Inherited From:
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

getConnectorLengthMedian(coordMode, allowCoordBorrow) → {Float}

Returns median of all connector lengths.
Parameters:
Name Type Description
coordMode Int
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Float

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, allowCoordBorrow) → {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.
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

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

getCoordDeterminateObjects() → {Array}

If this object determinate other object's coord, this method should returns them.
Inherited From:
Source:
Returns:
Type
Array

getDirectChildOfNestedNode() → {Kekule.StructureFragment}

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

getDisplayRichText(hydrogenDisplayLevel, showCharge, displayLabelConfigs)

Get label to display the atom.
Parameters:
Name Type Description
hydrogenDisplayLevel Int Value from Kekule.Render.HydrogenDisplayLevel.
showCharge Bool Whether display charge of node.
displayLabelConfigs Kekule.Render.DisplayLabelConfigs
Inherited From:
Source:

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) → {Variant}

Returns next sibling node or connector to childObj.
Parameters:
Name Type Description
childObj Variant Node or connector.
Inherited From:
Source:
Returns:
Type
Variant

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

getRingAromaticType(ring, refRings)

Returns aromatic type of a ring.
Parameters:
Name Type Description
ring Object
refRings Array Should list all related rings to ring, help to determine the p electron number. If this value is not set, SSSR of molecule will be used instead.
Inherited From:
Source:

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

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()

Check whether a connection table is used to represent this fragment.
Inherited From:
Source:

hasFormula()

Check whether a formula is used to represent this fragment.
Inherited From:
Source:

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.
Parameters:
Name Type Description
obj Variant
Inherited From:
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 node or connector list of ctab. If refChild is null or does not exists, obj will be append to tail of list.
Parameters:
Name Type Description
obj Variant A node or connector.
refChild Variant Ref node or connector
Inherited From:
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

isCoordDependent() → {Bool}

Whether the coord of chem object is calculated from other object (like connector).
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

isSameStructureWith(target, compareOptions) → {Bool}

Check if two structure fragment (molecule) is same in chem level (same atoms, bonds and structures).
Parameters:
Name Type Description
target Kekule.StructureFragment
compareOptions Hash
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

move(delta, coordMode) → {Hash}

Move node by delta.
Parameters:
Name Type Description
delta Hash
coordMode Int
Inherited From:
Source:
Returns:
New coord after moving.
Type
Hash

move2D(delta) → {Hash}

Move node 2D coord by delta.
Parameters:
Name Type Description
delta Hash
Inherited From:
Source:
Returns:
New coord after moving.
Type
Hash

move3D(delta) → {Hash}

Move node 3D coord by delta.
Parameters:
Name Type Description
delta Hash
Inherited From:
Source:
Returns:
New coord after moving.
Type
Hash

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

perceiveAromaticRings(allowUncertainRings, candidateRings) → {Array}

Perceive and mark all aromatic rings in molecule. Found rings will be stored in aromaticRings property of structure fragment object.
Parameters:
Name Type Description
allowUncertainRings Bool Whether uncertain rings (e.g., with variable atom) be included in result.
candidateRings Array Rings in molecule that the detection will be performed. If this param is not set, all memebers of SSSR of molecule will be checked.
Inherited From:
Source:
Returns:
Found aromatic rings.
Type
Array

perceiveChiralNodes(coordMode, ignoreCanonicalization:, options) → {Array}

Detect and mark parity of all chiral nodes in structure fragment.
Parameters:
Name Type Description
coordMode Int Use 2D or 3D coord to calculate.
ignoreCanonicalization: Bool Bool. If false, ctab will be canonicalized before perception.
options Hash Chiral calculation options, including: {
implicitFischerProjection: Bool, whether the "+" cross of Fischer projection need to be recognized and take into consideration. Only works when coord mode is 2D.
fischerAllowedError: the allowed error when checking vertical and horizontal line in Fischer projection cross, default is 0.08 (deltaY/deltaX or vice versa, about 4.5 degree).
reversedFischer: If true, the node on vertical line will be toward observer instead, allowExplicitHydrogenInFischer: Whether the simplification Fischer projection in saccharide chain form is allowed (H is omitted from structure).
}
Inherited From:
Source:
Returns:
Array of all chiral nodes.
Type
Array

perceiveStereoConnectors(coordMode) → {Array}

Detect and mark parity of all stereo connectors in structure fragment.
Parameters:
Name Type Description
coordMode Int Use 2D or 3D coord to calculate.
Inherited From:
Source:
Returns:
Array of all chiral nodes.
Type
Array

perceiveStereos(coordMode, ignoreCanonicalization:, options) → {Array}

Detect and mark parity of all chiral nodes/connectors in structure fragment.
Parameters:
Name Type Description
coordMode Int Use 2D or 3D coord to calculate.
ignoreCanonicalization: Bool Bool. If false, ctab will be canonicalized before perception.
options Hash Chiral calculation options, including: {
implicitFischerProjection: Bool, whether the "+" cross of Fischer projection need to be recognized and take into consideration. Only works when coord mode is 2D.
fischerAllowedError: the allowed error when checking vertical and horizontal line in Fischer projection cross, default is 0.08 (deltaY/deltaX or vice versa, about 4.5 degree).
reversedFischer: If true, the node on vertical line will be toward observer instead, allowExplicitHydrogenInFischer: Whether the simplification Fischer projection in saccharide chain form is allowed (H is omitted from structure).
}
Inherited From:
Source:
Returns:
Array of all nodes and connectors with special stereo parities.
Type
Array

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(childObj)

Remove child obj directly from connection table.
Parameters:
Name Type Description
childObj Variant A child node or connector.
Inherited From:
Source:

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:
Search sub structure in this fragment.
Parameters:
Name Type Description
subStructure Kekule.StructureFragment Structure to find.
options Hash Search options, can include the following fields: { doStandardize: Bool, whether standardize molecule (especially perceive aromatic rings) before searching. exactMatch: Bool, if true, only the same structure with subStructure will be matched. ignoreCharge: Bool ignoreBondOrder: Bool }
Inherited From:
Source:
Returns:
If sub structure is found, an array of matching node and connectors will be returned. Otherwise false will be returned.
Type
Variant

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:

standardize(options)

Standardize this structure fragment (molecule). Standardization may include canonicalization, aromatic perception and so on.
Parameters:
Name Type Description
options Hash Standardization options, including the following fields: { unmarshalSubFragments: bool, whether unmarshal all sub structures cascadedly of molecule, default is true. doCanonicalization: bool, whether do canonicalization to molecule, default is true. canonicalizerExecutorId: string, which canonicalizer executor should be used. If this value is not set, default one will be used instead. doAromaticPerception: bool, whether do aromatic ring perception to molecule, default is true. }.
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:

Kekule. Molecule

new Molecule()

Source:

Methods

analysisRings(options) → {Hash}

Returns ring system details of structure fragment.
Parameters:
Name Type Description
options Hash Options to find rings. Can include the following fields: { bondTypes: [] } If this param is not set, Kekule.globalOptions.algorithm.ringSearch will be used.
Inherited From:
Source:
Returns:
Ring info of ctab, now has one field {ringBlocks: []} in which ringBlocks is An array, each items in it is a cycle block detail. Item containing a series of hash with fields: { connectors: Array of all vertexes in cycle block. nodes: Array of all edges in cycle block. allRings: Array of all rings in cycle block, each item list connectors and nodes of one ring. sssrRings: Array, each item containing connectors and nodes in a SSSR member ring. }
Type
Hash

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

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

canonicalize(canonicalizerId)

Canonicalize a structure fragment by canonicalizer. If canonicalizerId is not set, the default one will be used.
Parameters:
Name Type Description
canonicalizerId String
Inherited From:
Source:

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

findAllRings() → {Array}

Returns all rings in a structure fragment.
Inherited From:
Source:
Returns:
An array containing a series of hash with fields: { connectors: Array of all found connectors. nodes: Array of all found nodes. } Each array item marks a ring.
Type
Array

findAromaticRings(allowUncertainRings, candidateRings) → {Array}

Perceive and all aromatic rings in molecule, same as method perceiveAromaticRings.
Parameters:
Name Type Description
allowUncertainRings Bool Whether uncertain rings (e.g., with variable atom) be included in result.
candidateRings Array Rings in ctab that the detection will be performed. If this param is not set, all memebers of SSSR of ctab will be checked.
Inherited From:
Source:
Returns:
Found aromatic rings.
Type
Array

findCycleBlocks(graph) → {Array}

Returns all connectors and nodes in cylce block.
Parameters:
Name Type Description
graph Kekule.Graph
Inherited From:
Source:
Returns:
An array containing a series of hash with fields: { connectors: Array of all found connectors. nodes: Array of all found nodes. } Each array item marks a cycle block.
Type
Array

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

findSSSR() → {Array}

Returns Smallest set of smallest rings of structure fragment.
Inherited From:
Source:
Returns:
An array containing a series of hash with fields: { nodes: Array of all found nodes. connectors: Array of all found connectors. } Each array item marks a SSSR ring.
Type
Array

getAbsBaseCoord(coordMode, allowCoordBorrow) → {Hash}

Get absolute center coord of object.
Parameters:
Name Type Description
coordMode Int
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Hash

getAllAutoScaleRefLengths(coordMode, allowCoordBorrow) → {Array}

Returns all length factors in object to help the scale ratio in autoscale mode. To molecule, typically this is the all of bond lengths. If no length can be found in this object, [] will be returned.
Parameters:
Name Type Description
coordMode Int
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Array

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.
Inherited From:
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

getAutoScaleRefLength(coordMode, allowCoordBorrow) → {Float}

Returns length factor in object to help the scale ratio in autoscale mode. To molecule, typically this is the median of bond length. If no length can be found in this object, null will be returned.
Parameters:
Name Type Description
coordMode Int
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Float

getBaseCoord(coordMode, allowCoordBorrow) → {Hash}

Get center coord of object.
Parameters:
Name Type Description
coordMode Int
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Hash

getBelongedRingMinSize() → {Int}

Returns the min size of all belonged rings.
Inherited From:
Source:
Returns:
Min ring node count. If the object is not belonged to any ring, null will be returned.
Type
Int

getBelongedSssrRings() → {Array}

Returns SSSR ring that this object belonged.
Inherited From:
Source:
Returns:
Type
Array

getChildAt(index) → {Variant}

Get child object (including both nodes and connectors) at index.
Parameters:
Name Type Description
index Int
Inherited From:
Source:
Returns:
Type
Variant

getChildCount() → {Int}

Get count of child objects (including both nodes and connectors).
Inherited From:
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

getConnectorLengthMedian(coordMode, allowCoordBorrow) → {Float}

Returns median of all connector lengths.
Parameters:
Name Type Description
coordMode Int
allowCoordBorrow Bool
Inherited From:
Source:
Returns:
Type
Float

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, allowCoordBorrow) → {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.
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

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

getCoordDeterminateObjects() → {Array}

If this object determinate other object's coord, this method should returns them.
Inherited From:
Source:
Returns:
Type
Array

getDirectChildOfNestedNode() → {Kekule.StructureFragment}

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

getDisplayRichText(hydrogenDisplayLevel, showCharge, displayLabelConfigs)

Get label to display the atom.
Parameters:
Name Type Description
hydrogenDisplayLevel Int Value from Kekule.Render.HydrogenDisplayLevel.
showCharge Bool Whether display charge of node.
displayLabelConfigs Kekule.Render.DisplayLabelConfigs
Inherited From:
Source:

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) → {Variant}

Returns next sibling node or connector to childObj.
Parameters:
Name Type Description
childObj Variant Node or connector.
Inherited From:
Source:
Returns:
Type
Variant

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

getRingAromaticType(ring, refRings)

Returns aromatic type of a ring.
Parameters:
Name Type Description
ring Object
refRings Array Should list all related rings to ring, help to determine the p electron number. If this value is not set, SSSR of molecule will be used instead.
Inherited From:
Source:

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

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()

Check whether a connection table is used to represent this fragment.
Inherited From:
Source:

hasFormula()

Check whether a formula is used to represent this fragment.
Inherited From:
Source:

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.
Parameters:
Name Type Description
obj Variant
Inherited From:
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 node or connector list of ctab. If refChild is null or does not exists, obj will be append to tail of list.
Parameters:
Name Type Description
obj Variant A node or connector.
refChild Variant Ref node or connector
Inherited From:
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

isCoordDependent() → {Bool}

Whether the coord of chem object is calculated from other object (like connector).
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

isSameStructureWith(target, compareOptions) → {Bool}

Check if two structure fragment (molecule) is same in chem level (same atoms, bonds and structures).
Parameters:
Name Type Description
target Kekule.StructureFragment
compareOptions Hash
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

move(delta, coordMode) → {Hash}

Move node by delta.
Parameters:
Name Type Description
delta Hash
coordMode Int
Inherited From:
Source:
Returns:
New coord after moving.
Type
Hash

move2D(delta) → {Hash}

Move node 2D coord by delta.
Parameters:
Name Type Description
delta Hash
Inherited From:
Source:
Returns:
New coord after moving.
Type
Hash

move3D(delta) → {Hash}

Move node 3D coord by delta.
Parameters:
Name Type Description
delta Hash
Inherited From:
Source:
Returns:
New coord after moving.
Type
Hash

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

perceiveAromaticRings(allowUncertainRings, candidateRings) → {Array}

Perceive and mark all aromatic rings in molecule. Found rings will be stored in aromaticRings property of structure fragment object.
Parameters:
Name Type Description
allowUncertainRings Bool Whether uncertain rings (e.g., with variable atom) be included in result.
candidateRings Array Rings in molecule that the detection will be performed. If this param is not set, all memebers of SSSR of molecule will be checked.
Inherited From:
Source:
Returns:
Found aromatic rings.
Type
Array

perceiveChiralNodes(coordMode, ignoreCanonicalization:, options) → {Array}

Detect and mark parity of all chiral nodes in structure fragment.
Parameters:
Name Type Description
coordMode Int Use 2D or 3D coord to calculate.
ignoreCanonicalization: Bool Bool. If false, ctab will be canonicalized before perception.
options Hash Chiral calculation options, including: {
implicitFischerProjection: Bool, whether the "+" cross of Fischer projection need to be recognized and take into consideration. Only works when coord mode is 2D.
fischerAllowedError: the allowed error when checking vertical and horizontal line in Fischer projection cross, default is 0.08 (deltaY/deltaX or vice versa, about 4.5 degree).
reversedFischer: If true, the node on vertical line will be toward observer instead, allowExplicitHydrogenInFischer: Whether the simplification Fischer projection in saccharide chain form is allowed (H is omitted from structure).
}
Inherited From:
Source:
Returns:
Array of all chiral nodes.
Type
Array

perceiveStereoConnectors(coordMode) → {Array}

Detect and mark parity of all stereo connectors in structure fragment.
Parameters:
Name Type Description
coordMode Int Use 2D or 3D coord to calculate.
Inherited From:
Source:
Returns:
Array of all chiral nodes.
Type
Array

perceiveStereos(coordMode, ignoreCanonicalization:, options) → {Array}

Detect and mark parity of all chiral nodes/connectors in structure fragment.
Parameters:
Name Type Description
coordMode Int Use 2D or 3D coord to calculate.
ignoreCanonicalization: Bool Bool. If false, ctab will be canonicalized before perception.
options Hash Chiral calculation options, including: {
implicitFischerProjection: Bool, whether the "+" cross of Fischer projection need to be recognized and take into consideration. Only works when coord mode is 2D.
fischerAllowedError: the allowed error when checking vertical and horizontal line in Fischer projection cross, default is 0.08 (deltaY/deltaX or vice versa, about 4.5 degree).
reversedFischer: If true, the node on vertical line will be toward observer instead, allowExplicitHydrogenInFischer: Whether the simplification Fischer projection in saccharide chain form is allowed (H is omitted from structure).
}
Inherited From:
Source:
Returns:
Array of all nodes and connectors with special stereo parities.
Type
Array

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(childObj)

Remove child obj directly from connection table.
Parameters:
Name Type Description
childObj Variant A child node or connector.
Inherited From:
Source:

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:
Search sub structure in this fragment.
Parameters:
Name Type Description
subStructure Kekule.StructureFragment Structure to find.
options Hash Search options, can include the following fields: { doStandardize: Bool, whether standardize molecule (especially perceive aromatic rings) before searching. exactMatch: Bool, if true, only the same structure with subStructure will be matched. ignoreCharge: Bool ignoreBondOrder: Bool }
Inherited From:
Source:
Returns:
If sub structure is found, an array of matching node and connectors will be returned. Otherwise false will be returned.
Type
Variant

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:

standardize(options)

Standardize this structure fragment (molecule). Standardization may include canonicalization, aromatic perception and so on.
Parameters:
Name Type Description
options Hash Standardization options, including the following fields: { unmarshalSubFragments: bool, whether unmarshal all sub structures cascadedly of molecule, default is true. doCanonicalization: bool, whether do canonicalization to molecule, default is true. canonicalizerExecutorId: string, which canonicalizer executor should be used. If this value is not set, default one will be used instead. doAromaticPerception: bool, whether do aromatic ring perception to molecule, default is true. }.
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: