diff --git a/__tests__/__snapshots__/molecule.js.snap b/__tests__/__snapshots__/molecule.js.snap index fe0053f2..42febdeb 100644 --- a/__tests__/__snapshots__/molecule.js.snap +++ b/__tests__/__snapshots__/molecule.js.snap @@ -16,12 +16,12 @@ exports[`Molecule toSVG with autoCrop 1`] = ` - - - - - - + + + + + + " `; @@ -41,11 +41,11 @@ exports[`Molecule toSVG with autoCrop 2`] = ` - - - - - - + + + + + + " `; diff --git a/__tests__/data/atomMapNo.mol b/__tests__/data/atomMapNo.mol new file mode 100644 index 00000000..1c9e12e2 --- /dev/null +++ b/__tests__/data/atomMapNo.mol @@ -0,0 +1,14 @@ + + + + 5 4 0 0 0 0 0 0 0 0999 V2000 + -1.4289 0.2062 0.0000 H 0 0 0 0 0 0 0 0 0 2 0 0 + -0.7145 -0.2062 0.0000 C 0 0 0 0 0 0 0 0 0 1 0 0 + -0.0000 0.2062 0.0000 C 0 0 0 0 0 0 0 0 0 3 0 0 + 0.7145 -0.2062 0.0000 C 0 0 0 0 0 0 0 0 0 4 0 0 + 1.4289 0.2062 0.0000 O 0 0 0 0 0 0 0 0 0 5 0 0 + 1 2 1 0 0 + 2 3 1 0 0 + 3 4 1 0 0 + 4 5 1 0 0 +M END \ No newline at end of file diff --git a/__tests__/molfileAndAtomMapNo.test.js b/__tests__/molfileAndAtomMapNo.test.js new file mode 100644 index 00000000..5a7a1512 --- /dev/null +++ b/__tests__/molfileAndAtomMapNo.test.js @@ -0,0 +1,27 @@ +'use strict'; + +const { readFileSync } = require('fs'); + +const { Molecule } = require('../minimal'); + + + +test('molfile with atomMapNo', () => { + const molfile = readFileSync( + `${__dirname}/data/atomMapNo.mol`, + 'utf8', + ); + const molecule = Molecule.fromMolfile(molfile); + + const newMolfile = molecule.toMolfile(); + const atomMapNo = newMolfile.split(/\r?\n/).filter((line) => line.match(/ [OCH] /)) + .map(line => line.replace(/.* ([OCH]) .*(.) {2}0 {2}0$/, '$1 $2')); + expect(atomMapNo).toStrictEqual(['O 5', 'C 1', 'C 3', 'C 4', 'H 2']) + + const svg = molecule.toSVG(300, 200); + const mapNos = svg.split(/\r?\n/).filter((line) => line.includes('data-atom-map')).map(line => line.replace(/.*atom-map-no="(.).*/, '$1')); + expect(mapNos).toStrictEqual(["5", "1", "3", "4", "2"]) + + + +}) \ No newline at end of file diff --git a/src/com/actelion/research/gwt/chemlib/com/actelion/research/chem/SVGDepictor.java b/src/com/actelion/research/gwt/chemlib/com/actelion/research/chem/SVGDepictor.java index 266c6b33..b300a72c 100644 --- a/src/com/actelion/research/gwt/chemlib/com/actelion/research/chem/SVGDepictor.java +++ b/src/com/actelion/research/gwt/chemlib/com/actelion/research/chem/SVGDepictor.java @@ -223,6 +223,7 @@ protected void onDrawAtom(int atom, String symbol, double x, double y) { String s = "