diff --git a/dist/helpers/chem.js b/dist/helpers/chem.js index c477abd9..1086556c 100644 --- a/dist/helpers/chem.js +++ b/dist/helpers/chem.js @@ -783,6 +783,9 @@ const ExtractJcamp = source => { // : ((Format.isXRDLayout(layout) || Format.isCyclicVoltaLayout(layout)) // ? extrFeaturesXrd(jcamp, layout, peakUp) : extrFeaturesNi(jcamp, layout, peakUp, spectra)); + if (layout === _list_layout.LIST_LAYOUT.EMISSIONS) { + _format.default.extractFixedWavelength(source); + } return { spectra, features, diff --git a/dist/helpers/format.js b/dist/helpers/format.js index e2eb4820..1fbc58a7 100644 --- a/dist/helpers/format.js +++ b/dist/helpers/format.js @@ -1,9 +1,11 @@ "use strict"; +var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; +var _jcampconverter = _interopRequireDefault(require("jcampconverter")); var _converter = require("./converter"); var _list_layout = require("../constants/list_layout"); var _multiplicity_calc = require("./multiplicity_calc"); @@ -58,6 +60,23 @@ const toPeakStr = peaks => { const str = arr.join('#'); return str; }; +let fixedWavelength = ''; +const extractFixedWavelength = source => { + const jcamp = _jcampconverter.default.convert(source, { + xy: true, + keepRecordsRegExp: /(CSAUTOMETADATA)/ + }); + 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 + }; +}; const spectraOps = { [_list_layout.LIST_LAYOUT.PLAIN]: { head: '', @@ -129,7 +148,7 @@ const spectraOps = { }, [_list_layout.LIST_LAYOUT.EMISSIONS]: { head: 'EMISSION', - tail: '.' + tail: ' nm' }, [_list_layout.LIST_LAYOUT.DLS_INTENSITY]: { head: 'DLS', @@ -259,7 +278,7 @@ const formatedEmissions = function (peaks, maxY) { x: k, y: ordered[k] })); - return ordered.map(o => `${o.x} nm (${fixDigit(o.y, 2)} a.u.)`).join(', '); + return `λex = ${fixedWavelength} nm; λem = ${ordered.map(o => `${o.x}`).join(', ')}`; }; const formatedDLSIntensity = function (peaks, maxY) { let decimal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2; @@ -526,7 +545,8 @@ const Format = { hasMultiCurves, isAIFLayout, isDLSACFLayout, - strNumberFixedDecimal + strNumberFixedDecimal, + extractFixedWavelength }; var _default = Format; exports.default = _default; \ No newline at end of file diff --git a/src/__tests__/fixtures/emissions_jcamp.js b/src/__tests__/fixtures/emissions_jcamp.js index 80610a34..e572ec20 100644 --- a/src/__tests__/fixtures/emissions_jcamp.js +++ b/src/__tests__/fixtures/emissions_jcamp.js @@ -1,10 +1,12 @@ const emissionsJcamp = ` -##TITLE= +##TITLE=Example of fluorescence measurement (4).1_bagit ##JCAMP-DX=5.0 ##DATA TYPE=LINK ##BLOCKS=1 + + $$ === CHEMSPECTRA SPECTRUM ORIG === -##TITLE= +##TITLE=Example of fluorescence measurement (4).1_bagit ##JCAMP-DX=5.00 ##DATA TYPE=Emissions ##DATA CLASS=XYDATA @@ -826,6 +828,7 @@ $$ === CHEMSPECTRA SPECTRUM ORIG === 800.0, 0.0258263 $$ === CHEMSPECTRA INTEGRALS AND MULTIPLETS === ##$OBSERVEDINTEGRALS= (X Y Z) + ##$OBSERVEDMULTIPLETS= ##$OBSERVEDMULTIPLETSPEAKS= $$ === CHEMSPECTRA SIMULATION === @@ -834,12 +837,12 @@ $$ === CHEMSPECTRA SIMULATION === $$ === CHEMSPECTRA PEAK TABLE EDIT === -##TITLE= +##TITLE=Example of fluorescence measurement (4).1_bagit ##JCAMP-DX=5.00 ##DATA TYPE=EmissionsPEAKTABLE ##DATA CLASS=PEAKTABLE ##$CSCATEGORY=EDIT_PEAK -##$CSTHRESHOLD=0.05 +##$CSTHRESHOLD=0.5 ##MAXX=800.0 ##MAXY=295.575 ##MINX=400.0 @@ -853,12 +856,12 @@ $$ === CHEMSPECTRA PEAK TABLE EDIT === $$ === CHEMSPECTRA PEAK TABLE AUTO === -##TITLE= +##TITLE=Example of fluorescence measurement (4).1_bagit ##JCAMP-DX=5.00 ##DATA TYPE=EmissionsPEAKTABLE ##DATA CLASS=PEAKTABLE ##$CSCATEGORY=AUTO_PEAK -##$CSTHRESHOLD=0.05 +##$CSTHRESHOLD=0.5 ##MAXX=800.0 ##MAXY=295.575 ##MINX=400.0 @@ -871,7 +874,16 @@ $$ === CHEMSPECTRA PEAK TABLE AUTO === 484.5, 190.807 ##END= + +$$ === CHEMSPECTRA AUTO METADATA === +##$CSAUTOMETADATA= +DATA CLASS=XYPOINTS +DATA TYPE=Emissions +XUNITS=wavelength (nm) +YUNITS=Intensity +FIXEDWAVELENGTH=380.0 ##END= +##END= `; export default emissionsJcamp; diff --git a/src/__tests__/units/helpers/format.test.tsx b/src/__tests__/units/helpers/format.test.tsx index bd8754d2..a617e88f 100644 --- a/src/__tests__/units/helpers/format.test.tsx +++ b/src/__tests__/units/helpers/format.test.tsx @@ -137,7 +137,7 @@ describe('Test format helper', () => { it('Get peaks for Emission layout', () => { params.layout = LIST_LAYOUT.EMISSIONS const body = Format.peaksBody(params) - expect(body).toEqual('2.0 nm (2.00 a.u.), 1.0 nm (1.00 a.u.)') + expect(body).toEqual('λex = nm; λem = 2.0, 1.0') }) diff --git a/src/helpers/chem.js b/src/helpers/chem.js index 3ad7fd94..99d0b5a1 100644 --- a/src/helpers/chem.js +++ b/src/helpers/chem.js @@ -751,6 +751,10 @@ const ExtractJcamp = (source) => { // : ((Format.isXRDLayout(layout) || Format.isCyclicVoltaLayout(layout)) // ? extrFeaturesXrd(jcamp, layout, peakUp) : extrFeaturesNi(jcamp, layout, peakUp, spectra)); + if (layout === LIST_LAYOUT.EMISSIONS) { + Format.extractFixedWavelength(source); + } + return { spectra, features, layout }; }; diff --git a/src/helpers/format.js b/src/helpers/format.js index b17f88cf..e37ce8c2 100644 --- a/src/helpers/format.js +++ b/src/helpers/format.js @@ -1,5 +1,6 @@ /* eslint-disable no-mixed-operators, prefer-object-spread, function-paren-newline, no-unused-vars, default-param-last */ +import Jcampconverter from 'jcampconverter'; import { ToXY, IsSame } from './converter'; import { LIST_LAYOUT } from '../constants/list_layout'; import { calcMpyCenter } from './multiplicity_calc'; @@ -51,6 +52,27 @@ const toPeakStr = (peaks) => { return str; }; +let fixedWavelength = ''; + +const extractFixedWavelength = (source) => { + const jcamp = Jcampconverter.convert( + source, + { + xy: true, + keepRecordsRegExp: /(CSAUTOMETADATA)/, + }, + ); + 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 }; +}; + const spectraOps = { [LIST_LAYOUT.PLAIN]: { head: '', tail: '.' }, [LIST_LAYOUT.H1]: { head: '1H', tail: '.' }, @@ -69,7 +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: '.' }, + [LIST_LAYOUT.EMISSIONS]: { head: 'EMISSION', tail: ' nm' }, [LIST_LAYOUT.DLS_INTENSITY]: { head: 'DLS', tail: '.' }, }; @@ -189,7 +211,8 @@ const formatedEmissions = ( ordered = Object.keys(ordered).sort(sortFunc) .map((k) => ({ x: k, y: ordered[k] })); - return ordered.map((o) => `${o.x} nm (${fixDigit(o.y, 2)} a.u.)`).join(', '); + return `λex = ${fixedWavelength} nm; λem = ${ordered.map((o) => `${o.x}`) + .join(', ')}`; }; const formatedDLSIntensity = ( @@ -459,6 +482,7 @@ const Format = { isAIFLayout, isDLSACFLayout, strNumberFixedDecimal, + extractFixedWavelength, }; export default Format;