Skip to content

Commit

Permalink
#3431 - Warnings appear while saving any structure as Daylight SMARTS
Browse files Browse the repository at this point in the history
  • Loading branch information
AKZhuk committed Oct 12, 2023
1 parent 54a4b66 commit 29f8612
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
***************************************************************************/

import {
Atom,
Bond,
RxnArrowMode,
StereoFlag,
Struct,
Expand All @@ -32,10 +34,29 @@ export function couldBeSaved(
const rxnArrowsSize = struct.rxnArrows.size;
const hasRxnArrow = struct.hasRxnArrow();

if (format === 'smiles' || format === 'smarts') {
warnings.push(
`Structure contains query properties of atoms and bonds that are not supported in the ${format?.toUpperCase()}. Query properties will not be reflected in the file saved.`,
if (format === 'smarts') {
const arrayOfAtoms: Array<Atom> = Array.from(struct.atoms.values());
const arrayOfBonds: Array<Bond> = Array.from(struct.bonds.values());
console.log(arrayOfAtoms);

const hasAtomUnsupportedProperties = arrayOfAtoms.some(
(atom) =>
atom.radical ||
atom.unsaturatedAtom ||
atom.exactChangeFlag ||
atom.invRet,
);
const hasBondUnsupportedProperties = arrayOfBonds.some(
(bond) =>
bond.reactingCenterStatus ||
bond.type === Bond.PATTERN.TYPE.DATIVE ||
bond.type === Bond.PATTERN.TYPE.HYDROGEN,
);
if (hasBondUnsupportedProperties || hasAtomUnsupportedProperties) {
warnings.push(
`Structure contains query properties of atoms and bonds that are not supported in the SMARTS. Query properties will not be reflected in the file saved.`,
);
}
}

if (format === 'smiles') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,16 @@ class SaveDialog extends Component {
}

if (moleculeErrors) {
warnings.push(...Object.values(moleculeErrors));
const filteredMoleculeErrors = Object.values(moleculeErrors).filter(
(error) => {
if (format === 'smarts' || format === 'ket') {
return !error.includes('Structure contains query features');
} else {
return true;
}
},
);
warnings.push(...Object.values(filteredMoleculeErrors));
}
return warnings;
};
Expand Down

0 comments on commit 29f8612

Please sign in to comment.