Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report fixed wavelength in emission spec #152

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dist/helpers/chem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 23 additions & 6 deletions dist/helpers/format.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -58,6 +60,18 @@ const toPeakStr = peaks => {
const str = arr.join('#');
return str;
};
let fixedWavelength = null;
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];
return {
fixedWavelength
};
};
const spectraOps = {
[_list_layout.LIST_LAYOUT.PLAIN]: {
head: '',
Expand Down Expand Up @@ -127,10 +141,6 @@ const spectraOps = {
head: 'SIZE EXCLUSION CHROMATOGRAPHY',
tail: '.'
},
[_list_layout.LIST_LAYOUT.EMISSIONS]: {
head: 'EMISSION',
tail: '.'
},
[_list_layout.LIST_LAYOUT.DLS_INTENSITY]: {
head: 'DLS',
tail: '.'
Expand Down Expand Up @@ -259,7 +269,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 ordered.map(o => `${o.x}`).join(', ');
};
const formatedDLSIntensity = function (peaks, maxY) {
let decimal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
Expand Down Expand Up @@ -402,6 +412,12 @@ const peaksWrapper = function (layout, shift) {
tail: ''
};
}
if (layout === _list_layout.LIST_LAYOUT.EMISSIONS) {
return {
head: `EMISSION: λex = ${fixedWavelength} nm, λem = `,
tail: ' nm'
};
}
const ops = spectraOps[layout];
return {
head: `${ops.head}${solvTxt} = `,
Expand Down Expand Up @@ -526,7 +542,8 @@ const Format = {
hasMultiCurves,
isAIFLayout,
isDLSACFLayout,
strNumberFixedDecimal
strNumberFixedDecimal,
extractFixedWavelength
};
var _default = Format;
exports.default = _default;
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];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • What will happen when CSAUTOMETADATA is not in the jcamp file?
  • What will happen when FIXEDWAVELENGTH is not in the jcamp file?


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 @@ -459,6 +478,7 @@ const Format = {
isAIFLayout,
isDLSACFLayout,
strNumberFixedDecimal,
extractFixedWavelength,
};

export default Format;