Skip to content

Commit

Permalink
feat WIP: add threshold for mass spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Lan Le committed Sep 12, 2024
1 parent ec22b19 commit cf4504f
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/fixtures/lc_ms_jcamp_uvvis.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $$ === CHEMSPECTRA SPECTRUM ORIG ===
##VAR_TYPE= INDEPENDENT, DEPENDENT, INDEPENDENT
##VAR_FORM= AFFN, AFFN, AFFN
##VAR_DIM= , , 3
##UNITS= M/Z, RELATIVE ABUNDANCE, SECONDS
##UNITS= MINUTES, RELATIVE ABUNDANCE, SECONDS
##FIRST= , , 0.009
##LAST= , , 5.10098333333333
##PAGE=210
Expand Down
22 changes: 15 additions & 7 deletions src/components/cmd_bar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,22 @@ const styles = () => (

const CmdBar = ({
classes, feature, hasEdit, forecast, operations, editorOnly, jcampIdx, hideThreshold,
hideMainEditTools,
}) => (
<div className={classes.card}>
<Viewer editorOnly={editorOnly} />
<Zoom />
<Peak jcampIdx={jcampIdx} feature={feature} />
<Pecker jcampIdx={jcampIdx} />
<Integration />
<Multiplicity />
<UndoRedo />
{
hideMainEditTools ? null : (
<>
<Viewer editorOnly={editorOnly} />
<Zoom />
<Peak jcampIdx={jcampIdx} feature={feature} />
<Pecker jcampIdx={jcampIdx} />
<Integration />
<Multiplicity />
<UndoRedo />
</>
)
}
<Submit
operations={operations}
feature={feature}
Expand Down Expand Up @@ -80,6 +87,7 @@ CmdBar.propTypes = {
editorOnly: PropTypes.bool.isRequired,
jcampIdx: PropTypes.any,
hideThreshold: PropTypes.bool,
hideMainEditTools: PropTypes.bool,
};

export default compose(
Expand Down
49 changes: 23 additions & 26 deletions src/components/d3_line_rect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import FindReplaceOutlinedIcon from '@mui/icons-material/FindReplaceOutlined';
import { MuButton, commonStyle, focusStyle } from '../cmd_bar/common';

import {
Topic2Seed, ToThresEndPts,
Topic2Seed, ToThresEndPts, convertThresEndPts,
} from '../../helpers/chem';
import { resetAll } from '../../actions/manager';
import {
Expand All @@ -36,7 +36,7 @@ import { LIST_ROOT_SVG_GRAPH, LIST_BRUSH_SVG_GRAPH } from '../../constants/list_
import PeakGroup from '../cmd_bar/08_peak_group';

const W = Math.round(window.innerWidth * 0.90 * 9 / 12); // ROI
const H = Math.round(window.innerHeight * 0.90 * 0.85 / 3); // ROI
const H = Math.round(window.innerHeight * 0.90 * 0.8 / 3); // ROI

const styles = () => (
Object.assign(
Expand Down Expand Up @@ -113,6 +113,7 @@ const waveLengthSelect = (classes, hplcMsSt, updateWaveLengthAct) => {
<FormControl
className={classNames(classes.fieldDecimal)}
variant="outlined"
style={{ width: '80px' }}
>
<InputLabel id="select-decimal-label" className={classNames(classes.selectLabel, 'select-sv-bar-label')}>
Wavelength
Expand Down Expand Up @@ -193,7 +194,7 @@ class ViewerLineRect extends React.Component {

componentDidMount() {
const {
entities, curveSt, seed, cLabel, xLabel, yLabel, feature,
entities, curveSt, seed, cLabel, feature,
tTrEndPts, layoutSt,
isUiAddIntgSt, isUiNoBrushSt,
isHidden,
Expand Down Expand Up @@ -223,7 +224,7 @@ class ViewerLineRect extends React.Component {
isUiNoBrushSt: true,
sweepExtentSt: sweepExtent[0],
});
drawLabel(this.rootKlassLine, null, 'M/Z', 'Intensity');
drawLabel(this.rootKlassLine, null, 'Minutes', 'Intensity');
drawDisplay(this.rootKlassLine, false);

const filterSeed = seed;
Expand All @@ -239,7 +240,7 @@ class ViewerLineRect extends React.Component {
isUiAddIntgSt,
isUiNoBrushSt,
});
drawLabel(this.rootKlassMulti, cLabel, xLabel, yLabel);
drawLabel(this.rootKlassMulti, cLabel, 'Minutes', 'Intensity');
drawDisplay(this.rootKlassMulti, isHidden);

drawMain(this.rootKlassRect, W, H, LIST_BRUSH_SVG_GRAPH.RECT);
Expand All @@ -256,10 +257,10 @@ class ViewerLineRect extends React.Component {

componentDidUpdate(prevProps) {
const {
entities, curveSt, seed, cLabel, xLabel, yLabel,
entities, curveSt, seed, cLabel,
tTrEndPts, layoutSt,
isUiAddIntgSt, isUiNoBrushSt,
isHidden, uiSt,
isHidden, uiSt, hplcMsSt,
} = this.props;
this.normChange(prevProps);

Expand All @@ -282,7 +283,7 @@ class ViewerLineRect extends React.Component {
isUiNoBrushSt: true,
sweepExtentSt: sweepExtent[0],
});
drawLabel(this.rootKlassLine, null, 'M/Z', 'Intensity');
drawLabel(this.rootKlassLine, null, 'Minutes', 'Intensity');
drawDisplay(this.rootKlassLine, false);
}

Expand All @@ -298,12 +299,14 @@ class ViewerLineRect extends React.Component {
isUiAddIntgSt,
isUiNoBrushSt,
});
drawLabel(this.rootKlassMulti, cLabel, xLabel, yLabel);
drawLabel(this.rootKlassMulti, cLabel, 'Minutes', 'Intensity');
drawDisplay(this.rootKlassMulti, isHidden);

const subViewFeature = this.extractSubView();
if (subViewFeature) {
const { data, xUnit, pageValue } = subViewFeature;
const { threshold } = hplcMsSt;
const curTrEndPts = convertThresEndPts(subViewFeature, threshold.value);
const { data, pageValue } = subViewFeature;
const currentData = data[0];
const { x, y } = currentData;
const subSeed = x.map((d, index) => {
Expand All @@ -313,11 +316,11 @@ class ViewerLineRect extends React.Component {
this.rectFocus.update({
filterSeed: subSeed,
filterPeak: [],
tTrEndPts,
tTrEndPts: curTrEndPts,
isUiNoBrushSt: true,
sweepExtentSt: sweepExtent[2],
});
drawLabel(this.rootKlassRect, `${pageValue} min`, xUnit, 'Intensity');
drawLabel(this.rootKlassRect, `${pageValue} min`, 'M/Z', 'Intensity');
drawDisplay(this.rootKlassRect, false);
}
}
Expand Down Expand Up @@ -381,22 +384,18 @@ class ViewerLineRect extends React.Component {
{
zoomView(classNames, 0, uiSt, zoomInAct)
}
<div style={{ textAlign: 'right' }}>
{
waveLengthSelect(classes, hplcMsSt, selectWavelengthAct)
}
<div className={LIST_ROOT_SVG_GRAPH.LINE} />
</div>
{
waveLengthSelect(classes, hplcMsSt, selectWavelengthAct)
}
<div className={LIST_ROOT_SVG_GRAPH.LINE} />
<PeakGroup feature={feature} graphIndex={1} />
{
zoomView(classes, 1, uiSt, zoomInAct)
}
<div style={{ textAlign: 'right' }}>
{
ticSelect(classes, hplcMsSt, handleTicChanged)
}
<div className={LIST_ROOT_SVG_GRAPH.MULTI} />
</div>
{
ticSelect(classes, hplcMsSt, handleTicChanged)
}
<div className={LIST_ROOT_SVG_GRAPH.MULTI} />
{
zoomView(classes, 2, uiSt, zoomInAct)
}
Expand Down Expand Up @@ -439,8 +438,6 @@ ViewerLineRect.propTypes = {
subEntities: PropTypes.array.isRequired,
seed: PropTypes.array.isRequired,
cLabel: PropTypes.string.isRequired,
xLabel: PropTypes.string.isRequired,
yLabel: PropTypes.string.isRequired,
layoutSt: PropTypes.string.isRequired,
feature: PropTypes.object.isRequired,
tTrEndPts: PropTypes.array.isRequired,
Expand Down
7 changes: 3 additions & 4 deletions src/components/d3_line_rect/rect_focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ class RectFocus {
const { xt, yt } = TfRescale(this);
this.updatePathCall(xt, yt);

// const yRef = this.tTrEndPts[0].y;
const yRef = 0;
const yRef = this.tTrEndPts[0].y;

const bars = this.bars.selectAll('rect')
.data(this.data);
Expand Down Expand Up @@ -219,7 +218,7 @@ class RectFocus {
if (this.data && this.data.length > 0) {
this.setConfig(sweepExtentSt);
this.drawBar();
// this.drawThres();
this.drawThres();
this.drawGrid();
}
MountBrush(this, isUiAddIntgSt, isUiNoBrushSt, this.brushClass);
Expand All @@ -235,7 +234,7 @@ class RectFocus {
if (this.data && this.data.length > 0) {
this.setConfig(sweepExtentSt);
this.drawBar();
// this.drawThres();
this.drawThres();
this.drawGrid();
}
MountBrush(this, isUiAddIntgSt, isUiNoBrushSt, this.brushClass);
Expand Down
1 change: 1 addition & 0 deletions src/components/hplc_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class HPLCViewer extends React.Component { // eslint-disable-line
operations={operations}
editorOnly={true}
hideThreshold={true}
hideMainEditTools={true}
/>
<div className="react-spectrum-editor">
<Grid container>
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/chem.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ const extrFeaturesMs = (jcamp, layout, peakUp) => {
// }
// // workaround for legacy design
const thresRef = (jcamp.info && jcamp.info.$CSTHRESHOLD * 100) || 5;
console.log('thresRef', thresRef);
const base = jcamp.spectra[0];

const features = jcamp.spectra.map((s) => {
Expand Down Expand Up @@ -887,4 +888,5 @@ export {
GetCyclicVoltaRatio, GetCyclicVoltaPeakSeparate,
Feature2MaxMinPeak, convertTopic, Convert2MaxMinPeak,
GetCyclicVoltaShiftOffset, GetCyclicVoltaPreviousShift,
convertThresEndPts,
};
10 changes: 10 additions & 0 deletions src/reducers/reducer_hplc_ms.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const initialState = {
tic: {
isNegative: false,
},
threshold: {
isEdit: true,
value: false,
},
};

const updateHPLCData = (state, action) => {
Expand All @@ -28,8 +32,14 @@ const updateHPLCData = (state, action) => {
listWaveLength,
selectedWaveLength: listWaveLength[0],
});
const postiveCurves = payload[3];
const { thresRef } = postiveCurves.features[0];
return Object.assign({}, state, {
uvvis: newUvvis,
threshold: {
isEdit: true,
value: thresRef,
},
});
}
return state;
Expand Down

0 comments on commit cf4504f

Please sign in to comment.