From d69d4814f30256f235ba64d6192af354ae17a395 Mon Sep 17 00:00:00 2001 From: jobo322 Date: Fri, 28 Jun 2024 10:28:41 -0500 Subject: [PATCH] fix: extract nucleus from tag --- src/converter/__tests__/nmredataToJSON.test.js | 12 ++++++++++++ src/converter/util/toJSON/getNucleusFromTag.js | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/converter/__tests__/nmredataToJSON.test.js b/src/converter/__tests__/nmredataToJSON.test.js index 55b3428..1c3ba3e 100644 --- a/src/converter/__tests__/nmredataToJSON.test.js +++ b/src/converter/__tests__/nmredataToJSON.test.js @@ -50,4 +50,16 @@ describe('NMReData to nmrium', () => { 'AN-menthol/10/specpar', ]); }); + + it('1D data with more than one carbon spectra', async () => { + const nmrRecord = await readNmrRecord( + await getData('3,5-Bis(trifluoromethyl)aniline-sym.zip'), + ); + let jsonData = await nmrRecord.toJSON(); + + //dept135 is under tag #2 so it is what is testing. + expect( + jsonData.spectra.some((s) => s.experiment === 'dept135'), + ).toBeTruthy(); + }); }); diff --git a/src/converter/util/toJSON/getNucleusFromTag.js b/src/converter/util/toJSON/getNucleusFromTag.js index 68a8818..1cf19f0 100644 --- a/src/converter/util/toJSON/getNucleusFromTag.js +++ b/src/converter/util/toJSON/getNucleusFromTag.js @@ -4,11 +4,11 @@ export function getNucleusFromTag(label) { if (dimensions === '1') { nucleus = label .substring(3, label.length) - .replace(/(?[0-9]+\w+)#\w+/g, '$nucleus'); + .replace(/(?[0-9]+\w+)#\w+/g, '$'); } else if (dimensions === '2') { let data = label.substring(12, label.length).split('_'); for (let i = 0; i < data.length; i += 2) { - nucleus.push(data[i].replace(/(?[0-9]+\w+)#\w+/g, '$nucleus')); + nucleus.push(data[i].replace(/(?[0-9]+\w+)#\w+/g, '$')); } } return nucleus;