Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/Chem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@types/pako": "^2.0.3",
"@webgpu/types": "^0.1.40",
"cash-dom": "^8.1.5",
"datagrok-api": "^1.27.2",
"datagrok-api": "../../js-api",
"dayjs": "^1.11.13",
"file-loader": "^6.2.0",
"js-yaml": "^4.1.1",
Expand Down
17 changes: 9 additions & 8 deletions packages/Chem/src/open-chem/ocl-sketcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,48 +60,49 @@ export class OpenChemLibSketcher extends grok.chem.SketcherBase {
}

get smiles() {
if (this.explicitMol?.notation === 'smiles')
if (this.explicitMol?.notation === DG.chem.Notation.Smiles)
return this.explicitMol.value;
return this._sketcher ? this._sketcher.getSmiles() : '';
}

set smiles(s) {
this.explicitMol = {notation: 'smiles', value: s};
this.explicitMol = {notation: DG.chem.Notation.Smiles, value: s};
this.importing = true;
this._sketcher?.setSmiles(s);
}

get molFile() {
if (this.explicitMol?.notation === 'molblock')
if (this.explicitMol?.notation === DG.chem.Notation.MolBlock)
return this.explicitMol.value;
return this._sketcher ? this._sketcher.getMolFile() : '';
}

set molFile(s) {
this.explicitMol = {notation: 'molblock', value: s};
this.explicitMol = {notation: DG.chem.Notation.MolBlock, value: s};
this.importing = true;
this._sketcher?.setMolFile(s);
}

get molV3000() {
if (this.explicitMol?.notation === 'molblockV3000')
if (this.explicitMol?.notation === DG.chem.Notation.V3KMolBlock)
return this.explicitMol.value;
return this._sketcher ? this._sketcher.getMolFileV3() : '';
}

set molV3000(s) {
this.explicitMol = {notation: 'molblockV3000', value: s};
this.explicitMol = {notation: DG.chem.Notation.V3KMolBlock, value: s};
this.importing = true;
this._sketcher?.setMolFile(s);
}

async getSmarts(): Promise<string> {
if (this.explicitMol?.notation === DG.chem.Notation.Smarts)
return this.explicitMol.value;
return PackageFunctions.convertMolNotation(this.molFile, DG.chem.Notation.MolBlock, DG.chem.Notation.Smarts);
}

set smarts(s: string) {
//@ts-ignore
this.explicitMol = {notation: 'smarts', value: s};
this.explicitMol = {notation: DG.chem.Notation.Smarts, value: s};
this.importing = true;
this.convertAndSetSmarts(s);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/KetcherSketcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@datagrok-libraries/utils": "^4.6.5",
"@types/react-dom": "^18.2.0",
"datagrok-api": "^1.27.0",
"datagrok-api": "../../js-api",
"file-loader": "^6.2.0",
"ketcher-core": "^3.12.0",
"ketcher-react": "^3.12.0",
Expand Down
17 changes: 8 additions & 9 deletions packages/KetcherSketcher/src/ketcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'ketcher-react/dist/index.css';
import '../css/editor.css';
import {KETCHER_MOLV2000, KETCHER_MOLV3000} from './constants';

type NotationKey = 'smiles' | 'molblock' | 'molblockV3000' | 'smarts';
type NotationKey = DG.chem.Notation.Smiles | DG.chem.Notation.MolBlock | DG.chem.Notation.V3KMolBlock | DG.chem.Notation.Smarts;

export class KetcherSketcher extends grok.chem.SketcherBase {
_smiles: string | null = null;
Expand Down Expand Up @@ -141,7 +141,7 @@ export class KetcherSketcher extends grok.chem.SketcherBase {
}

get smiles() {
if (this.explicitMol?.notation === 'smiles')
if (this.explicitMol?.notation === DG.chem.Notation.Smiles)
return this.explicitMol.value;
if (this._smiles !== null)
return this._smiles;
Expand All @@ -162,11 +162,11 @@ export class KetcherSketcher extends grok.chem.SketcherBase {
this._molV3000 = null;
this._smarts = null;
this.importedMoleculesCounter++;
this._setNotation('smiles', smiles);
this._setNotation(DG.chem.Notation.Smiles, smiles);
}

get molFile() {
if (this.explicitMol?.notation === 'molblock')
if (this.explicitMol?.notation === DG.chem.Notation.MolBlock)
return this.explicitMol.value;
if (this._molV2000 !== null)
return this._molV2000;
Expand All @@ -185,11 +185,11 @@ export class KetcherSketcher extends grok.chem.SketcherBase {
this._molV3000 = null;
this._smarts = null;
this.importedMoleculesCounter++;
this._setNotation('molblock', molfile);
this._setNotation(DG.chem.Notation.MolBlock, molfile);
}

get molV3000() {
if (this.explicitMol?.notation === 'molblockV3000')
if (this.explicitMol?.notation === DG.chem.Notation.V3KMolBlock)
return this.explicitMol.value;
if (this._molV3000 !== null)
return this._molV3000;
Expand All @@ -208,7 +208,7 @@ export class KetcherSketcher extends grok.chem.SketcherBase {
this._smiles = null;
this._smarts = null;
this.importedMoleculesCounter++;
this._setNotation('molblockV3000', molfile);
this._setNotation(DG.chem.Notation.V3KMolBlock, molfile);
}

async getSmarts(): Promise<string> {
Expand All @@ -223,7 +223,7 @@ export class KetcherSketcher extends grok.chem.SketcherBase {
this._molV2000 = null;
this._smiles = null;
this.importedMoleculesCounter++;
this._setNotation('smarts', smarts);
this._setNotation(DG.chem.Notation.Smarts, smarts);
}

get isInitialized() {
Expand Down Expand Up @@ -265,7 +265,6 @@ export class KetcherSketcher extends grok.chem.SketcherBase {
private _setNotation(notation: NotationKey, value: string): void {
this.updatingMolecule = true;
this.setKetcherMolecule(value);
//@ts-ignore
this.explicitMol = {notation, value};
}

Expand Down
Loading