Skip to content

Commit

Permalink
#920 Support CDXML (#931)
Browse files Browse the repository at this point in the history
* Add new format support

* Update standalone library

* Add options to formats

* Remove rescale from options, set rescale forever

Co-authored-by: Kirill Kapytov <Kirill_Kapytov@epam.com>
  • Loading branch information
r1z3rISGOD and Kirill Kapytov authored Nov 12, 2021
1 parent 2c140dc commit 981fdfc
Show file tree
Hide file tree
Showing 9 changed files with 1,344 additions and 1,239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class FormatterFactory {
case 'rxnV3000':
case 'smilesExt':
case 'smarts':
case 'cdxml':
default:
formatter = new ServerFormatter(
this.structService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ const formatProperties: FormatPropertiesMap = {
),
graph: new SupportedFormatProperties('Graph Format', ChemicalMimeType.KET, [
'.ket'
])
]),
cdxml: new SupportedFormatProperties(
'CDXML',
ChemicalMimeType.CDXML,
['.cdxml'],
true
)
}

function getPropertiesByFormat(format: SupportedFormat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export function identifyStructFormat(
return 'smiles'
}

if (sanitizedString.indexOf('<CDXML') !== -1) {
return 'cdxml'
}
// Molfile by default as Indigo does
return 'mol'
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type SupportedFormat =
| 'inChIAuxInfo'
| 'cml'
| 'graph'
| 'cdxml'

export type FormatterFactoryOptions = Partial<
MolSerializerOptions & StructServiceOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum ChemicalMimeType {
DaylightSmarts = 'chemical/x-daylight-smarts',
InChI = 'chemical/x-inchi',
InChIAuxInfo = 'chemical/x-inchi-aux',
CDXML = 'chemical/x-cdxml',
CML = 'chemical/x-cml',
KET = 'application/json'
}
Expand Down
6 changes: 3 additions & 3 deletions packages/ketcher-react/src/script/ui/state/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function load(struct, options) {

return parseStruct(struct, server, options).then(
struct => {
const { rescale, fragment } = options
const { fragment } = options

if (struct.sgroups.some(sGroup => !supportedSGroupTypes[sGroup.type])) {
const isConfirmed = window.confirm(
Expand All @@ -73,9 +73,9 @@ export function load(struct, options) {
)
}

if (rescale && editor.struct().atoms.size) {
struct.rescale() // TODO: move out parsing?
struct.rescale() // TODO: move out parsing?

if (editor.struct().atoms.size) {
//NB: reset id
const oldStruct = editor.struct().clone()

Expand Down
Loading

0 comments on commit 981fdfc

Please sign in to comment.