Skip to content

Commit

Permalink
add check for autometadata
Browse files Browse the repository at this point in the history
  • Loading branch information
f-idiris committed Sep 8, 2023
1 parent 37b67dd commit 2cd7aa3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
21 changes: 15 additions & 6 deletions dist/helpers/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ const toPeakStr = peaks => {
const str = arr.join('#');
return str;
};
let fixedWavelength = null;
let fixedWavelength = '';
const extractFixedWavelength = source => {
const jcamp = _jcampconverter.default.convert(source, {
xy: true,
keepRecordsRegExp: /(CSAUTOMETADATA)/
});
// eslint-disable-next-line prefer-destructuring
fixedWavelength = jcamp.info.$CSAUTOMETADATA.match(/FIXEDWAVELENGTH=([\d.]+)/)[1];
if ('$CSAUTOMETADATA' in jcamp.info) {
const match = jcamp.info.$CSAUTOMETADATA.match(/FIXEDWAVELENGTH=([\d.]+)/);
if (match !== null) {
// eslint-disable-next-line prefer-destructuring
fixedWavelength = match[1];
}
}
return {
fixedWavelength
};
Expand Down Expand Up @@ -141,6 +146,10 @@ const spectraOps = {
head: 'SIZE EXCLUSION CHROMATOGRAPHY',
tail: '.'
},
[_list_layout.LIST_LAYOUT.EMISSIONS]: {
head: 'EMISSION',
tail: ' nm'
},
[_list_layout.LIST_LAYOUT.DLS_INTENSITY]: {
head: 'DLS',
tail: '.'
Expand Down Expand Up @@ -412,13 +421,13 @@ const peaksWrapper = function (layout, shift) {
tail: ''
};
}
const ops = spectraOps[layout];
if (layout === _list_layout.LIST_LAYOUT.EMISSIONS) {
return {
head: `EMISSION: λex = ${fixedWavelength} nm, λem = `,
tail: ' nm'
head: `${ops.head}${solvTxt}: λex = ${fixedWavelength} nm; λem = `,
tail: ops.tail
};
}
const ops = spectraOps[layout];
return {
head: `${ops.head}${solvTxt} = `,
tail: ops.tail
Expand Down
16 changes: 11 additions & 5 deletions src/helpers/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const toPeakStr = (peaks) => {
return str;
};

let fixedWavelength = null;
let fixedWavelength = '';

const extractFixedWavelength = (source) => {
const jcamp = Jcampconverter.convert(
Expand All @@ -62,8 +62,13 @@ const extractFixedWavelength = (source) => {
keepRecordsRegExp: /(CSAUTOMETADATA)/,
},
);
// eslint-disable-next-line prefer-destructuring
fixedWavelength = jcamp.info.$CSAUTOMETADATA.match(/FIXEDWAVELENGTH=([\d.]+)/)[1];
if ('$CSAUTOMETADATA' in jcamp.info) {
const match = jcamp.info.$CSAUTOMETADATA.match(/FIXEDWAVELENGTH=([\d.]+)/);
if (match !== null) {
// eslint-disable-next-line prefer-destructuring
fixedWavelength = match[1];
}
}

return { fixedWavelength };
};
Expand All @@ -86,6 +91,7 @@ const spectraOps = {
[LIST_LAYOUT.CYCLIC_VOLTAMMETRY]: { head: 'CYCLIC VOLTAMMETRY', tail: '.' },
[LIST_LAYOUT.CDS]: { head: 'CIRCULAR DICHROISM SPECTROSCOPY', tail: '.' },
[LIST_LAYOUT.SEC]: { head: 'SIZE EXCLUSION CHROMATOGRAPHY', tail: '.' },
[LIST_LAYOUT.EMISSIONS]: { head: 'EMISSION', tail: ' nm' },
[LIST_LAYOUT.DLS_INTENSITY]: { head: 'DLS', tail: '.' },
};

Expand Down Expand Up @@ -340,10 +346,10 @@ const peaksWrapper = (layout, shift, atIndex = 0) => {
return { head: '', tail: '' };
}

const ops = spectraOps[layout];
if (layout === LIST_LAYOUT.EMISSIONS) {
return { head: `EMISSION: λex = ${fixedWavelength} nm, λem = `, tail: ' nm' };
return { head: `${ops.head}${solvTxt}: λex = ${fixedWavelength} nm; λem = `, tail: ops.tail };
}
const ops = spectraOps[layout];
return { head: `${ops.head}${solvTxt} = `, tail: ops.tail };
};

Expand Down

0 comments on commit 2cd7aa3

Please sign in to comment.