Comparing version 0.6.4 to 0.7.0
{ | ||
"name": "emdb", | ||
"version": "0.6.4", | ||
"version": "0.7.0", | ||
"description": "Database manager for exact mass query", | ||
@@ -25,11 +25,11 @@ "browser": { | ||
"dependencies": { | ||
"isotopic-distribution": "^0.6.4", | ||
"isotopic-distribution": "^0.7.0", | ||
"jszip": "^3.1.5", | ||
"mf-finder": "^0.6.4", | ||
"mf-from-google-sheet": "^0.6.4", | ||
"mf-generator": "^0.6.4", | ||
"mf-matcher": "^0.6.4", | ||
"mf-parser": "^0.6.4", | ||
"mf-utilities": "^0.6.4", | ||
"nucleotide": "^0.6.4", | ||
"mf-finder": "^0.7.0", | ||
"mf-from-google-sheet": "^0.7.0", | ||
"mf-generator": "^0.7.0", | ||
"mf-matcher": "^0.7.0", | ||
"mf-parser": "^0.7.0", | ||
"mf-utilities": "^0.7.0", | ||
"nucleotide": "^0.7.0", | ||
"peaks-similarity": "^2.3.0", | ||
@@ -36,0 +36,0 @@ "peptide": "^1.6.1", |
@@ -5,4 +5,2 @@ 'use strict'; | ||
jest.setTimeout(30000); | ||
test('test DBManager contaminants and knapSack', async () => { | ||
@@ -16,3 +14,3 @@ let dbManager = new DBManager(); | ||
expect(dbManager.get('contaminants').length).toBeGreaterThan(1000); | ||
}); | ||
}, 30000); | ||
@@ -22,5 +20,3 @@ test('test DBManager fromMonoisotopicMass', () => { | ||
dbManager.fromMonoisotopicMass(300, { | ||
ionizations: 'H+,Na+' | ||
}); | ||
dbManager.fromMonoisotopicMass(300, { ionizations: 'H+,Na+' }); | ||
@@ -27,0 +23,0 @@ expect(dbManager.listDatabases()).toEqual(['monoisotopic']); |
@@ -5,13 +5,13 @@ 'use strict'; | ||
test('test load google sheet', async () => { | ||
let data = await loadGoogleSheet(); | ||
expect(data.length).toBeGreaterThan(1000); | ||
let data = await loadGoogleSheet(); | ||
expect(data.length).toBeGreaterThan(1000); | ||
let first = data[0]; | ||
expect(first.mf).toBe('CN'); | ||
expect(first.ionization).toEqual({ charge: -1, em: 0, mf: '(-)' }); | ||
expect(first.em).toBeGreaterThan(0); | ||
expect(first.ms.charge).not.toBe(0); | ||
expect(first.ms.em).toBeGreaterThan(0); | ||
}); | ||
let first = data[0]; | ||
expect(first.mf).toBe('CN'); | ||
expect(first.ionization).toEqual({charge: -1, em: 0, mf: '(-)'}); | ||
expect(first.em).toBeGreaterThan(0); | ||
expect(first.ms.charge).not.toBe(0); | ||
expect(first.ms.em).toBeGreaterThan(0); | ||
}, 10000); |
@@ -17,44 +17,40 @@ 'use strict'; | ||
* @param {number} [options.allowNeutralMolecules=false] - Should we display uncharged molecules (non observable by mass) | ||
* @param {number} [options.url='https://pubchem2.cheminfo.org/mfs/em'] - URL of the webservice | ||
* @param {number} [options.url='https://pubchem.cheminfo.org/mfs/em'] - URL of the webservice | ||
*/ | ||
module.exports = async function searchPubchem(mass, options = {}) { | ||
const { | ||
url = 'https://pubchem2.cheminfo.org/mfs/em', | ||
precision = 1000, | ||
allowNeutralMolecules = false | ||
} = options; | ||
const { | ||
url = 'https://pubchem.cheminfo.org/mfs/em', | ||
precision = 1000, | ||
allowNeutralMolecules = false | ||
} = options; | ||
let promises = []; | ||
let ionizations = preprocessIonizations(options.ionizations); | ||
for (let ionization of ionizations) { | ||
let realMass = mass * ionization.charge - ionization.em; | ||
promises.push(fetch(`${url}?em=${realMass}&precision=${precision}`)); | ||
} | ||
let promises = []; | ||
let ionizations = preprocessIonizations(options.ionizations); | ||
for (let ionization of ionizations) { | ||
let realMass = mass * ionization.charge - ionization.em; | ||
promises.push(fetch(`${url}?em=${realMass}&precision=${precision}`)); | ||
} | ||
let results = await Promise.all(promises); | ||
let results = await Promise.all(promises); | ||
let mfs = []; | ||
for (let i = 0; i < results.length; i++) { | ||
for (let mf of results[i].result) { | ||
try { | ||
let mfInfo = new mfParser.MF(mf.mf).getInfo(); | ||
mfInfo.ionization = ionizations[i]; | ||
mfInfo.em = mfInfo.monoisotopicMass; | ||
mfInfo.ms = getMsInfo(mfInfo, { | ||
targetMass: mass, | ||
allowNeutralMolecules | ||
}); | ||
mfInfo.info = { | ||
nbPubchemEntries: mf.total | ||
}; | ||
mfs.push(mfInfo); | ||
} catch (e) { | ||
console.warn(`${e}`); | ||
} | ||
} | ||
let mfs = []; | ||
for (let i = 0; i < results.length; i++) { | ||
for (let mf of results[i].result) { | ||
try { | ||
let mfInfo = new mfParser.MF(mf.mf).getInfo(); | ||
mfInfo.ionization = ionizations[i]; | ||
mfInfo.em = mfInfo.monoisotopicMass; | ||
mfInfo.ms = | ||
getMsInfo(mfInfo, {targetMass: mass, allowNeutralMolecules}); | ||
mfInfo.info = {nbPubchemEntries: mf.total}; | ||
mfs.push(mfInfo); | ||
} catch (e) { | ||
console.warn(`${e}`); | ||
} | ||
} | ||
// because we can combine many ionizations we should resort the data | ||
mfs.sort((a, b) => a.ms.ppm - b.ms.ppm); | ||
return mfs; | ||
} | ||
// because we can combine many ionizations we should resort the data | ||
mfs.sort((a, b) => a.ms.ppm - b.ms.ppm); | ||
return mfs; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
97365
1010
+ Addedatom-sorter@0.7.0(transitive)
+ Addedchemical-elements@0.7.0(transitive)
+ Addedchemical-groups@0.7.0(transitive)
+ Addedisotopic-distribution@0.7.0(transitive)
+ Addedmf-finder@0.7.0(transitive)
+ Addedmf-from-google-sheet@0.7.0(transitive)
+ Addedmf-generator@0.7.0(transitive)
+ Addedmf-matcher@0.7.0(transitive)
+ Addedmf-parser@0.7.0(transitive)
+ Addedmf-utilities@0.7.0(transitive)
+ Addednucleotide@0.7.0(transitive)
- Removedatom-sorter@0.6.4(transitive)
- Removedchemical-elements@0.6.4(transitive)
- Removedchemical-groups@0.6.4(transitive)
- Removedisotopic-distribution@0.6.4(transitive)
- Removedmf-finder@0.6.4(transitive)
- Removedmf-from-google-sheet@0.6.4(transitive)
- Removedmf-generator@0.6.4(transitive)
- Removedmf-matcher@0.6.4(transitive)
- Removedmf-parser@0.6.4(transitive)
- Removedmf-utilities@0.6.4(transitive)
- Removednucleotide@0.6.4(transitive)
Updatedisotopic-distribution@^0.7.0
Updatedmf-finder@^0.7.0
Updatedmf-from-google-sheet@^0.7.0
Updatedmf-generator@^0.7.0
Updatedmf-matcher@^0.7.0
Updatedmf-parser@^0.7.0
Updatedmf-utilities@^0.7.0
Updatednucleotide@^0.7.0