Skip to content

Commit

Permalink
feat(chromatogram extraction): fix and update isolation window target…
Browse files Browse the repository at this point in the history
… extraction

Now able to extract both precursor and product isolation window target m/z, respectively.

fix #3
  • Loading branch information
vimalnathnambiar committed Mar 28, 2024
1 parent 3ecd54a commit 1439919
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 38 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,42 @@ Data extraction and spectrum filtration have been tested on data acquired from t
<tr>
<th>Instrument Vendor</th>
<th>MS Platform</th>
<th>Status</th>
</tr>
<tr>
<td rowspan="4">Bruker</td>
<td>EVOQ TQ-MS</td>
<td>Not Working</td>
</tr>
<tr>
<td rowspan="3">Bruker</td>
<td>ImpactII QToF-MS</td>
<td>Working</td>
</tr>
<tr>
<td>solariX MRMS</td>
<td>Working</td>
</tr>
<tr>
<tr>
<td>timsTOFPro TIMS-ToF-MS</td>
<td>Not Working</td>
</tr>
<tr>
<td rowspan="3">Waters</td>
<td>XEVOTQXS TQ-MS</td>
<td>Working</td>
</tr>
<tr>
<td>XEVOTQXS DESI-MS</td>
<td>XEVOG2XSQTOF DESI-MS</td>
<td>Working</td>
</tr>
<tr>
<td>XEVOG2XSQTOF REIMS</td>
<td>Working</td>
</tr>
<tr>
<td>SCIEX</td>
<td>QTRAP6500+ TQ-MS</td>
<td>Working</td>
</tr>
</table>

Expand Down
23 changes: 16 additions & 7 deletions src/__tests__/initChromatogramArray.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ describe('initChromatogramArray', () => {
chromatogramType: 'total ion current chromatogram',
polarity: null,
dwellTime: null,
isolationWindowTarget: null,
precursorIsolationWindowTarget: null,
collisionType: null,
collisionEnergy: null,
productIsolationWindowTarget: null,
timeArray: [],
intensityArray: [],
msLevelArray: [],
Expand All @@ -32,9 +33,10 @@ describe('initChromatogramArray', () => {
chromatogramType: 'base peak chromatogram',
polarity: null,
dwellTime: null,
isolationWindowTarget: null,
precursorIsolationWindowTarget: null,
collisionType: null,
collisionEnergy: null,
productIsolationWindowTarget: null,
timeArray: [],
intensityArray: [],
msLevelArray: [],
Expand Down Expand Up @@ -68,9 +70,10 @@ describe('initChromatogramArray', () => {
chromatogramType: 'extracted ion chromatogram',
polarity: null,
dwellTime: null,
isolationWindowTarget: null,
precursorIsolationWindowTarget: null,
collisionType: null,
collisionEnergy: null,
productIsolationWindowTarget: null,
timeArray: [],
intensityArray: [],
msLevelArray: [],
Expand All @@ -96,15 +99,18 @@ describe('initChromatogramArray', () => {
expect(chromatogram[0].dwellTime).toStrictEqual(
testBasicChromatogram[0].dwellTime,
);
expect(chromatogram[0].isolationWindowTarget).toStrictEqual(
testBasicChromatogram[0].isolationWindowTarget,
expect(chromatogram[0].precursorIsolationWindowTarget).toStrictEqual(
testBasicChromatogram[0].precursorIsolationWindowTarget,
);
expect(chromatogram[0].collisionType).toStrictEqual(
testBasicChromatogram[0].collisionType,
);
expect(chromatogram[0].collisionEnergy).toStrictEqual(
testBasicChromatogram[0].collisionEnergy,
);
expect(chromatogram[0].productIsolationWindowTarget).toStrictEqual(
testBasicChromatogram[0].productIsolationWindowTarget,
);
expect(chromatogram[0].timeArray).toStrictEqual(
testBasicChromatogram[0].timeArray,
);
Expand Down Expand Up @@ -139,15 +145,18 @@ describe('initChromatogramArray', () => {
expect(chromatogram[3].dwellTime).toStrictEqual(
testTargetedChromatogram[3].dwellTime,
);
expect(chromatogram[3].isolationWindowTarget).toStrictEqual(
testTargetedChromatogram[3].isolationWindowTarget,
expect(chromatogram[3].precursorIsolationWindowTarget).toStrictEqual(
testTargetedChromatogram[3].precursorIsolationWindowTarget,
);
expect(chromatogram[3].collisionType).toStrictEqual(
testTargetedChromatogram[3].collisionType,
);
expect(chromatogram[3].collisionEnergy).toStrictEqual(
testTargetedChromatogram[3].collisionEnergy,
);
expect(chromatogram[3].productIsolationWindowTarget).toStrictEqual(
testTargetedChromatogram[3].productIsolationWindowTarget,
);
expect(chromatogram[3].timeArray).toStrictEqual(
testTargetedChromatogram[3].timeArray,
);
Expand Down
19 changes: 8 additions & 11 deletions src/__tests__/parseMZML.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,19 @@ describe('parseMZML', () => {
expect(await parseMZML(testConfigParam));
});

// ! Uncovered Lines - extractChromatogram.js line 55, 62, 79, 105
// Line 55 - Assignation of value (mappedValue || paramValue) works but don't know why it doesn't pick up in test
// Line 62 - userParamMap array check with the test data is always false
// Line 79 - isolationWindowMap.cvParam array check with the test data is always false
// Line 105 - binaryData.cvParam array check with the test data is always true
// ! Uncovered Lines - extractChromatogram.js line 91-92, 125-126
// Test data only consist of isolationWindowTarget for the mappedKey (Both precursor and product data)

// ! Uncovered Lines - extractSpectrum.js line 69, 107, 147, 161
// ! Uncovered Lines - extractSpectrum.js line 69, 107, 150, 165
// Line 69 - spectrumData.cvParam array check with test data is always true
// Line 107 - scanWindowMap.cvParam array check with test data is always true
// Line 147 - activationMap.cvParam array check with test data is always true
// Line 161 - binaryData.cvParam array check with the test data is always true
// Line 150 - activationMap.cvParam array check with test data is always true
// Line 165 - binaryData.cvParam array check with the test data is always true

// ! Uncovered Lines - filterSpectra.js line 97-108, 115-117, 127-136
// Line 95-106 - Calculation of mass accuracy if m/z falls within range works, but don't know why it doesn't pick up in test
// Line 112-114 - Assignation of new basePeakIntensity and basePeakMZ works, but don't know why it doesn't pick up in test
// Line 124-133 - Pushing chromatogram data based on spectrum data filtering works, but don't know why it doesn't pick up in test
// Line 95-108 - Calculation of mass accuracy if m/z falls within range works, but don't know why it doesn't pick up in test
// Line 115-117 - Assignation of new basePeakIntensity and basePeakMZ works, but don't know why it doesn't pick up in test
// Line 127-136 - Pushing chromatogram data based on spectrum data filtering works, but don't know why it doesn't pick up in test

// ! Fail to catch decoder() input type error - Code won't reach: decoder.js line 15, 17, 19, 21, 23-24
// If decoder() throws an error - it is caught and handled within parseMZML()
Expand Down
13 changes: 10 additions & 3 deletions src/__tests__/typedef.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ describe('typedef', () => {
chromatogramType: 'total ion current chromatogram',
polarity: null,
dwellTime: null,
isolationWindowTarget: null,
precursorIsolationWindowTarget: null,
collisionType: null,
collisionEnergy: null,
productIsolationWindowTarget: null,
timeArray: [0.0031, 0.0052, 0.0074],
intensityArray: [996, 1346, 50390],
msLevelArray: [1, 1, 2],
Expand All @@ -209,9 +210,10 @@ describe('typedef', () => {
chromatogramType: 'base peak chromatogram',
polarity: null,
dwellTime: null,
isolationWindowTarget: null,
precursorIsolationWindowTarget: null,
collisionType: null,
collisionEnergy: null,
productIsolationWindowTarget: null,
timeArray: [0.0031, 0.0052, 0.0074],
intensityArray: [370, 390, 38150],
msLevelArray: [1, 1, 2],
Expand Down Expand Up @@ -281,9 +283,14 @@ describe('typedef', () => {
expect(testData.chromatogram[0]).toHaveProperty('chromatogramType');
expect(testData.chromatogram[0]).toHaveProperty('polarity');
expect(testData.chromatogram[0]).toHaveProperty('dwellTime');
expect(testData.chromatogram[0]).toHaveProperty('isolationWindowTarget');
expect(testData.chromatogram[0]).toHaveProperty(
'precursorIsolationWindowTarget',
);
expect(testData.chromatogram[0]).toHaveProperty('collisionType');
expect(testData.chromatogram[0]).toHaveProperty('collisionEnergy');
expect(testData.chromatogram[0]).toHaveProperty(
'productIsolationWindowTarget',
);
expect(testData.chromatogram[0]).toHaveProperty('timeArray');
expect(testData.chromatogram[0]).toHaveProperty('intensityArray');
expect(testData.chromatogram[0]).toHaveProperty('msLevelArray');
Expand Down
3 changes: 2 additions & 1 deletion src/typedef/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@
* @property {?string} chromatogramType Chromatogram type
* @property {?string} polarity Polarity
* @property {?number} dwellTime Dwell time
* @property {?number} isolationWindowTarget Isolation window target
* @property {?number} precursorIsolationWindowTarget Precursor isolation window target
* @property {?string} collisionType Collision type
* @property {?number} collisionEnergy Collision energy
* @property {?number} productIsolationWindowTarget Product isolation window target
* @property {[]|number[]} timeArray Retention time array
* @property {[]|number[]} intensityArray Intensity array
* @property {[]|number[]} msLevelArray MS level array
Expand Down
40 changes: 35 additions & 5 deletions src/utils/extractChromatogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export async function extractChromatogram(configParam, chromatogramArray) {
const cvParamMap = chromatogramData.cvParam;
const userParamMap = chromatogramData.userParam;
const precursorMap = chromatogramData.precursor;
const productMap = chromatogramData.product;
const binaryDataArrayMap =
chromatogramData.binaryDataArrayList.binaryDataArray;

Expand All @@ -34,9 +35,10 @@ export async function extractChromatogram(configParam, chromatogramArray) {
chromatogramType: null,
polarity: null,
dwellTime: null,
isolationWindowTarget: null,
precursorIsolationWindowTarget: null,
collisionType: null,
collisionEnergy: null,
productIsolationWindowTarget: null,
timeArray: [],
intensityArray: [],
msLevelArray: [],
Expand All @@ -49,8 +51,8 @@ export async function extractChromatogram(configParam, chromatogramArray) {
: [cvParamMap];
for (const cvParam of chromatogramCvParam) {
const mappedKey = keyMap[cvParam.$name];
let paramValue = cvParam.$value;
const mappedValue = valueMap[cvParam.$name];
const paramValue = cvParam.$value;
if (mappedKey) {
data[mappedKey] = mappedValue || paramValue;
}
Expand All @@ -63,8 +65,9 @@ export async function extractChromatogram(configParam, chromatogramArray) {
: [userParamMap];
for (const cvParam of userCvParam) {
const mappedKey = keyMap[cvParam.$name];
const paramValue = cvParam.$value;
if (mappedKey) {
data[mappedKey] = cvParam.$value;
data[mappedKey] = paramValue;
}
}
}
Expand All @@ -80,8 +83,13 @@ export async function extractChromatogram(configParam, chromatogramArray) {
: [isolationWindowMap.cvParam];
for (const cvParam of isolationWindowCvParam) {
const mappedKey = keyMap[cvParam.$name];
const paramValue = cvParam.$value;
if (mappedKey) {
data[mappedKey] = cvParam.$value;
if (mappedKey === 'isolationWindowTarget') {
data.precursorIsolationWindowTarget = paramValue;
} else {
data[mappedKey] = paramValue;
}
}
}

Expand All @@ -92,8 +100,30 @@ export async function extractChromatogram(configParam, chromatogramArray) {
for (const cvParam of activationCvParam) {
const mappedKey = keyMap[cvParam.$name];
const mappedValue = valueMap[cvParam.$name];
const paramValue = cvParam.$value;
if (mappedKey) {
data[mappedKey] = mappedValue || paramValue;
}
}
}

// Product data
if (productMap) {
const isolationWindowMap = productMap.isolationWindow;

// Isolation window parameters
const isolationWindowCvParam = Array.isArray(isolationWindowMap.cvParam)
? isolationWindowMap.cvParam
: [isolationWindowMap.cvParam];
for (const cvParam of isolationWindowCvParam) {
const mappedKey = keyMap[cvParam.$name];
const paramValue = cvParam.$value;
if (mappedKey) {
data[mappedKey] = mappedValue || cvParam.$value;
if (mappedKey === 'isolationWindowTarget') {
data.productIsolationWindowTarget = paramValue;
} else {
data[mappedKey] = paramValue;
}
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/utils/extractSpectrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export async function extractSpectrum(
: [spectrumData.cvParam];
for (const cvParam of spectrumCvParam) {
const mappedKey = keyMap[cvParam.$name];
let paramValue = cvParam.$value;
const mappedValue = valueMap[cvParam.$name];
let paramValue = cvParam.$value;

if (mappedKey) {
if (mappedKey === 'basePeakMZ') {
Expand Down Expand Up @@ -107,8 +107,9 @@ export async function extractSpectrum(
: [scanWindowMap.cvParam];
for (const cvParam of scanWindowCvParam) {
const mappedKey = keyMap[cvParam.$name];
const paramValue = cvParam.$value;
if (mappedKey) {
data[mappedKey] = cvParam.$value;
data[mappedKey] = paramValue;
}
}

Expand All @@ -125,8 +126,9 @@ export async function extractSpectrum(
: [isolationWindowMap.cvParam];
for (const cvParam of isolationWindowCvParam) {
const mappedKey = keyMap[cvParam.$name];
const paramValue = cvParam.$value;
if (mappedKey) {
data[mappedKey] = cvParam.$value;
data[mappedKey] = paramValue;
}
}

Expand All @@ -136,8 +138,9 @@ export async function extractSpectrum(
: [selectedIonMap.cvParam];
for (const cvParam of selectedIonCvParam) {
const mappedKey = keyMap[cvParam.$name];
const paramValue = cvParam.$value;
if (mappedKey) {
data[mappedKey] = cvParam.$value;
data[mappedKey] = paramValue;
}
}

Expand All @@ -148,8 +151,9 @@ export async function extractSpectrum(
for (const cvParam of activationCvParam) {
const mappedKey = keyMap[cvParam.$name];
const mappedValue = valueMap[cvParam.$name];
const paramValue = cvParam.$value;
if (mappedKey) {
data[mappedKey] = mappedValue || cvParam.$value;
data[mappedKey] = mappedValue || paramValue;
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/utils/initChromatogramArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export async function initChromatogramArray(configParam) {
chromatogramType: 'total ion current chromatogram',
polarity: null,
dwellTime: null,
isolationWindowTarget: null,
precursorIsolationWindowTarget: null,
collisionType: null,
collisionEnergy: null,
productIsolationWindowTarget: null,
timeArray: [],
intensityArray: [],
msLevelArray: [],
Expand All @@ -34,9 +35,10 @@ export async function initChromatogramArray(configParam) {
chromatogramType: 'base peak chromatogram',
polarity: null,
dwellTime: null,
isolationWindowTarget: null,
precursorIsolationWindowTarget: null,
collisionType: null,
collisionEnergy: null,
productIsolationWindowTarget: null,
timeArray: [],
intensityArray: [],
msLevelArray: [],
Expand All @@ -55,9 +57,10 @@ export async function initChromatogramArray(configParam) {
chromatogramType: 'extracted ion chromatogram',
polarity: null,
dwellTime: null,
isolationWindowTarget: null,
precursorIsolationWindowTarget: null,
collisionType: null,
collisionEnergy: null,
productIsolationWindowTarget: null,
timeArray: [],
intensityArray: [],
msLevelArray: [],
Expand Down

0 comments on commit 1439919

Please sign in to comment.