Skip to content

Commit 2c00d26

Browse files
committed
report fixed wavelength in emission spec
1 parent e996036 commit 2c00d26

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed

src/__tests__/fixtures/emissions_jcamp.js

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const emissionsJcamp = `
2-
##TITLE=
2+
##TITLE=Example of fluorescence measurement (4).1_bagit
33
##JCAMP-DX=5.0
44
##DATA TYPE=LINK
55
##BLOCKS=1
6+
7+
68
$$ === CHEMSPECTRA SPECTRUM ORIG ===
7-
##TITLE=
9+
##TITLE=Example of fluorescence measurement (4).1_bagit
810
##JCAMP-DX=5.00
911
##DATA TYPE=Emissions
1012
##DATA CLASS=XYDATA
@@ -826,6 +828,7 @@ $$ === CHEMSPECTRA SPECTRUM ORIG ===
826828
800.0, 0.0258263
827829
$$ === CHEMSPECTRA INTEGRALS AND MULTIPLETS ===
828830
##$OBSERVEDINTEGRALS= (X Y Z)
831+
829832
##$OBSERVEDMULTIPLETS=
830833
##$OBSERVEDMULTIPLETSPEAKS=
831834
$$ === CHEMSPECTRA SIMULATION ===
@@ -834,12 +837,12 @@ $$ === CHEMSPECTRA SIMULATION ===
834837
835838
836839
$$ === CHEMSPECTRA PEAK TABLE EDIT ===
837-
##TITLE=
840+
##TITLE=Example of fluorescence measurement (4).1_bagit
838841
##JCAMP-DX=5.00
839842
##DATA TYPE=EmissionsPEAKTABLE
840843
##DATA CLASS=PEAKTABLE
841844
##$CSCATEGORY=EDIT_PEAK
842-
##$CSTHRESHOLD=0.05
845+
##$CSTHRESHOLD=0.5
843846
##MAXX=800.0
844847
##MAXY=295.575
845848
##MINX=400.0
@@ -853,12 +856,12 @@ $$ === CHEMSPECTRA PEAK TABLE EDIT ===
853856
854857
855858
$$ === CHEMSPECTRA PEAK TABLE AUTO ===
856-
##TITLE=
859+
##TITLE=Example of fluorescence measurement (4).1_bagit
857860
##JCAMP-DX=5.00
858861
##DATA TYPE=EmissionsPEAKTABLE
859862
##DATA CLASS=PEAKTABLE
860863
##$CSCATEGORY=AUTO_PEAK
861-
##$CSTHRESHOLD=0.05
864+
##$CSTHRESHOLD=0.5
862865
##MAXX=800.0
863866
##MAXY=295.575
864867
##MINX=400.0
@@ -871,7 +874,16 @@ $$ === CHEMSPECTRA PEAK TABLE AUTO ===
871874
484.5, 190.807
872875
##END=
873876
877+
878+
$$ === CHEMSPECTRA AUTO METADATA ===
879+
##$CSAUTOMETADATA=
880+
DATA CLASS=XYPOINTS
881+
DATA TYPE=Emissions
882+
XUNITS=wavelength (nm)
883+
YUNITS=Intensity
884+
FIXEDWAVELENGTH=380.0
874885
##END=
875886
887+
##END=
876888
`;
877889
export default emissionsJcamp;

src/__tests__/units/helpers/format.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe('Test format helper', () => {
137137
it('Get peaks for Emission layout', () => {
138138
params.layout = LIST_LAYOUT.EMISSIONS
139139
const body = Format.peaksBody(params)
140-
expect(body).toEqual('2.0 nm (2.00 a.u.), 1.0 nm (1.00 a.u.)')
140+
expect(body).toEqual('2.0, 1.0')
141141
})
142142

143143

src/helpers/chem.js

+4
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,10 @@ const ExtractJcamp = (source) => {
751751
// : ((Format.isXRDLayout(layout) || Format.isCyclicVoltaLayout(layout))
752752
// ? extrFeaturesXrd(jcamp, layout, peakUp) : extrFeaturesNi(jcamp, layout, peakUp, spectra));
753753

754+
if (layout === LIST_LAYOUT.EMISSIONS) {
755+
Format.extractFixedWavelength(source);
756+
}
757+
754758
return { spectra, features, layout };
755759
};
756760

src/helpers/format.js

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable no-mixed-operators, prefer-object-spread,
22
function-paren-newline, no-unused-vars, default-param-last */
3+
import Jcampconverter from 'jcampconverter';
34
import { ToXY, IsSame } from './converter';
45
import { LIST_LAYOUT } from '../constants/list_layout';
56
import { calcMpyCenter } from './multiplicity_calc';
@@ -51,6 +52,22 @@ const toPeakStr = (peaks) => {
5152
return str;
5253
};
5354

55+
let fixedWavelength = null;
56+
57+
const extractFixedWavelength = (source) => {
58+
const jcamp = Jcampconverter.convert(
59+
source,
60+
{
61+
xy: true,
62+
keepRecordsRegExp: /(CSAUTOMETADATA)/,
63+
},
64+
);
65+
// eslint-disable-next-line prefer-destructuring
66+
fixedWavelength = jcamp.info.$CSAUTOMETADATA.match(/FIXEDWAVELENGTH=([\d.]+)/)[1];
67+
68+
return { fixedWavelength };
69+
};
70+
5471
const spectraOps = {
5572
[LIST_LAYOUT.PLAIN]: { head: '', tail: '.' },
5673
[LIST_LAYOUT.H1]: { head: '1H', tail: '.' },
@@ -69,7 +86,6 @@ const spectraOps = {
6986
[LIST_LAYOUT.CYCLIC_VOLTAMMETRY]: { head: 'CYCLIC VOLTAMMETRY', tail: '.' },
7087
[LIST_LAYOUT.CDS]: { head: 'CIRCULAR DICHROISM SPECTROSCOPY', tail: '.' },
7188
[LIST_LAYOUT.SEC]: { head: 'SIZE EXCLUSION CHROMATOGRAPHY', tail: '.' },
72-
[LIST_LAYOUT.EMISSIONS]: { head: 'EMISSION', tail: '.' },
7389
[LIST_LAYOUT.DLS_INTENSITY]: { head: 'DLS', tail: '.' },
7490
};
7591

@@ -189,7 +205,7 @@ const formatedEmissions = (
189205

190206
ordered = Object.keys(ordered).sort(sortFunc)
191207
.map((k) => ({ x: k, y: ordered[k] }));
192-
return ordered.map((o) => `${o.x} nm (${fixDigit(o.y, 2)} a.u.)`).join(', ');
208+
return ordered.map((o) => `${o.x}`).join(', ');
193209
};
194210

195211
const formatedDLSIntensity = (
@@ -324,6 +340,9 @@ const peaksWrapper = (layout, shift, atIndex = 0) => {
324340
return { head: '', tail: '' };
325341
}
326342

343+
if (layout === LIST_LAYOUT.EMISSIONS) {
344+
return { head: `EMISSION: λex = ${fixedWavelength} nm, λem = `, tail: ' nm' };
345+
}
327346
const ops = spectraOps[layout];
328347
return { head: `${ops.head}${solvTxt} = `, tail: ops.tail };
329348
};
@@ -459,6 +478,7 @@ const Format = {
459478
isAIFLayout,
460479
isDLSACFLayout,
461480
strNumberFixedDecimal,
481+
extractFixedWavelength,
462482
};
463483

464484
export default Format;

0 commit comments

Comments
 (0)