Skip to content

Commit

Permalink
fix: extract nucleus from tag
Browse files Browse the repository at this point in the history
  • Loading branch information
jobo322 committed Jun 28, 2024
1 parent c0779b8 commit d69d481
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/converter/__tests__/nmredataToJSON.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
4 changes: 2 additions & 2 deletions src/converter/util/toJSON/getNucleusFromTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export function getNucleusFromTag(label) {
if (dimensions === '1') {
nucleus = label
.substring(3, label.length)
.replace(/(?<nucleus>[0-9]+\w+)#\w+/g, '$nucleus');
.replace(/(?<nucleus>[0-9]+\w+)#\w+/g, '$<nucleus>');
} 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(/(?<nucleus>[0-9]+\w+)#\w+/g, '$nucleus'));
nucleus.push(data[i].replace(/(?<nucleus>[0-9]+\w+)#\w+/g, '$<nucleus>'));
}
}
return nucleus;
Expand Down

0 comments on commit d69d481

Please sign in to comment.