Comparing version 1.4.0 to 1.4.1
{ | ||
"name": "mf-finder", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Find a molecular formula from a monoisotopic mass", | ||
@@ -27,3 +27,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "988291b8d79f39fc2074f384845dd5878dea19fd" | ||
"gitHead": "e4ecee35a3769aa536b1d334de748deb5b8aefd8" | ||
} |
@@ -147,2 +147,16 @@ 'use strict'; | ||
it('ethylbenzene with uniqueMF', async () => { | ||
let result1 = await findMFs(519.127524, { | ||
ranges: 'C0-100 H0-200 N0-20 O0-20 F0-3', | ||
allowNeutral: true, | ||
uniqueMFs: false, | ||
}); | ||
let result2 = await findMFs(519.127524, { | ||
ranges: 'C0-100 H0-200 N0-20 O0-20 F0-3', | ||
allowNeutral: true, | ||
uniqueMFs: true, | ||
}); | ||
expect(result1.mfs).toHaveLength(result2.mfs.length); | ||
}); | ||
it('ethane with groups in parenthesis and uniqueMF', async () => { | ||
@@ -149,0 +163,0 @@ let result = await findMFs(30.04695, { |
@@ -174,4 +174,4 @@ 'use strict'; | ||
if (result.mfs.length > 2 * limit) { | ||
if (uniqueMFs) ensureUniqueMF(result); | ||
result.mfs.sort((a, b) => Math.abs(a.ms.ppm) - Math.abs(b.ms.ppm)); | ||
if (uniqueMFs) ensureUniqueMF(result); | ||
result.mfs.length = limit; | ||
@@ -213,4 +213,4 @@ } | ||
if (uniqueMFs) ensureUniqueMF(result); | ||
result.mfs.sort((a, b) => Math.abs(a.ms.ppm) - Math.abs(b.ms.ppm)); | ||
if (uniqueMFs) ensureUniqueMF(result); | ||
if (result.mfs.length > limit) { | ||
@@ -229,2 +229,3 @@ result.mfs.length = limit; | ||
function ensureUniqueMF(result) { | ||
result.mfs.sort((a, b) => a.em - b.em); | ||
let previousEM = 0; | ||
@@ -240,2 +241,3 @@ let bestCounts = []; | ||
for (let i = 0; i < current.currentCounts.length; i++) { | ||
// better priority ??? | ||
if (current.currentCounts[i] > bestCounts[i]) { | ||
@@ -252,4 +254,2 @@ mfs.pop(); | ||
} | ||
// better priority ??? | ||
} | ||
@@ -256,0 +256,0 @@ } |
33918
974