Skip to content

Commit

Permalink
#6161 - Stereo flags are displayed despite enabling 'Ignore chiral fl…
Browse files Browse the repository at this point in the history
…ag' in MOL V2000 files (#6179)

- added ignoreChiralFlag parameter to be used in mol v2000 deserialization during setMolecule and openning files methods
- removed ignoreChiralFlag parameter from serialization
  • Loading branch information
rrodionov91 committed Dec 23, 2024
1 parent 0fb0c60 commit 2030475
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion documentation/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ In the _Stereochemistry tab_ in _Settings_ you can:

<img src=images/49_sett_stereon.png width = "440"/>

When option _Ignore the chiral flag_ is _true_ it will affect opening and saving of MDL V2000 and MDL V3000 files, as well as the display of labels at stereogenic centers and stereo flags:
When option _Ignore the chiral flag_ is _true_ it will affect opening of MDL V2000 and MDL V3000 files, as well as the display of labels at stereogenic centers and stereo flags:

- stereo flags are not displayed

Expand Down
2 changes: 1 addition & 1 deletion packages/ketcher-core/src/application/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function parseStruct(

const service = factory.create(format, {
'dearomatize-on-load': options['dearomatize-on-load'],
'ignore-no-chiral-flag': options.ignoreChiralFlag,
ignoreChiralFlag: options.ignoreChiralFlag,
});
return service.getStructureFromStringAsync(structStr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export class MolSerializer implements Serializer<Struct> {
this.options.ignoreErrors,
this.options.noRgroups,
this.options.preserveIndigoDesc,
this.options.ignoreChiralFlag,
);
}
}
11 changes: 5 additions & 6 deletions packages/ketcher-core/src/domain/serializers/mol/molfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ export class Molfile {
skipSGroupErrors: boolean,
norgroups?: boolean,
preserveIndigoDesc?: boolean,
ignoreChiralFlag?: boolean,
) {
// eslint-disable-line max-statements
/* saver */
Expand Down Expand Up @@ -201,7 +200,7 @@ export class Molfile {
this.prepareSGroups(skipSGroupErrors, preserveIndigoDesc);

this.writeHeader();
this.writeCTab2000(undefined, ignoreChiralFlag);
this.writeCTab2000(undefined);

return this.molfile;
}
Expand Down Expand Up @@ -268,7 +267,7 @@ export class Molfile {
this.write(utils.paddedNum(number, width, precision));
}

writeCTab2000Header(ignoreChiralFlag) {
writeCTab2000Header() {
/* saver */
this.writePaddedNumber(this.molecule!.atoms.size, 3);
this.writePaddedNumber(this.molecule!.bonds.size, 3);
Expand All @@ -279,7 +278,7 @@ export class Molfile {
fr ? fr.enhancedStereoFlag === StereoFlag.Abs : false,
);

this.writePaddedNumber(isAbsFlag || ignoreChiralFlag ? 1 : 0, 3);
this.writePaddedNumber(isAbsFlag ? 1 : 0, 3);
this.writePaddedNumber(0, 3);
this.writePaddedNumber(0, 3);
this.writePaddedNumber(0, 3);
Expand All @@ -289,10 +288,10 @@ export class Molfile {
this.writeCR(' V2000');
}

writeCTab2000(rgroups?: Map<any, any>, ignoreChiralFlag?: boolean) {
writeCTab2000(rgroups?: Map<any, any>) {
// eslint-disable-line max-statements
/* saver */
this.writeCTab2000Header(ignoreChiralFlag);
this.writeCTab2000Header();

this.mapping = {};
let i = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ const server: {
'gross-formula-add-rsites': ExtendedSchema;
'gross-formula-add-isotopes': ExtendedSchema;
'dearomatize-on-load': ExtendedSchema;
ignoreChiralFlag: ExtendedSchema;
} = {
'dearomatize-on-load': {
title: 'dearomatize-on-load',
Expand All @@ -347,6 +348,12 @@ const server: {
description: 'slider',
default: true,
},
ignoreChiralFlag: {
title: 'Ignore the chiral flag',
type: 'boolean',
description: 'slider',
default: false,
},
'ignore-stereochemistry-errors': {
title: 'Ignore stereochemistry errors',
type: 'boolean',
Expand Down

0 comments on commit 2030475

Please sign in to comment.