openchemlib
Version:
Manipulate molecules
1,536 lines (1,331 loc) • 128 kB
TypeScript
export declare const Resources: {
/**
* Register the static resources.
* This is needed for some APIs.
* @param data - Object containing the resources or JSON string for such an object.
*/
register(data: string | Record<string, string>): void;
/**
* Fetch and register the static resources asynchronously from a URL.
* @param url - URL to the resources.json file.
* If omitted, fetch will be done relative to the openchemlib.js module location.
*/
registerFromUrl(url?: string): Promise<void>;
/**
* Read and register the static resources synchronously.
* This is a convenience method for Node.js.
* @param path - Path to the resources.json file.
* If omitted, the file will be read relative to the openchemlib.js module location.
*/
registerFromNodejs(path?: string): void;
};
export interface MoleculeFromSmilesOptions {
/**
* Disable coordinate invention.
* @default false
*/
noCoordinates?: boolean;
/**
* Disable stereo features parsing.
* @default false
*/
noStereo?: boolean;
}
export interface AtomQueryFeatures {
aromatic: boolean;
notAromatic: boolean;
notChain: boolean;
not2RingBonds: boolean;
not3RingBonds: boolean;
not4RingBonds: boolean;
noMoreNeighbours: boolean;
moreNeighbours: boolean;
matchStereo: boolean;
not0PiElectrons: boolean;
not1PiElectron: boolean;
not2PiElectrons: boolean;
not0Hydrogen: boolean;
not1Hydrogen: boolean;
not2Hydrogen: boolean;
not3Hydrogen: boolean;
not0Neighbours: boolean;
not1Neighbour: boolean;
not2Neighbours: boolean;
not3Neighbours: boolean;
not4Neighbours: boolean;
notChargeNeg: boolean;
notCharge0: boolean;
noChargePos: boolean;
ringSize0: boolean;
ringSize3: boolean;
ringSize4: boolean;
ringSize5: boolean;
ringSize6: boolean;
ringSize7: boolean;
ringSizeLarge: boolean;
}
export interface BondQueryFeatures {
single: boolean;
double: boolean;
triple: boolean;
delocalized: boolean;
metalLigand: boolean;
quadruple: boolean;
quintuple: boolean;
notRing: boolean;
ring: boolean;
aromatic: boolean;
nonAromatic: boolean;
ringSize: number;
brigdeMin: number;
brigdeSpan: number;
}
export interface MoleculeToSVGOptions extends DepictorOptions {
/**
* Factor used to compute the size of text nodes.
* Default: 1.
*/
factorTextSize?: number;
/**
* font-weight attribute of atom labels.
*/
fontWeight?: number | string;
/**
* stroke-width styling property of bonds.
*/
strokeWidth?: number | string;
/**
* Automatically crop the SVG to fit around the molecule.
* This changes the size of the SVG.
* Default: false.
*/
autoCrop?: boolean;
/**
* Margin (in px) to keep around the molecule when `autoCrop` is `true`.
* Default: 5.
*/
autoCropMargin?: number;
}
export interface HoseCodesOptions {
/**
* Maximum number of atoms from the center.
* Default: 5.
*/
maxSphereSize: number;
/**
* Type of HOSE code.
* 0: normal HOSE code.
* 1: stop if Csp3-Csp3.
* Default: 0.
*/
type: 0 | 1;
}
export interface SmilesGeneratorOptions {
/**
* Whether to create SMILES with SMARTS capabilities.
* @default false
*/
createSmarts?: boolean;
/**
* Whether to include mapping information (atomMapNo) in the SMILES.
* @default false
*/
includeMapping?: boolean;
/**
* Should localisation of double bonds be attempted?
* @default false
*/
kekulizedOutput?: boolean;
}
export interface Rectangle {
/**
* X-coordinate of the top-left corner.
*/
x: number;
/**
* Y-coordinate of the top-left corner.
*/
y: number;
/**
* Width of the shape.
*/
width: number;
/**
* Height of the shape.
*/
height: number;
}
export declare class Molecule {
/**
* Construct a new molecule.
* @param maxAtoms - Maximum number of initialized atoms. Default: 256.
* @param maxBonds - Maximum number of initialized bonds. Default: 256.
*/
constructor(maxAtoms: number, maxBonds: number);
// based on JSMolecule.java you can do a regexp ".*static.* (int|long|double)(.*) = .*;" and replace with "$2: number;"
// bonds to represent aromaticity
static CANONIZER_CREATE_SYMMETRY_RANK: number;
static CANONIZER_CONSIDER_DIASTEREOTOPICITY: number;
static CANONIZER_CONSIDER_ENANTIOTOPICITY: number;
static CANONIZER_CONSIDER_STEREOHETEROTOPICITY: number;
static CANONIZER_ENCODE_ATOM_CUSTOM_LABELS: number;
static CANONIZER_ENCODE_ATOM_SELECTION: number;
static CANONIZER_ASSIGN_PARITIES_TO_TETRAHEDRAL_N: number;
static CANONIZER_COORDS_ARE_3D: number;
static CANONIZER_CREATE_PSEUDO_STEREO_GROUPS: number;
static CANONIZER_DISTINGUISH_RACEMIC_OR_GROUPS: number;
static CANONIZER_TIE_BREAK_FREE_VALENCE_ATOMS: number;
static CANONIZER_ENCODE_ATOM_CUSTOM_LABELS_WITHOUT_RANKING: number;
static CANONIZER_NEGLECT_ANY_STEREO_INFORMATION: number;
static cMaxAtomicNo: number;
static cAtomParityNone: number;
static cAtomParity1: number;
static cAtomParity2: number;
static cAtomParityUnknown: number;
static cAtomParityIsPseudo: number;
static cAtomRadicalState: number;
static cAtomRadicalStateShift: number;
static cAtomRadicalStateNone: number;
static cAtomRadicalStateS: number;
static cAtomRadicalStateD: number;
static cAtomRadicalStateT: number;
static cAtomColorNone: number;
static cAtomColorBlue: number;
static cAtomColorRed: number;
static cAtomColorGreen: number;
static cAtomColorMagenta: number;
static cAtomColorOrange: number;
static cAtomColorDarkGreen: number;
static cAtomColorDarkRed: number;
static cAtomCIPParityNone: number;
static cAtomCIPParityRorM: number;
static cAtomCIPParitySorP: number;
static cAtomCIPParityProblem: number;
static cESRTypeAbs: number;
static cESRTypeAnd: number;
static cESRTypeOr: number;
static cESRMaxGroups: number;
static cESRGroupBits: number;
static cAtomQFNoOfBits: number;
static cAtomQFAromStateBits: number;
static cAtomQFAromStateShift: number;
static cAtomQFRingStateBits: number;
static cAtomQFRingStateShift: number;
static cAtomQFHydrogenBits: number;
static cAtomQFHydrogenShift: number;
static cAtomQFPiElectronBits: number;
static cAtomQFPiElectronShift: number;
static cAtomQFNeighbourBits: number;
static cAtomQFNeighbourShift: number;
static cAtomQFSmallRingSizeBits: number;
static cAtomQFSmallRingSizeShift: number;
static cAtomQFChargeBits: number;
static cAtomQFChargeShift: number;
static cAtomQFRxnParityBits: number;
static cAtomQFRxnParityShift: number;
static cAtomQFNewRingSizeBits: number;
static cAtomQFNewRingSizeShift: number;
static cAtomQFENeighbourBits: number;
static cAtomQFENeighbourShift: number;
static cAtomQFStereoStateBits: number;
static cAtomQFStereoStateShift: number;
static cAtomQFSimpleFeatures: number;
static cAtomQFNarrowing: number;
static cAtomQFAny: number;
static cAtomQFAromState: number;
static cAtomQFAromatic: number;
static cAtomQFNotAromatic: number;
static cAtomQFRingState: number;
static cAtomQFNotChain: number;
static cAtomQFNot2RingBonds: number;
static cAtomQFNot3RingBonds: number;
static cAtomQFNot4RingBonds: number;
static cAtomQFHydrogen: number;
static cAtomQFNot0Hydrogen: number;
static cAtomQFNot1Hydrogen: number;
static cAtomQFNot2Hydrogen: number;
static cAtomQFNot3Hydrogen: number;
static cAtomQFNoMoreNeighbours: number;
static cAtomQFMoreNeighbours: number;
static cAtomQFMatchStereo: number;
static cAtomQFPiElectrons: number;
static cAtomQFNot0PiElectrons: number;
static cAtomQFNot1PiElectron: number;
static cAtomQFNot2PiElectrons: number;
static cAtomQFNeighbours: number;
static cAtomQFNot0Neighbours: number;
static cAtomQFNot1Neighbour: number;
static cAtomQFNot2Neighbours: number;
static cAtomQFNot3Neighbours: number;
static cAtomQFNot4Neighbours: number;
static cAtomQFSmallRingSize: number;
static cAtomQFCharge: number;
static cAtomQFNotChargeNeg: number;
static cAtomQFNotCharge0: number;
static cAtomQFNotChargePos: number;
static cAtomQFFlatNitrogen: number;
static cAtomQFExcludeGroup: number;
static cAtomQFRxnParityHint: number;
static cAtomQFRxnParityRetain: number;
static cAtomQFRxnParityInvert: number;
static cAtomQFRxnParityRacemize: number;
static cAtomQFNewRingSize: number;
static cAtomQFRingSize0: number;
static cAtomQFRingSize3: number;
static cAtomQFRingSize4: number;
static cAtomQFRingSize5: number;
static cAtomQFRingSize6: number;
static cAtomQFRingSize7: number;
static cAtomQFRingSizeLarge: number;
static cAtomQFENeighbours: number;
static cAtomQFNot0ENeighbours: number;
static cAtomQFNot1ENeighbour: number;
static cAtomQFNot2ENeighbours: number;
static cAtomQFNot3ENeighbours: number;
static cAtomQFNot4ENeighbours: number;
static cAtomQFStereoState: number;
static cAtomQFIsStereo: number;
static cAtomQFIsNotStereo: number;
static cAtomQFHeteroAromatic: number;
static cBondTypeSingle: number;
static cBondTypeDouble: number;
static cBondTypeTriple: number;
static cBondTypeQuadruple: number;
static cBondTypeQuintuple: number;
static cBondTypeMetalLigand: number;
static cBondTypeDelocalized: number;
static cBondTypeDown: number;
static cBondTypeUp: number;
static cBondTypeCross: number;
static cBondTypeDeleted: number;
static cBondTypeIncreaseOrder: number;
static cBondTypeMaskSimple: number;
static cBondTypeMaskStereo: number;
static cBondFlagsHelper2: number;
static cBondFlagsHelper3: number;
static cBondParityNone: number;
static cBondParityEor1: number;
static cBondParityZor2: number;
static cBondParityUnknown: number;
static cBondCIPParityNone: number;
static cBondCIPParityEorP: number;
static cBondCIPParityZorM: number;
static cBondCIPParityProblem: number;
static cBondQFNoOfBits: number;
static cBondQFBondTypesBits: number;
static cBondQFBondTypesShift: number;
static cBondQFRareBondTypesBits: number;
static cBondQFRareBondTypesShift: number;
static cBondQFRingStateBits: number;
static cBondQFRingStateShift: number;
static cBondQFBridgeBits: number;
static cBondQFBridgeShift: number;
static cBondQFBridgeMinBits: number;
static cBondQFBridgeMinShift: number;
static cBondQFBridgeSpanBits: number;
static cBondQFBridgeSpanShift: number;
static cBondQFRingSizeBits: number;
static cBondQFRingSizeShift: number;
static cBondQFAromStateBits: number;
static cBondQFAromStateShift: number;
static cBondQFAllFeatures: number;
static cBondQFSimpleFeatures: number;
static cBondQFNarrowing: number;
static cBondQFBondTypes: number;
static cBondQFRareBondTypes: number;
/* @deprecated Use `cBondTypeSingle` instead */
static cBondQFSingle: number;
/* @deprecated Use `cBondTypeDouble` instead */
static cBondQFDouble: number;
/* @deprecated Use `cBondTypeTriple` instead */
static cBondQFTriple: number;
/* @deprecated Use `cBondTypeDelocalized` instead */
static cBondQFDelocalized: number;
/* @deprecated Use `cBondTypeMetalLigand` instead */
static cBondQFMetalLigand: number;
/* @deprecated Use `cBondTypeQuadruple` instead */
static cBondQFQuadruple: number;
/* @deprecated Use `cBondTypeQuintuple` instead */
static cBondQFQuintuple: number;
static cBondQFRingState: number;
static cBondQFNotRing: number;
static cBondQFRing: number;
static cBondQFBridge: number;
static cBondQFBridgeMin: number;
static cBondQFBridgeSpan: number;
static cBondQFRingSize: number;
static cBondQFMatchStereo: number;
static cBondQFAromState: number;
static cBondQFAromatic: number;
static cBondQFNotAromatic: number;
static cBondQFMatchFormalOrder: number;
static cHelperAll: number;
static cHelperNone: number;
static cHelperBitNeighbours: number;
static cHelperBitRingsSimple: number;
static cHelperBitRings: number;
static cHelperBitParities: number;
static cHelperBitCIP: number;
static cHelperBitSymmetrySimple: number;
static cHelperBitSymmetryStereoHeterotopicity: number;
static cHelperBitIncludeNitrogenParities: number;
static cHelperBitsStereo: number;
static cHelperNeighbours: number;
static cHelperRingsSimple: number;
static cHelperRings: number;
static cHelperParities: number;
static cHelperCIP: number;
static cHelperSymmetrySimple: number;
static cHelperSymmetryStereoHeterotopicity: number;
static cChiralityIsomerCountMask: number;
static cChiralityUnknown: number;
static cChiralityNotChiral: number;
static cChiralityMeso: number;
static cChiralityRacemic: number;
static cChiralityKnownEnantiomer: number;
static cChiralityUnknownEnantiomer: number;
static cChiralityEpimers: number;
static cChiralityDiastereomers: number;
static cDefaultAVBL: number;
static cMoleculeColorDefault: number;
static cMoleculeColorNeutral: number;
static cPseudoAtomsHydrogenIsotops: number;
static cPseudoAtomsRGroups: number;
static cPseudoAtomsAGroups: number;
static cPseudoAtomR: number;
static cPseudoAtomA: number;
static cPseudoAtomX: number;
static cPseudoAtomsAminoAcids: number;
static cPseudoAtomPolymer: number;
static cPseudoAtomAttachmentPoint: number;
static cPseudoAtomsAll: number;
static cDefaultAllowedPseudoAtoms: number;
static cAtomLabel: string[];
static cRoundedMass: number[];
static cDefaultAtomValence: number;
static cAtomValence: number[][];
static cCommonOxidationState: number[][];
static FISCHER_PROJECTION_LIMIT: number;
static FISCHER_PROJECTION_RING_LIMIT: number;
static STEREO_ANGLE_LIMIT: number;
static cMaxConnAtoms: number;
static VALIDATION_ERROR_ESR_CENTER_UNKNOWN: string;
static VALIDATION_ERROR_OVER_UNDER_SPECIFIED: string;
static VALIDATION_ERROR_AMBIGUOUS_CONFIGURATION: string;
static VALIDATION_ERRORS_STEREO: string[];
/**
* Parse the provided `smiles` and return a `Molecule`.
* By default, stereo features are parsed, which triggers itself a coordinate
* computation and coordinates are computed again after parsing to guarantee that
* they are always the same.
* If you do not need stereo features and want the fastest parsing, use this method
* with `{noCoordinates: true, noStereo: true}`.
* @param smiles
* @param options
*/
static fromSmiles(
smiles: string,
options?: MoleculeFromSmilesOptions,
): Molecule;
/**
* Parse the provided `molfile` and return a `Molecule`.
* @param molfile - MDL Molfile string in V2000 or V3000
*/
static fromMolfile(molfile: string): Molecule;
/**
* Parse the provided `molfile` and return an object with `Molecule` and map.
* @param molfile - MDL Molfile string in V2000 or V3000.
*/
static fromMolfileWithAtomMap(molfile: string): {
molecule: Molecule;
map: number[];
};
/**
* Parse the provided `idcode` and return a `Molecule`.
* @param idcode
* @param coordinates
*/
static fromIDCode(idcode: string, coordinates?: string): Molecule;
/**
* Parse the provided `idcode` and return a `Molecule`.
* @param idcode
* @param ensure2DCoordinates - boolean indicating if the 2D coordinates
* should be computed. Default: true.
*/
static fromIDCode(idcode: string, ensure2DCoordinates?: boolean): Molecule;
/**
* Tries to parse a molecule from arbitrary text, with the following algorithm:
* - If it contains V2000 or V3000, Molfile is assumed.
* - Try to parse as SMILES.
* - Try to parse as ID code.
* @param text - The text to parse.
* @returns A molecule or null if the text could not be parsed or would give an empty molecule.
*/
static fromText(text: string): Molecule | null;
static getAtomicNoFromLabel(
atomLabel: string,
allowedPseudoAtomGroups?: number,
): number;
static getAngle(x1: number, y1: number, x2: number, y2: number): number;
static getAngleDif(angle1: number, angle2: number): number;
static getDefaultAverageBondLength(): number;
/**
* When the molecule adds a new bond to a new atom or a new ring, then atoms are
* positioned such that the lengths of the new bonds are equal to the average
* length of existing bonds. If there are no existing bonds, then this default
* is used. If the default is not set by this function, then it is 24.
* @param defaultAVBL
*/
static setDefaultAverageBondLength(defaultAVBL: number): void;
static isAtomicNoElectronegative(atomicNo: number): boolean;
static isAtomicNoElectropositive(atomicNo: number): boolean;
/**
* Returns the OCL object.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getOCL(): any;
toSmiles(): string;
toSmarts(): string;
toIsomericSmiles(options?: SmilesGeneratorOptions): string;
/**
* Returns a MDL Molfile V2000 string.
*/
toMolfile(): string;
/**
* Returns a MDL Molfile V3000 string.
*/
toMolfileV3(): string;
/**
* Returns an SVG string representing the structure in two dimensions.
* @param width
* @param height
* @param id - Id attribute of the resulting svg element. Defaults to "id"
* followed by an automatically incremented number.
* @param options
*/
toSVG(
width: number,
height: number,
id?: string,
options?: MoleculeToSVGOptions,
): string;
/**
* Get an ID code for the molecule
* @param flag
*/
getCanonizedIDCode(flag: number): string;
/**
* Returns the canonic numbering of the atoms.
*/
getFinalRanks(flag: number): number[];
/**
* Returns an object with both the ID code and coordinates of the molecule.
*/
getIDCodeAndCoordinates(): { idCode: string; coordinates: string };
getMolecularFormula(): MolecularFormula;
/**
* Returns the `int[]` index array that can be used for substructure search.
*/
getIndex(): number[];
/**
* Compute and set atom coordinates for this molecule.
*/
inventCoordinates(): void;
/**
* Expand and find a position for all the hydrogens of the 2D molecule. If
* `atomNumber` is specified, the function only applies for the hydrogens of
* the given atom.
*/
addImplicitHydrogens(atomNumber?: number): void;
/**
* Returns the count of hydrogens in the molecule.
*/
getNumberOfHydrogens(): number;
/**
* Returns the diastereotopic Ids of all the atoms in the molecule.
*/
getDiastereotopicAtomIDs(): string[];
addMissingChirality(esrType?: number): void;
/**
* This function returns an array of HOSE(Hierarchical Organisation of
* Spherical Environments) codes represented as diastereotopic actelion IDs.
* @param options
*/
getHoseCodes(options?: HoseCodesOptions): string[][];
getRingSet(): RingCollection;
/**
* Returns the rectangle that bounds the molecule.
*/
getBounds(): Rectangle;
addAtom(atomicNo: number): number;
/**
* Suggests either cBondTypeSingle or cBondTypeMetalLigand whatever seems more
* appropriate for a new bond between the two atoms.
* @param atom1
* @param atom2
*/
suggestBondType(atom1: number, atom2: number): number;
/**
* Adds a single or metal bond between the two atoms depending on whether one
* of them is a metal atom.
* @param atom1
* @param atom2
*/
addBond(atom1: number, atom2: number): number;
addOrChangeAtom(
x: number,
y: number,
atomicNo: number,
mass: number,
abnormalValence: number,
radical: number,
customLabel: string,
): boolean;
addOrChangeBond(atm1: number, atm2: number, type: number): number;
addRing(
x: number,
y: number,
ringSize: number,
aromatic: boolean,
bondLength: number,
): boolean;
addRingToAtom(
atom: number,
ringSize: number,
aromatic: boolean,
bondLength: number,
): boolean;
addRingToBond(
bond: number,
ringSize: number,
aromatic: boolean,
bondLength: number,
): boolean;
changeAtom(
atom: number,
atomicNo: number,
mass: number,
abnormalValence: number,
radical: number,
): boolean;
changeAtomCharge(atom: number, positive: boolean): boolean;
changeBond(bnd: number, type: number): boolean;
/**
* Copies all atoms and bonds of mol to the end of this Molecule's atom and bond
* tables. If mol is a fragment then this Molecule's fragment flag is set to
* true and all query features of mol are also copied.
* @param mol
* @returns Atom mapping from original mol to this molecule after incorporation of mol.
*/
addMolecule(mol: Molecule): number[];
/**
* Adds and connects the substituent molecule to the connectionAtom of this molecule.
* Substituent atoms with atomicNo=0 are not copied and considered to represent the connectionAtom.
* Bonds leading to them, however, are copied and connected to the connectionAtom.
* High level function for constructing a molecule.
* @param substituent
* @param connectionAtom
* @return atom mapping from substituent to this molecule after addition of substituent
*/
addSubstituent(substituent: Molecule, connectionAtom: number): number[];
/**
* Copies this molecule including parity settings, if valid. The original
* content of destMol is replaced. Helper arrays are not copied and need to be
* recalculated if needed.
* @param destMol
*/
copyMolecule(destMol: Molecule): void;
/**
* Creates a new atom in destMol and copies all source atom properties including
* atom list, custom label, flags, and mapNo to it.
* @param destMol
* @param sourceAtom
* @param esrGroupOffsetAND - -1 to create new ESR group or destMol ESR group
* count from esrGroupCountAND()
* @param esrGroupOffsetOR - -1 to create new ESR group or destMol ESR group
* count from esrGroupCountOR()
* @returns Index of new atom in destMol.
*/
copyAtom(
destMol: Molecule,
sourceAtom: number,
esrGroupOffsetAND: number,
esrGroupOffsetOR: number,
): number;
/**
*
* @param destMol
* @param sourceBond
* @param esrGroupOffsetAND - -1 to create new ESR group or destMol ESR group
* count from esrGroupCountAND()
* @param esrGroupOffsetOR - -1 to create new ESR group or destMol ESR group
* count from esrGroupCountOR()
*/
copyBond(
destMol: Molecule,
sourceBond: number,
esrGroupOffsetAND: number,
esrGroupOffsetOR: number,
): number;
/**
* Copies name,isFragment,chirality and validity of parity & CIP flags. When
* copying molecules parts only or when changing the atom order during copy,
* then atom parities or CIP parities may not be valid anymore and
* invalidateHelperArrays([affected bits]) should be called in these cases.
* @param destMol
*/
copyMoleculeProperties(destMol: Molecule): void;
/**
* Clears helperBits from mValidHelperArrays.
* @param helperBits
*/
invalidateHelperArrays(helperBits: number): void;
/**
* For the given ESR type (AND or OR) renumbers all group indexes starting from
* 0. Use this, if stereo center deletion or other operations caused an
* inconsisten ESR number state. Molecule and derived methods do this
* automatically.
* @param type - cESRTypeAnd or cESRTypeOr
* @returns number of ESR groups
*/
renumberESRGroups(type: number): number;
/**
* Swaps two atoms' indexes/locations in the atom table.
* @param atom1
* @param atom2
*/
swapAtoms(atom1: number, atom2: number): void;
/**
* Swaps two bonds' indexes/locations in the atom table.
* @param bond1
* @param bond2
*/
swapBonds(bond1: number, bond2: number): void;
/**
* After the deletion the original order of atom and bond indexes is retained.
* @param atom
*/
deleteAtom(atom: number): void;
deleteAtomOrBond(x: number, y: number): boolean;
/**
* After the deletion the original order of atom and bond indexes is retained.
* @param bond
*/
deleteBond(bond: number): void;
/**
* After the deletion the original order of atom and bond indexes is retained.
* @param bond
*/
deleteBondAndSurrounding(bond: number): void;
/**
* After the deletion the original order of atom and bond indexes is retained.
* @param atomList
*/
deleteAtoms(atomList: number[]): number[];
/**
* Delete all selected atoms
* and all bonds attached to them. After the deletion the original order of atom
* and bond indexes is retained.
*/
deleteSelectedAtoms(): boolean;
/**
* Marks this atom to be deleted in a later call to deleteMarkedAtomsAndBonds().
* @param atom
*/
markAtomForDeletion(atom: number): void;
/**
* Marks this bond to be deleted in a later call to deleteMarkedAtomsAndBonds().
* @param bond
*/
markBondForDeletion(bond: number): void;
/**
* Checks whether this atom was marked to be deleted and not deleted yet.
* @param atom
*/
isAtomMarkedForDeletion(atom: number): boolean;
/**
* Checks whether this bond was marked to be deleted and not deleted yet.
* @param bond
*/
isBondMarkedForDeletion(bond: number): boolean;
/**
* Deletes all atoms and bonds
* from the molecule, which were marked before for deletion by calling
* markAtomForDeletion() or markBondForDeletion(). Bonds connecting atoms of
* which at least one is marked for deletion, are deleted automatically and
* don't require to be explicitly marked.<br>
* When multiple atoms and/or bonds need to be deleted, marking them and calling
* this method is more efficient than deleting them individually with
* deleteAtom() and deleteBond(). Bonds, whose atoms carry opposite charges are
* treated in the following manner: If only one of the two bond atoms is kept,
* then its absolute charge will be reduced by 1. After the deletion the
* original order of atom and bond indexes is retained.
* @returns mapping from old to new atom indices; null if no atoms nor bonds were deleted.
*/
deleteMarkedAtomsAndBonds(): number[];
/**
* @deprecated Use clear() instead of this method.
*/
deleteMolecule(): void;
/**
* Empties the molecule to serve as container for constructing a new molecule,
* e.g. by multiply calling addAtom(...), addBond(...) and other high level methods.
*/
clear(): void;
removeAtomSelection(): void;
removeAtomColors(): void;
removeAtomCustomLabels(): void;
removeAtomMarkers(): void;
removeBondHiliting(): void;
/**
*
* @param pickx
* @param picky
* @returns index of closest of nearby atoms or -1, if no atom is close.
*/
findAtom(pickx: number, picky: number): number;
/**
*
* @param pickx
* @param picky
* @returns index of closest of nearby bonds or -1, if no bond is close.
*/
findBond(pickx: number, picky: number): number;
/**
* @returns the number of all atoms, which includes hydrogen atoms.
*/
getAllAtoms(): number;
/**
* @returns the number of all bonds, which includes those connecting hydrogen atoms.
*/
getAllBonds(): number;
/**
* Get an atom's defined maximum valance if different from the default one.
* @param atom
* @returns valence 0-14: new maximum valence; -1: use default
*/
getAtomAbnormalValence(atom: number): number;
/**
*
* @param atom
* @returns The formal atom charge.
*/
getAtomCharge(atom: number): number;
/**
* The atom Cahn-Ingold-Prelog parity is a calculated property available
* above/equal helper level cHelperCIP. It encodes the stereo configuration of
* an atom with its neighbors using up/down-bonds or 3D-atom-coordinates,
* whatever is available. It depends on the atom indices of the neighbor atoms
* and their orientation is space. This method is called by the Canonizer and
* usually should not be called otherwise.
* @param atom
* @returns one of
* cAtomCIPParityNone,cAtomCIPParityRorM,cAtomCIPParitySorP,cAtomCIPParityProblem
*/
getAtomCIPParity(atom: number): number;
getAtomColor(atom: number): number;
/**
* This is MDL's enhanced stereo representation (ESR). Stereo atoms and bonds
* with the same ESR type (AND or OR) and the same ESR group number are in the
* same group, i.e. within this group they have the defined (relative) stereo
* configuration.
* @param atom
* @returns group index starting with 0
*/
getAtomESRGroup(atom: number): number;
/**
* This is MDL's enhanced stereo representation (ESR). Stereo atoms and bonds
* with the same ESR type (AND or OR) and the same ESR group number are in the
* same group, i.e. within this group they have the defined (relative) stereo
* configuration.
* @param atom
* @returns one of cESRTypeAbs,cESRTypeAnd,cESRTypeOr
*/
getAtomESRType(atom: number): number;
/**
* In addition to the natural atomic numbers, we support additional pseudo
* atomic numbers. Most of these are for compatibility with the MDL atom table,
* e.g. for amino acids and R-groups. D and T are accepted for setting, but are
* on-the-fly translated to H with the proper atom mass.
* @param atom
*/
getAtomicNo(atom: number): number;
/**
* If a custom atom label is set, a molecule depiction displays the custom label
* instead of the original one.
* @param atom
* @returns null or previously defined atom custom label
*/
getAtomCustomLabel(atom: number): string;
/**
*
* @param atom
* @returns standard atom label of the atom: C,Li,Sc,...
*/
getAtomLabel(atom: number): string;
/**
* Get the atomic query features as an object
* @param atom
*/
getAtomQueryFeaturesObject(atom: number): AtomQueryFeatures;
/**
* Get the bond query features as an object
* @param bond
*/
getBondQueryFeaturesObject(bond: number): BondQueryFeatures;
/**
* The list of atoms that are allowed at this position during sub-structure
* search. (or refused atoms, if atom query feature cAtomQFAny is set).
* @param atom
* @returns null or sorted list of unique atomic numbers, if defined.
*/
getAtomList(atom: number): number[];
getAtomListString(atom: number): string;
/**
* Returns an atom mapping number within the context of a reaction. Atoms that
* that share the same mapping number on the reactant and product side are
* considered to be the same atom.
* @param atom
*/
getAtomMapNo(atom: number): number;
/**
*
* @param atom
* @returns atom mass, if is specific isotop, otherwise 0 for natural abundance
*/
getAtomMass(atom: number): number;
/**
* The atom parity is a calculated property available above/equal helper level
* cHelperParities. It describes the stereo configuration of a chiral atom and
* is calculated either from 2D-atom-coordinates and up/down-bonds or from
* 3D-atom-coordinates, whatever is available. It depends on the atom indexes of
* the neighbor atoms and their orientation in space.<br>
* The parity is defined as follows: Look at the chiral atom such that its
* neighbor atom with the highest atom index (or the hydrogen atom if it is
* implicit) is oriented to the back. If the remaining three neighbors are in
* clockwise order (considering ascending atom indexes) than the parity is 1. If
* they are in anti-clockwise order, then the parity is 2.<br>
* For linear chirality (allenes): Look along the straight line of double bonds
* such that the rear neighbor with the lower atom index points to the top. If
* the front neighbor with the lower atom index points to the right than the
* parity is 1.<br>
* @param atom
* @returns one of cAtomParity1,cAtomParity2,cAtomParityNone,cAtomParityUnknown
*/
getAtomParity(atom: number): number;
/**
* Returns all set query features for this atom. In order to get all features
* related to a certain subject use something like this:
* <i>getAtomQueryFeatures() & cAtomQFHydrogen</i>
* @param atom
*/
// getAtomQueryFeatures(atom: number): number;
/**
* Gets an atom's radical state as singulet,dublet,triplet or none
* @param atom
* @returns one of
* cAtomRadicalStateNone,cAtomRadicalStateS,cAtomRadicalStateD,cAtomRadicalStateT
*/
getAtomRadical(atom: number): number;
getAtomX(atom: number): number;
getAtomY(atom: number): number;
getAtomZ(atom: number): number;
getBondAngle(atom1: number, atom2: number): number;
/**
* Calculates a signed torsion as an exterior spherical angle from a valid
* 4-atom strand. Looking along the central bond, the torsion angle is 0.0, if
* the projection of front and rear bonds point in the same direction. If the
* front bond is rotated in the clockwise direction, the angle increases, i.e.
* has a positive value. http://en.wikipedia.org/wiki/Dihedral_angle
* @param atom 4 valid atom indices defining a connected atom sequence
* @returns torsion in the range: -pi <= torsion <= pi
*/
calculateTorsion(atom: number[]): number;
/**
*
* @param no - 0 or 1
* @param bond
* @returns atom index
*/
getBondAtom(no: 0 | 1, bond: number): number;
/**
* The bond Cahn-Ingold-Prelog parity is a calculated property available
* above/equal helper level cHelperCIP. It encodes the stereo configuration of a
* bond with its neighbors using 2D-coordinates and up/down-bonds or
* 3D-atom-coordinates, whatever is available. It depends on the atom indices of
* the neighbor atoms and their orientation is space. This method is called by
* the Canonizer and usually should not be called otherwise. Considered are
* E/Z-double bonds and M/P-BINAP type single bonds.
* @param bond
* @returns one of
* cBondCIPParityNone,cBondCIPParityEorP,cBondCIPParityZorM,cBondCIPParityProblem
*/
getBondCIPParity(bond: number): number;
/**
* This is MDL's enhanced stereo representation (ESR). Stereo atoms and bonds
* with the same ESR type (AND or OR) and the same ESR group number are in the
* same group, i.e. within this group they have the defined (relative) stereo
* configuration.
* @param bond
* @returns group index starting with 0
*/
getBondESRGroup(bond: number): number;
/**
* This is MDL's enhanced stereo representation (ESR). Stereo atoms and bonds
* with the same ESR type (AND or OR) and the same ESR group number are in the
* same group, i.e. within this group they have the defined (relative) stereo
* configuration.
* @param bond
* @returns one of cESRTypeAbs,cESRTypeAnd,cESRTypeOr
*/
getBondESRType(bond: number): number;
/**
*
* @param bond
* @returns bond length calculated from atom 2D-coordinates.
*/
getBondLength(bond: number): number;
/**
* Returns the formal bond order. Delocalized rings have alternating single and double
* bonds, which are returned as such. Bonds that are explicitly marked as being delocalized
* are returned as 1. Dative bonds are returned as 0.
* @param bond
* @return formal bond order 0 (dative bonds), 1, 2, or 3
*/
getBondOrder(bond: number): number;
/**
* Returns the pre-calculated bond parity, e.g. cBondParityEor1. To distinguish
* double bond parities (E/Z) from parities of axial chirality, e.g. BINAP type
* (1/2) simply check with getBondOrder(bond): If the order is 2, then the
* parity describes E/Z, otherwise an axial parity.
* @param bond
* @return one of cBondParity???
*/
getBondParity(bond: number): number;
getBondQueryFeatures(bond: number): number;
isBondBridge(bond: number): boolean;
getBondBridgeMinSize(bond: number): number;
getBondBridgeMaxSize(bond: number): number;
/**
* Returns bond type combining bond order and stereo orientation.
* @param bond
* @returns one of cBondTypeSingle,cBondTypeDouble,cBondTypeUp,cBondTypeCross,...
*/
getBondType(bond: number): number;
/**
* This is the bond type without stereo information.
* @param bond
* @returns cBondTypeSingle,cBondTypeDouble,cBondTypeTriple,cBondTypeDelocalized
*/
getBondTypeSimple(bond: number): number;
/**
* Gets the overall chirality of the molecule, which is a calculated information
* considering: Recognition of stereo centers and stereo bonds, defined ESR
* features, meso detection. The chirality combines the knowledge about how many
* stereo isomers are represented, whether all of these are meso, whether we
* have one defined stereo isomer, a mixture of racemates, epimers, or other
* diastereomers. The information is used during depiction.
*/
getChirality(): number;
/**
* The currently defined maximum of atoms, which increases automatically when
* using high level construction methods and new atoms exceed the current
* maximum.
*/
getMaxAtoms(): number;
/**
* Usually called automatically and hardly needed to be called.
* @param v
*/
setMaxAtoms(v: number): void;
/**
* The currently defined maximum of bonds, which increases automatically when
* using high level construction methods and new bonds exceed the current
* maximum.
*/
getMaxBonds(): number;
/**
* Usually called automatically and hardly needed to be called.
* @param v
*/
setMaxBonds(v: number): void;
/**
* cMoleculeColorDefault: atom coloring depends on atomic number. Carbon and
* hydrogen are drawn in neutral color<br>
* cMoleculeColorNeutral: all atoms and bonds and CIP letters are drawn in
* neutral color<br>
* @returns cMoleculeColorNeutral or cMoleculeColorDefault. In future may also
* return ARGB values.
*/
getMoleculeColor(): number;
/**
* Currently, this method only allows to switch the default atomic number
* dependent atom coloring off by passing cMoleculeColorNeutral. In future
* updates it may also accept ARGB values.
* @param color currently supported values: cMoleculeColorDefault,
* cMoleculeColorNeutral
*/
setMoleculeColor(color: number): void;
/**
* Allows to set a molecule name or identifier, that is, for instance, written
* to or read from molfiles.
*/
getName(): string;
/**
* The stereo problem flag is set by the stereo recognition (available
* equal/above helper level cHelperParities) if an atom has over- or
* under-specified stereo bonds attached, i.e. a stereo center with less or more
* than one up/down-bond, an non-stereo-center atom carrying (a) stereo bond(s),
* or a stereo center with neighbors coordinates such that the stereo
* configuration cannot be deduced. This flag is used by the depiction and
* causes affected atoms to be drawn in margenta.
* @param atom
*/
getStereoProblem(atom: number): boolean;
/**
*
* @param atom
* @returns whether the atom's stereo configuration was explicitly declared
* unknown
*/
isAtomConfigurationUnknown(atom: number): boolean;
/**
* Pseudo paries are parities that indicate a relative configuration. It always
* needs at least 2 pseudo parities (atom or bond) within a part of a molecule
* to be meaningful. This information is calculated by
* ensureHelperArrays(Molecule.cHelperCIP). Molecules extracted from IDCode
* don't know about pseudo parities.
* @param atom
* @returns whether this atom's parity is a relative configuration
*/
isAtomParityPseudo(atom: number): boolean;
/**
* Atoms with pseudo parities are not considered stereo centers. While parities
* are canonized and always refer to the full set of molecules (in case ESR
* groups are defined), this method returns true if this atom is a stereo center
* in any(!) of the individual molecules described by the ESR settings.
* @param atom
* @returns true if atom is stereo center in at least one molecule after ESR
* resolution
*/
isAtomStereoCenter(atom: number): boolean;
isBondParityPseudo(bond: number): boolean;
/**
* This hint/flag is set by CoordinateInventor for double bonds without given
* EZ-parity, because the new coordinates may imply a not intended EZ-parity. If
* parities are calculated later by the Canonizer is can correctly assign
* cBondParityUnknown if the bond is a stereo bond. The setBondParity() method
* clears this flag. This method usually should not be called for other
* purposes.
* @param bond
* @returns whether the bond parity was unknown when 2D- atom coordinates were
* created
*/
isBondParityUnknownOrNone(bond: number): boolean;
/**
* Molecule objects may represent complete molecules or sub-structure fragments,
* depending on, whether they are flagges as being a fragment or not. Both
* representations have much in common, but in certain aspects behave
* differently. Thus, complete molecules are considered to carry implicit
* hydrogens to fill unoccupied atom valences. Sub-structure fragments on the
* other hand may carry atom or bond query features. Depiction, sub-structure
* search, and other algorithms treat fragments and complete molecules
* differerently.
*/
isFragment(): boolean;
/**
* @return true if at least one z-coordinate is different from 0.0
*/
is3D(): boolean;
/**
*
* @param atom
* @returns whether the atom has the natural isotop distribution
*/
isNaturalAbundanc(atom: number): boolean;
/**
* @returns true if atom is one of H,B,C,N,O,F,Si,P,S,Cl,As,Se,Br,Te,I
*/
isPurelyOrganic(): boolean;
isSelectedAtom(atom: number): boolean;
/**
* Atom marking may be used for any external purpose
* @param atom
*/
isMarkedAtom(atom: number): boolean;
/**
* Used for depiction only.
* @param bond
*/
isBondBackgroundHilited(bond: number): boolean;
/**
* Used for depiction only.
* @param bond
*/
isBondForegroundHilited(bond: number): boolean;
isSelectedBond(bond: number): boolean;
isAutoMappedAtom(atom: number): boolean;
/**
* Checks whether bond is drawn as up/down single bond
* @param bond
* @returns true if bond is a stereo bond
*/
isStereoBond(bond: number): boolean;
/**
* Low level method for constructing/modifying a molecule from scratch. Use
* setAtomicNo(), possibly setAtomX(), setAtomY() and other setAtomXXX() methods
* for new atoms.
* @param no
*/
setAllAtoms(no: number): void;
/**
* Low level method for constructing/modifying a molecule from scratch. Use
* setBondType() and setBondAtom() if you increase the number of bonds with this
* method.
* @param no
*/
setAllBonds(no: number): void;
/**
* Set an atom's maximum valance to be different from the default one. If a
* carbon atom's valence is set to -1,0 or 4 its radical state is removed. If a
* carbon atom's valence is set to 2, a singulet carbene state is assumed.
* @param atom
* @param valence 0-14: new maximum valence; -1: use default
*/
setAtomAbnormalValence(atom: number, valence: number): void;
setAtomCharge(atom: number, charge: number): void;
setAtomColor(atom: number, color: number): void;
/**
* This is a user applied information, rather than a calculated value. The
* stereo center configuration is declared to be unknown. If the atom is
* recognized a stereo center, then its parity will be cAtomParityUnknown.
* @param atom
* @param u
*/
setAtomConfigurationUnknown(atom: number, u: boolean): void;
setAtomSelection(atom: number, s: boolean): void;
/**
* Atom marking may be used for any external purpose.
* @param atom
* @param s
*/
setAtomMarker(atom: number, s: boolean): void;
/**
* Set an atom's atomic number and defines the isotop to be natural abundance.
* @param atom
* @param no
*/
setAtomicNo(atom: number, no: number): void;
/**
* Defines an atom list as query feature for substructure search
* @param atom
* @param list - is null or a sorted int[] of valid atomic numbers
* @param isExcludeList - true if atom is a wild card and list contains atoms to
* be excluded
*/
setAtomList(atom: number, list: number[], isExcludeList: boolean): void;
/**
* Defines an atom mapping number within the context of a reaction. Atoms that
* that share the same mapping number on the reactant and product side are
* considered to be the same atom.
* @param atom
* @param mapNo
* @param autoMapped
*/
setAtomMapNo(atom: number, mapNo: number, autoMapped?: boolean): void;
/**
* Set atom to specific isotop or to have a natural isotop distribution
* @param atom
* @param mass - rounded atom mass or 0 (default) for natural abundance
*/
setAtomMass(atom: number, mass: number): void;
/**
* The atom parity is a calculated property available above/equal helper level
* cHelperParities. It describes the stereo configuration of a chiral atom and
* is calculated either from 2D-atom-coordinates and up/down-bonds or from
* 3D-atom-coordinates, whatever is available. It depends on the atom indices of
* the neighbor atoms and their orientation in space.<br>
* The parity is defined as follows: Look at the chiral atom such that its
* neighbor atom with the highest atom index (or the hydrogen atom if it is
* implicit) is oriented to the back. If the remaining three neighbors are in
* clockwise order (considering ascending atom indexes) than the parity is 1. If
* they are in anti-clockwise order, then the parity is 2.<br>
* For linear chirality (allenes): Look along the straight line of double bonds
* such that the rear neighbor with the lower atom index points to the top. If
* the front neighbor with the lower atom index points to the right than the
* parity is 1.<br>
* This method is called by the Canonizer and usually should not be called
* otherwise.
* @param atom
* @param parity - one of
* cAtomParity1,cAtomParity2,cAtomParityNone,cAtomParityUnknown
* @param isPseudo - true if the configuration is only meaningful relative to
* another one
*/
setAtomParity(atom: number, parity: number, isPseudo: boolean): void;
/**
* Introduce or remove an atom query feature and make sure, the molecule is
* flagged to be a sub-structure fragment (see setFragment()). A query feature
* is usually a flag, which if set, poses an additional atom/bond matching
* constraint for the sub-structure search and, thus, reduces the number of
* matching atoms and therefore also the number of molecules found. Often
* multiple query feature flags are related and grouped, e.g. to define the
* number of hydrogens atoms. These are the flags related to hydrogen
* neighbors:<br>
* <br>
* public static final int cAtomQFHydrogen = 0x00000780;<br>
* public static final int cAtomQFNot0Hydrogen = 0x00000080;<br>
* public static final int cAtomQFNot1Hydrogen = 0x00000100;<br>
* public static final int cAtomQFNot2Hydrogen = 0x00000200;<br>
* public static final int cAtomQFNot3Hydrogen = 0x00000400;<br>
* <p>
* An inverse logic needs to be applied to translate a user request to the bits
* needed. For example, to only accept atoms that have 1 or 2 hydrogen
* neighbors, we need to filter out all others. Thus, we would call<br>
* setAtomQueryFeature(atom, cAtomQFNot0Hydrogen | cAtomQFNot3Hydrogen, true);
* </p>
* <p>
* To match only atoms without hydrogen neighbors, call<br>
* setAtomQueryFeature(atom, cAtomQFHydrogen & ~cAtomQFNot3Hydrogen, true);<br>
* This mechanism allows a very efficient atom matching and therefore very fast
* sub-structure search.
* </p>
* @param atom
* @param feature - one of cAtomQF... Because of long it could be an internal object
* @param value - if true, the feature is set, otherwise it is removed
*/
setAtomQueryFeature(atom: number, feature: number, value: boolean): void;
/**
* Sets an atom's radical state as singulet,dublet,triplet or none
* @param atom
* @param radical - one of
* cAtomRadicalStateNone,cAtomRadicalStateS,cAtomRadicalStateD,cAtomRadicalStateT
*/
setAtomRadical(atom: number, radical: number): void;
/**
* The atom Cahn-Ingold-Prelog parity is a calculated property available
* above/equal helper level cHelperCIP. It encodes the stereo configuration of
* an atom with its neighbors using up/down-bonds or 3D-atom-coordinates,
* whatever is available. It depends on the atom indices of the neighbor atoms
* and their orientation is space. This method is called by the Canonizer and
* usually should not be called otherwise.
* @param atom
* @param parity - one of
* cAtomCIPParityRorM,cAtomCIPParitySorP,cAtomCIPParityProblem
*/
setAtomCIPParity(atom: number, parity: number): void;
setAtomX(atom: number, x: number): void;
setAtomY(atom: number, y: number): void;
setAtomZ(atom: number, z: number): void;
setBondAtom(no: number, bond: number, atom: number): void;
/**
* The bond Cahn-Ingold-Prelog parity is a calculated property available
* above/equal helper level cHelperCIP. It encodes the stereo configuration of a
* bond with its neighbors using 2D-coordinates and up/down-bonds or
* 3D-atom-coordinates, whatever is available. It depends on the atom indices of
* the neighbor atoms and their orientation is space. This method is called by
* the Canonizer and usually should not be called otherwise. Considered are
* E/Z-double bonds and M/P-BINAP type single bonds.
* @param bond
* @param parity - one of
* cBondCIPParityEorP,cBondCIPParityZorM,cBondCIPParityP