Skip to content

Commit

Permalink
Merge pull request #1784 from epam/#1782-Add_Layout_Method_to_Ketcher…
Browse files Browse the repository at this point in the history
…_API

#1782 add layout method to ketcher api
  • Loading branch information
evgeniiFrolov1 authored Oct 28, 2022
2 parents 87765b6 + 37ddd9a commit cce0afe
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/ketcher-core/docs/classes/Ketcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
### Methods

- [addFragment](Ketcher.md#addfragment)
- [layout](Ketcher.md#layout)
- [containsReaction](Ketcher.md#containsreaction)
- [generateImage](Ketcher.md#generateimage)
- [generateInchIKey](Ketcher.md#generateinchikey)
Expand Down Expand Up @@ -144,6 +145,20 @@ ___

___

### layout

**layout**(): `Promise`<`void`\>

#### Returns

`Promise`<`void`\>

#### Defined in

[packages/ketcher-core/src/application/ketcher.ts:198](https://github.com/epam/ketcher/blob/bf065756/packages/ketcher-core/src/application/ketcher.ts#L198)

___

### containsReaction

**containsReaction**(): `boolean`
Expand Down
10 changes: 9 additions & 1 deletion packages/ketcher-core/src/application/ketcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { GenerateImageOptions, StructService } from 'domain/services'

import { Editor } from './editor'
import { Indigo } from 'application/indigo'
import { MolfileFormat } from 'domain/serializers'
import { KetSerializer, MolfileFormat } from 'domain/serializers'
import { Struct } from 'domain/entities'
import assert from 'assert'
import { EventEmitter } from 'events'
Expand Down Expand Up @@ -234,6 +234,14 @@ export class Ketcher {
}, this.eventBus)
}

async layout(): Promise<void> {
runAsyncAction<void>(async () => {
const struct = await this.#indigo.layout(this.#editor.struct())
const ketSerializer = new KetSerializer()
this.setMolecule(ketSerializer.serialize(struct))
}, this.eventBus)
}

recognize(image: Blob, version?: string): Promise<Struct> {
return this.#indigo.recognize(image, { version: version })
}
Expand Down

0 comments on commit cce0afe

Please sign in to comment.