diff --git a/__tests__/Reactor.test.js b/__tests__/Reactor.test.js index 031c73c1..98fa250f 100644 --- a/__tests__/Reactor.test.js +++ b/__tests__/Reactor.test.js @@ -9,6 +9,20 @@ const { Reactor, Molecule, Reaction, ReactionEncoder } = require('../core'); // Currently we generate RXN files using ChemDraw describe('Reactor class', () => { + it('impossible water loss', () => { + const reaction = ReactionEncoder.decode( + 'eMHAIhH!eF@HhP#QF Qd#!R_vq?DqtJ_@ !R@Fp]Agp', + ); + + const reactor = new Reactor(reaction); + + const match = reactor.setReactant(0, Molecule.fromSmiles('C=C(O)C(C)(C)C')); + expect(match).toStrictEqual(true); + + const products = reactor.getProducts(); + expect(products).toHaveLength(0); + }); + it('deshydratation', () => { const reaction = ReactionEncoder.decode( 'eMHAIhH!eF@HhP#QF Qd#!R_vq?DqtJ_@ !R@Fp]Agp', diff --git a/src/com/actelion/research/gwt/core/JSReactor.java b/src/com/actelion/research/gwt/core/JSReactor.java index 81709856..b86da998 100644 --- a/src/com/actelion/research/gwt/core/JSReactor.java +++ b/src/com/actelion/research/gwt/core/JSReactor.java @@ -23,6 +23,10 @@ public boolean setReactant(int no, JSMolecule reactant) { public JSMolecule[][] getProducts() { StereoMolecule[][] products = reactor.getProducts(); + if (products == null || products.length == 0) { + return new JSMolecule[0][0]; + } + JSMolecule[][] jsProducts = new JSMolecule[products.length][products[0].length]; for (int i = 0; i < products.length; i++) {