Skip to content

Commit

Permalink
report fixed wavelength in emission spec
Browse files Browse the repository at this point in the history
  • Loading branch information
f-idiris committed Sep 8, 2023
1 parent 3bc250d commit 913dbc7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
24 changes: 18 additions & 6 deletions src/__tests__/fixtures/emissions_jcamp.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -826,6 +828,7 @@ $$ === CHEMSPECTRA SPECTRUM ORIG ===
800.0, 0.0258263
$$ === CHEMSPECTRA INTEGRALS AND MULTIPLETS ===
##$OBSERVEDINTEGRALS= (X Y Z)
##$OBSERVEDMULTIPLETS=
##$OBSERVEDMULTIPLETSPEAKS=
$$ === CHEMSPECTRA SIMULATION ===
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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;
2 changes: 1 addition & 1 deletion src/__tests__/units/helpers/format.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('2.0, 1.0')
})


Expand Down
4 changes: 4 additions & 0 deletions src/helpers/chem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};

Expand Down
24 changes: 22 additions & 2 deletions src/helpers/format.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -51,6 +52,22 @@ const toPeakStr = (peaks) => {
return str;
};

let fixedWavelength = null;

const extractFixedWavelength = (source) => {
const jcamp = Jcampconverter.convert(
source,
{
xy: true,
keepRecordsRegExp: /(CSAUTOMETADATA)/,
},
);
// eslint-disable-next-line prefer-destructuring
fixedWavelength = jcamp.info.$CSAUTOMETADATA.match(/FIXEDWAVELENGTH=([\d.]+)/)[1];

return { fixedWavelength };
};

const spectraOps = {
[LIST_LAYOUT.PLAIN]: { head: '', tail: '.' },
[LIST_LAYOUT.H1]: { head: '1H', tail: '.' },
Expand All @@ -69,7 +86,6 @@ 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.DLS_INTENSITY]: { head: 'DLS', tail: '.' },
};

Expand Down Expand Up @@ -189,7 +205,7 @@ 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 ordered.map((o) => `${o.x}`).join(', ');
};

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

if (layout === LIST_LAYOUT.EMISSIONS) {
return { head: `EMISSION: λex = ${fixedWavelength} nm, λem = `, tail: ' nm' };
}
const ops = spectraOps[layout];
return { head: `${ops.head}${solvTxt} = `, tail: ops.tail };
};
Expand Down Expand Up @@ -451,6 +470,7 @@ const Format = {
hasMultiCurves,
isAIFLayout,
isDLSACFLayout,
extractFixedWavelength,
};

export default Format;

0 comments on commit 913dbc7

Please sign in to comment.