Class: StructureFragment

StructureFragment

new StructureFragment(id, coord2D, coord3D)

Represent an abstract container of nodes (molecule, substitution, group...) in chemical structure.
Parameters:
Name Type Description
id String Id of this node.
coord2D Object The 2D coordinates of node, {x, y}, can be null.
coord3D Object The 3D coordinates of node, {x, y, z}, can be null.
Properties:
Name Type Description
formula Kekule.MolecularFormula Formula of this container. Usually used for some simple structures (such as inorganic molecules). Formual can also be calculated from Kekule.StructureConnectionTable.
ctab Kekule.StructureConnectionTable Connection table of this container. Usually used for some complex structures (such as organic molecules).
nodes Array All structure nodes in this fragment.
anchorNodes Array Nodes that can have bond connected to other structure nodes.
connectors Array Connectors (usually bonds) in this container.
crossConnectors Array Connectors outside the fragment connected to nodes inside fragment. Read only.
nonHydrogenNodes Array All structure nodes except hydrogen atoms in this fragment.
nonHydrogenConnectors Array Connectors except ones connected to hydrogen atoms in this fragment.
flattenedShadow Kekule.StructureFragmentShadow A shadow that "flatten" this structure fragment, unmarshalling all subgroups. Some algorithms (e.g., stereo detection) need to be carried out on flattened structure, this shadow may prevent the original structure from being modified.
Source:

Extends

Methods

(static) moveChildBetweenStructFragment(target, dest, moveNodes, moveConnectors, ignoreAnchorNodes)

Move nodes and connectors from target to dest structure fragment.
Parameters:
Name Type Description
target Kekule.StructureFragment
dest Kekule.StructureFragment
moveNodes Array
moveConnectors Array
ignoreAnchorNodes Bool
Source:

appendAnchorNode(node)

Add anchor node of container. If node not in nodes container, nothing will be done.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
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.
Source:
Returns:
Type
Kekule.Bond

appendConnector(connector)

Add connector to container.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
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
Source:

calcFormula() → {Kekule.MolecularFormula}

Calculate molecular formula from this connection table.
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}.
Source:

clear()

Clear all CTab and formula struuctures.
Source:

clearAnchorNodes()

Remove all anchor nodes.
Source:

clearConnectors()

Remove all connectors.
Source:

clearNodes()

Remove all nodes.
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
Source:
Returns:
Type
Kekule.ChemStructureNode

getAllChildConnectors() → {Array}

Return all bonds in structure as well as in sub structure.
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
Source:
Returns:
Type
Kekule.ChemStructureNode

getAnchorNodeCount() → {Int}

Return count of anchorNodes.
Source:
Returns:
Type
Int

getChildAt(index) → {Variant}

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

getChildCount() → {Int}

Get count of child objects (including both nodes and connectors).
Source:
Returns:
Type
Int

getConnectorAt(index) → {Kekule.ChemStructureConnector}

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

getConnectorById(id) → {Kekule.ChemStructureConnector}

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

getConnectorCount() → {Int}

Return count of connectors.
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, 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
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.
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.
Source:
Returns:
Type
Kekule.StructureFragment

getFlatternedShadowShadowObj(srcObj) → {Kekule.ChemStructureObject}

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

getFlatternedShadowShadowObjs(srcObjs) → {Array}

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

getFlatternedShadowSourceObj(shadowObj) → {Kekule.ChemStructureObject}

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

getFlatternedShadowSourceObjs(shadowObjs) → {Array}

Returns the source objects from flatterned shadow.
Parameters:
Name Type Description
shadowObjs Array
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.
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.
Source:
Returns:
Type
Variant

getNodeAt(index) → {Kekule.ChemStructureNode}

Get node at index.
Parameters:
Name Type Description
index Int
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.
Source:
Returns:
Type
Kekule.ChemStructureNode

getNodeById(id) → {Kekule.ChemStructureNode}

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

getNodeCount() → {Int}

Return count of nodes.
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
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.
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
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.
Source:
Returns:
Type
Bool

hasCtab()

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

hasFormula()

Check whether a formula is used to represent this fragment.
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.
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.
Source:
Returns:
Type
Bool

indexOfAnchorNode(node) → {Int}

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

indexOfChild(obj) → {Int}

Get the index of obj in children list.
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
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
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
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
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
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
Source:

isConnectorInAromaticRing(connector) → {Bool}

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

isCtabEmpty() → {Bool}

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

isEmpty() → {Bool}

Returns if this fragment has no formula or ctab, or ctab has no nodes or connectors.
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
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
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.
Source:
Returns:
Type
Kekule.StructureFragment

nodesHasCoord2D(allowCoordBorrow) → {Bool}

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

nodesHasCoord3D(allowCoordBorrow) → {Bool}

Check if child nodes has 3D coord.
Parameters:
Name Type Description
allowCoordBorrow Bool
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.
Source:

removeAnchorNode(node)

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

removeAnchorNodeAt(index)

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

removeChild(childObj)

Remove child obj directly from connection table.
Parameters:
Name Type Description
childObj Variant A child node or connector.
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.
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.
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.
Source:

removeCtab()

Delete ctab info from this fragment.
Source:

removeFormula()

Delete formula info from this fragment.
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.
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.
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
Source:

sortConnectors(sortFunc)

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

sortNodes(sortFunc)

Sort direct child nodes in structure fragment.
Parameters:
Name Type Description
sortFunc function Function to determine the priority of nodes.
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.
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.
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.
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:

StructureFragment

new StructureFragment()

Source:

Methods

(static) moveChildBetweenStructFragment(target, dest, moveNodes, moveConnectors, ignoreAnchorNodes)

Move nodes and connectors from target to dest structure fragment.
Parameters:
Name Type Description
target Kekule.StructureFragment
dest Kekule.StructureFragment
moveNodes Array
moveConnectors Array
ignoreAnchorNodes Bool
Source:

appendAnchorNode(node)

Add anchor node of container. If node not in nodes container, nothing will be done.
Parameters:
Name Type Description
node Kekule.ChemStructureNode
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.
Source:
Returns:
Type
Kekule.Bond

appendConnector(connector)

Add connector to container.
Parameters:
Name Type Description
connector Kekule.ChemStructureConnector
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
Source:

calcFormula() → {Kekule.MolecularFormula}

Calculate molecular formula from this connection table.
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}.
Source:

clear()

Clear all CTab and formula struuctures.
Source:

clearAnchorNodes()

Remove all anchor nodes.
Source:

clearConnectors()

Remove all connectors.
Source:

clearNodes()

Remove all nodes.
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
Source:
Returns:
Type
Kekule.ChemStructureNode

getAllChildConnectors() → {Array}

Return all bonds in structure as well as in sub structure.
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
Source:
Returns:
Type
Kekule.ChemStructureNode

getAnchorNodeCount() → {Int}

Return count of anchorNodes.
Source:
Returns:
Type
Int

getChildAt(index) → {Variant}

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

getChildCount() → {Int}

Get count of child objects (including both nodes and connectors).
Source:
Returns:
Type
Int

getConnectorAt(index) → {Kekule.ChemStructureConnector}

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

getConnectorById(id) → {Kekule.ChemStructureConnector}

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

getConnectorCount() → {Int}

Return count of connectors.
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, 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
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.
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.
Source:
Returns:
Type
Kekule.StructureFragment

getFlatternedShadowShadowObj(srcObj) → {Kekule.ChemStructureObject}

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

getFlatternedShadowShadowObjs(srcObjs) → {Array}

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

getFlatternedShadowSourceObj(shadowObj) → {Kekule.ChemStructureObject}

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

getFlatternedShadowSourceObjs(shadowObjs) → {Array}

Returns the source objects from flatterned shadow.
Parameters:
Name Type Description
shadowObjs Array
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.
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.
Source:
Returns:
Type
Variant

getNodeAt(index) → {Kekule.ChemStructureNode}

Get node at index.
Parameters:
Name Type Description
index Int
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.
Source:
Returns:
Type
Kekule.ChemStructureNode

getNodeById(id) → {Kekule.ChemStructureNode}

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

getNodeCount() → {Int}

Return count of nodes.
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
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.
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
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.
Source:
Returns:
Type
Bool

hasCtab()

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

hasFormula()

Check whether a formula is used to represent this fragment.
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.
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.
Source:
Returns:
Type
Bool

indexOfAnchorNode(node) → {Int}

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

indexOfChild(obj) → {Int}

Get the index of obj in children list.
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
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
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
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
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
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
Source:

isConnectorInAromaticRing(connector) → {Bool}

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

isCtabEmpty() → {Bool}

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

isEmpty() → {Bool}

Returns if this fragment has no formula or ctab, or ctab has no nodes or connectors.
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
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
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.
Source:
Returns:
Type
Kekule.StructureFragment

nodesHasCoord2D(allowCoordBorrow) → {Bool}

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

nodesHasCoord3D(allowCoordBorrow) → {Bool}

Check if child nodes has 3D coord.
Parameters:
Name Type Description
allowCoordBorrow Bool
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.
Source:

removeAnchorNode(node)

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

removeAnchorNodeAt(index)

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

removeChild(childObj)

Remove child obj directly from connection table.
Parameters:
Name Type Description
childObj Variant A child node or connector.
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.
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.
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.
Source:

removeCtab()

Delete ctab info from this fragment.
Source:

removeFormula()

Delete formula info from this fragment.
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.
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.
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
Source:

sortConnectors(sortFunc)

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

sortNodes(sortFunc)

Sort direct child nodes in structure fragment.
Parameters:
Name Type Description
sortFunc function Function to determine the priority of nodes.
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.
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.
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.
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: