Comparing version 1.5.0 to 1.6.0
{ | ||
"name": "emdb", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "Database manager for exact mass query", | ||
@@ -26,5 +26,5 @@ "main": "src/index.js", | ||
"jszip": "^3.7.1", | ||
"mf-finder": "^1.2.0", | ||
"mf-from-google-sheet": "^1.1.24", | ||
"mf-generator": "^1.3.12", | ||
"mf-finder": "^1.2.1", | ||
"mf-from-google-sheet": "^1.1.25", | ||
"mf-generator": "^1.3.13", | ||
"mf-matcher": "^1.1.19", | ||
@@ -36,3 +36,3 @@ "mf-parser": "^1.4.0", | ||
"ml-regression-theil-sen": "^2.0.0", | ||
"ms-spectrum": "^1.4.6", | ||
"ms-spectrum": "^1.4.7", | ||
"nucleotide": "^1.2.14", | ||
@@ -42,3 +42,3 @@ "peaks-similarity": "^2.3.1", | ||
}, | ||
"gitHead": "0ccc601b2ba051652963fad05479902943d7feaf" | ||
"gitHead": "0b932f49c82fd9fb2ef0804c1430b1499426ef95" | ||
} |
@@ -15,6 +15,6 @@ 'use strict'; | ||
test('DBManager fromMonoisotopicMass', () => { | ||
test('DBManager fromMonoisotopicMass', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromMonoisotopicMass(300, { ionizations: 'H+,Na+' }); | ||
await dbManager.fromMonoisotopicMass(300, { ionizations: 'H+,Na+' }); | ||
@@ -21,0 +21,0 @@ expect(dbManager.listDatabases()).toStrictEqual(['monoisotopic']); |
@@ -5,6 +5,6 @@ 'use strict'; | ||
test('loadTest', () => { | ||
test('loadTest', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadTest(); | ||
await dbManager.loadTest(); | ||
expect(dbManager.databases.test).toMatchSnapshot(); | ||
}); |
@@ -13,5 +13,5 @@ 'use strict'; | ||
let experimental = loadEthylbenzene(); | ||
it('should find one result with bad distribution', () => { | ||
it('should find one result with bad distribution', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromMonoisotopicMass(106.077, { | ||
await dbManager.fromMonoisotopicMass(106.077, { | ||
ionizations: 'Na+,K+,(H+),(H+)2,(H+)3,+', | ||
@@ -32,3 +32,3 @@ ranges: 'C0-100 H0-100 N0-100 O0-100', | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
filter: {}, | ||
@@ -35,0 +35,0 @@ similarity: { |
@@ -19,5 +19,5 @@ /* eslint-disable import/no-extraneous-dependencies */ | ||
it('should find one result with bad distribution', () => { | ||
it('should find one result with bad distribution', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromPeptidicSequence( | ||
await dbManager.fromPeptidicSequence( | ||
// 'KKK', | ||
@@ -38,3 +38,3 @@ 'MQIFVKTLTGKTITLEVEPSDTIENVKAKIQDKEGIPPDQQ', | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
filter: {}, | ||
@@ -101,5 +101,5 @@ similarity: { | ||
it('should find one result with bad distribution and string fucntion', () => { | ||
it('should find one result with bad distribution and string fucntion', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromPeptidicSequence( | ||
await dbManager.fromPeptidicSequence( | ||
'MQIFVKTLTGKTITLEVEPSDTIENVKAKIQDKEGIPPDQQ', | ||
@@ -119,3 +119,3 @@ { | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
filter: {}, | ||
@@ -122,0 +122,0 @@ similarity: { |
@@ -6,7 +6,7 @@ 'use strict'; | ||
describe('test searchSimilarity', () => { | ||
it('should find one result with bad distribution', () => { | ||
it('should find one result with bad distribution', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadNeutralTest({ maxC: 10 }); | ||
await dbManager.loadNeutralTest({ maxC: 10 }); | ||
dbManager.setExperimentalSpectrum({ x: [41, 121], y: [1, 1] }); | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
ionizations: 'H+,(H+)2,(H+)3', // useless because the test database has already ionizations | ||
@@ -32,7 +32,7 @@ filter: {}, | ||
it('should find one result with callback', () => { | ||
it('should find one result with callback', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadNeutralTest({ maxC: 10 }); | ||
await dbManager.loadNeutralTest({ maxC: 10 }); | ||
dbManager.setExperimentalSpectrum({ x: [41, 121], y: [1, 1] }); | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
ionizations: 'H+,(H+)2,(H+)3', // useless because the test database has already ionizations | ||
@@ -47,7 +47,7 @@ filter: { | ||
it('should find one result with wrong callback', () => { | ||
it('should find one result with wrong callback', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadNeutralTest({ maxC: 10 }); | ||
await dbManager.loadNeutralTest({ maxC: 10 }); | ||
dbManager.setExperimentalSpectrum({ x: [41, 121], y: [1, 1] }); | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
ionizations: 'H+,(H+)2,(H+)3', // useless because the test database has already ionizations | ||
@@ -62,7 +62,7 @@ filter: { | ||
it('should find one result with perfect match (small zone)', () => { | ||
it('should find one result with perfect match (small zone)', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadTest(); | ||
await dbManager.loadTest(); | ||
dbManager.setExperimentalSpectrum({ x: [120], y: [1] }); | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
ionizations: '+', | ||
@@ -84,7 +84,7 @@ filter: {}, | ||
it('should find one result with bad distribution, small zone, small width', () => { | ||
it('should find one result with bad distribution, small zone, small width', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadTest(); | ||
await dbManager.loadTest(); | ||
dbManager.setExperimentalSpectrum({ x: [120, 121], y: [1, 1] }); | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
ionizations: '+', | ||
@@ -109,7 +109,7 @@ filter: { | ||
it('should find no result because of filter', () => { | ||
it('should find no result because of filter', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadTest(); | ||
await dbManager.loadTest(); | ||
dbManager.setExperimentalSpectrum({ x: [120, 121], y: [1, 1] }); | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
ionizations: '+', | ||
@@ -124,7 +124,7 @@ filter: { | ||
it('should find one result with bad bad distribution, large window', () => { | ||
it('should find one result with bad bad distribution, large window', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadTest(); | ||
await dbManager.loadTest(); | ||
dbManager.setExperimentalSpectrum({ x: [120], y: [1] }); | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
ionizations: '+', | ||
@@ -148,7 +148,7 @@ filter: { | ||
it('should find one result with bad bad distribution, large window huge width', () => { | ||
it('should find one result with bad bad distribution, large window huge width', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadTest(); | ||
await dbManager.loadTest(); | ||
dbManager.setExperimentalSpectrum({ x: [120], y: [1] }); | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
ionizations: '+', | ||
@@ -172,7 +172,7 @@ filter: { | ||
it('should find one result with overlap', () => { | ||
it('should find one result with overlap', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadTest(); | ||
await dbManager.loadTest(); | ||
dbManager.setExperimentalSpectrum({ x: [120], y: [1] }); | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
ionizations: '+', | ||
@@ -196,7 +196,7 @@ filter: { | ||
it('should find one result with good distribution', () => { | ||
it('should find one result with good distribution', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.loadTest(); | ||
await dbManager.loadTest(); | ||
dbManager.setExperimentalSpectrum({ x: [120, 121], y: [1, 0.11] }); | ||
let results = dbManager.searchSimilarity({ | ||
let results = await dbManager.searchSimilarity({ | ||
ionizations: '+', | ||
@@ -203,0 +203,0 @@ filter: { |
@@ -6,11 +6,11 @@ 'use strict'; | ||
describe('fromArray', () => { | ||
it('using an array of string', () => { | ||
it('using an array of string', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromArray(['C.N', 'N.O']); | ||
await dbManager.fromArray(['C.N', 'N.O']); | ||
expect(dbManager.databases.generated).toHaveLength(4); | ||
}); | ||
it('with ranges and group', () => { | ||
it('with ranges and group', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromArray(['(CH2)0-2N0-1', 'O0-1']); | ||
await dbManager.fromArray(['(CH2)0-2N0-1', 'O0-1']); | ||
expect(dbManager.databases.generated).toHaveLength(12); | ||
@@ -34,5 +34,5 @@ let mfs = dbManager.databases.generated.map((entry) => entry.mf).sort(); | ||
it('with callback filter', () => { | ||
it('with callback filter', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromArray(['C0-100', 'H0-100'], { | ||
await dbManager.fromArray(['C0-100', 'H0-100'], { | ||
filter: { | ||
@@ -45,5 +45,5 @@ callback: (entry) => entry.atoms.C === entry.atoms.H, | ||
it('using an array or array', () => { | ||
it('using an array or array', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromArray(['C.N', ['Cl0-1', 'Br0-1']]); | ||
await dbManager.fromArray(['C.N', ['Cl0-1', 'Br0-1']]); | ||
let result = dbManager | ||
@@ -50,0 +50,0 @@ .get('generated') |
@@ -5,5 +5,5 @@ 'use strict'; | ||
test('fromMonoisotopicMass', () => { | ||
test('fromMonoisotopicMass', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromMonoisotopicMass(120, { | ||
await dbManager.fromMonoisotopicMass(120, { | ||
allowNeutral: true, | ||
@@ -14,5 +14,5 @@ }); | ||
test('fromMonoisotopicMass string', () => { | ||
test('fromMonoisotopicMass string', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromMonoisotopicMass('120,60', { | ||
await dbManager.fromMonoisotopicMass('120,60', { | ||
allowNeutral: true, | ||
@@ -23,5 +23,5 @@ }); | ||
test('fromMonoisotopicMass array', () => { | ||
test('fromMonoisotopicMass array', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromMonoisotopicMass([60, 120], { | ||
await dbManager.fromMonoisotopicMass([60, 120], { | ||
allowNeutral: true, | ||
@@ -32,5 +32,5 @@ }); | ||
test('fromMonoisotopicMass with ionizations', () => { | ||
test('fromMonoisotopicMass with ionizations', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromMonoisotopicMass(120, { | ||
await dbManager.fromMonoisotopicMass(120, { | ||
allowNeutral: false, | ||
@@ -43,5 +43,5 @@ ionizations: ', H+, K+', | ||
test('fromMonoisotopicMass large database', () => { | ||
test('fromMonoisotopicMass large database', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromMonoisotopicMass(1000, { | ||
await dbManager.fromMonoisotopicMass(1000, { | ||
ranges: 'C0-100 H0-100 N0-100 O0-100', | ||
@@ -48,0 +48,0 @@ filter: { |
@@ -11,5 +11,5 @@ /* eslint-disable import/no-extraneous-dependencies */ | ||
describe('fromNucleicSequence', () => { | ||
it('fromNucleicSequence', () => { | ||
it('fromNucleicSequence', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromNucleicSequence('AAA', { | ||
await dbManager.fromNucleicSequence('AAA', { | ||
ionizations: 'H+,Na+', | ||
@@ -40,5 +40,5 @@ fragmentation: { | ||
it('fromNucleicSequence ds-DNA', () => { | ||
it('fromNucleicSequence ds-DNA', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromNucleicSequence('AAA', { | ||
await dbManager.fromNucleicSequence('AAA', { | ||
ionizations: 'H+,Na+', | ||
@@ -59,5 +59,5 @@ fragmentation: { | ||
it('TACGTGCCAATAC internal fragment', () => { | ||
it('TACGTGCCAATAC internal fragment', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromNucleicSequence('TACGTGCCAATAC', { | ||
await dbManager.fromNucleicSequence('TACGTGCCAATAC', { | ||
ionizations: '(H+)-5', | ||
@@ -94,5 +94,5 @@ fragmentation: { | ||
it('TACGTGCCAATAC callback', () => { | ||
it('TACGTGCCAATAC callback', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromNucleicSequence('TACGTGCCAATAC', { | ||
await dbManager.fromNucleicSequence('TACGTGCCAATAC', { | ||
ionizations: '(H+)-5', | ||
@@ -116,5 +116,5 @@ fragmentation: { | ||
it('AGGCAG fragment', () => { | ||
it('AGGCAG fragment', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromNucleicSequence('AGGCAG', { | ||
await dbManager.fromNucleicSequence('AGGCAG', { | ||
ionizations: '(H+)-', | ||
@@ -133,5 +133,5 @@ fragmentation: { | ||
it('AGG with d-h2o and base loss', () => { | ||
it('AGG with d-h2o and base loss', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromNucleicSequence('AGG', { | ||
await dbManager.fromNucleicSequence('AGG', { | ||
ionizations: '(H+)-1', | ||
@@ -152,5 +152,5 @@ fragmentation: { | ||
it('HODamDamDamDamDamH', () => { | ||
it('HODamDamDamDamDamH', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromNucleicSequence('HODamDamDamDamDamH', { | ||
await dbManager.fromNucleicSequence('HODamDamDamDamDamH', { | ||
ionizations: '(H+)-', | ||
@@ -157,0 +157,0 @@ fragmentation: { |
@@ -6,5 +6,5 @@ 'use strict'; | ||
describe('fromPeptidicSequence', () => { | ||
it('AAKK', () => { | ||
it('AAKK', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromPeptidicSequence('AAKK', { | ||
await dbManager.fromPeptidicSequence('AAKK', { | ||
allowNeutralLoss: false, | ||
@@ -33,5 +33,5 @@ protonation: false, | ||
it('AAKK with callback', () => { | ||
it('AAKK with callback', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromPeptidicSequence('AAKK', { | ||
await dbManager.fromPeptidicSequence('AAKK', { | ||
allowNeutralLoss: false, | ||
@@ -59,5 +59,5 @@ protonation: false, | ||
it('AAKKKKKKKKKKKKKKKKKK allowNeutralLoss', () => { | ||
it('AAKKKKKKKKKKKKKKKKKK allowNeutralLoss', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromPeptidicSequence('AAKKKKKKKKKKKKKKKKKK', { | ||
await dbManager.fromPeptidicSequence('AAKKKKKKKKKKKKKKKKKK', { | ||
allowNeutralLoss: true, | ||
@@ -87,5 +87,5 @@ protonation: false, | ||
it('AAKKKKKKKKKKKKKKKKKK filter callback', () => { | ||
it('AAKKKKKKKKKKKKKKKKKK filter callback', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromPeptidicSequence('AAKKKKKKKKKKKKKKKKKK', { | ||
await dbManager.fromPeptidicSequence('AAKKKKKKKKKKKKKKKKKK', { | ||
ionizations: 'H+,Na+', | ||
@@ -103,5 +103,5 @@ fragmentation: { | ||
it('AAKKKKKK allowNeutralLoss limit: 1000', () => { | ||
it('AAKKKKKK allowNeutralLoss limit: 1000', async () => { | ||
let dbManager = new DBManager(); | ||
expect(() => { | ||
await expect( | ||
dbManager.fromPeptidicSequence('AAKKKKKKKKK', { | ||
@@ -116,2 +116,3 @@ allowNeutralLoss: true, | ||
}, | ||
filter: { | ||
@@ -123,9 +124,11 @@ minMSEM: 100, | ||
}, | ||
}); | ||
}).toThrow('processRange generates to many fragments (over 100)'); | ||
}), | ||
).rejects.toMatchInlineSnapshot( | ||
`[Error: processRange generates to many fragments (over 100)]`, | ||
); | ||
}); | ||
it('Linked AA(H-1#1)AA,GG(H-1#1)GG', () => { | ||
it('Linked AA(H-1#1)AA,GG(H-1#1)GG', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromPeptidicSequence('AA(H-1#1)AA,GG(H-1#2)GG', { | ||
await dbManager.fromPeptidicSequence('AA(H-1#1)AA,GG(H-1#2)GG', { | ||
links: { filter: true }, | ||
@@ -145,5 +148,5 @@ mfsArray: ['#1C6H4#2'], | ||
it('Optional linked AA(H-1#1)A,GG(H-1#1)G', () => { | ||
it('Optional linked AA(H-1#1)A,GG(H-1#1)G', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromPeptidicSequence('AA(H-1#1)A,GG(H-1#2)G', { | ||
await dbManager.fromPeptidicSequence('AA(H-1#1)A,GG(H-1#2)G', { | ||
links: { filter: true }, | ||
@@ -150,0 +153,0 @@ mfsArray: ['#1C6H4#2,'], |
@@ -6,17 +6,17 @@ 'use strict'; | ||
describe('fromRange', () => { | ||
it('no filter', () => { | ||
it('no filter', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromRange('C1-10, H1-10; Cl0-1 Br0-1'); | ||
await dbManager.fromRange('C1-10, H1-10; Cl0-1 Br0-1'); | ||
expect(dbManager.databases.generated).toHaveLength(80); | ||
}); | ||
it('with charge', () => { | ||
it('with charge', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromRange('C1-10 H1-10 (-)'); | ||
await dbManager.fromRange('C1-10 H1-10 (-)'); | ||
expect(dbManager.databases.generated[0].charge).toBe(-1); | ||
}); | ||
it('Filter callback', () => { | ||
it('Filter callback', async () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromRange('C0-4 H0-4', { | ||
await dbManager.fromRange('C0-4 H0-4', { | ||
filter: { | ||
@@ -23,0 +23,0 @@ callback: (entry) => entry.atoms.C - entry.atoms.H === 0, |
@@ -8,10 +8,11 @@ 'use strict'; | ||
* @param {array} mfsArray - Array of string or Array of array containing the parts to combine | ||
* @param {obejct} [options={}] | ||
* @param {object} [options={}] | ||
* @param {boolean} [options.estimate=false] - estimate the number of MF without filters | ||
* @param {string} [options.databaseName='generated'] | ||
* @param {function} [options.onStep] - Callback to do after each step | ||
* @param {number} [options.limit=10000000] - Maximum number of results | ||
* @param {boolean} [canonizeMF=true] - Canonize molecular formula | ||
* @param {boolean} [uniqueMFs=true] - Force canonization and make MF unique | ||
* @param {string} [ionizations=''] - Comma separated list of ionizations (to charge the molecule) | ||
* @param {number} [options.filter={}] | ||
* @param {boolean} [options.canonizeMF=true] - Canonize molecular formula | ||
* @param {boolean} [options.uniqueMFs=true] - Force canonization and make MF unique | ||
* @param {string} [options.ionizations=''] - Comma separated list of ionizations (to charge the molecule) | ||
* @param {object} [options.filter={}] | ||
* @param {number} [options.filter.minMass=0] - Minimal monoisotopic mass | ||
@@ -26,7 +27,7 @@ * @param {number} [options.filter.maxMass=+Infinity] - Maximal monoisotopic mass | ||
* | ||
* @param {number} [options.filter.unsaturation={}] | ||
* @param {object} [options.filter.unsaturation={}] | ||
* @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation | ||
* @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {boolean} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {boolean} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {object} [options.filter.atoms] - object of atom:{min, max} | ||
@@ -71,4 +72,4 @@ * @param {function} [options.filter.callback] - a function to filter the MF | ||
module.exports = function fromArray(mfsArray, options = {}) { | ||
module.exports = async function fromArray(mfsArray, options = {}) { | ||
return generateMFs(mfsArray, options); | ||
}; |
@@ -10,2 +10,3 @@ 'use strict'; | ||
* @param {number} [options.maxIterations=10000000] - Maximum number of iterations | ||
* @param {function} [options.onStep] - Callback to do after each step | ||
* @param {number} [options.limit=1000] - Maximum number of results | ||
@@ -25,5 +26,6 @@ * @param {string} [options.ionizations=''] - string containing a comma separated list of modifications | ||
* @param {function} [options.filter.callback] - a function to filter the MF | ||
* @returns {Promise} | ||
*/ | ||
module.exports = function fromMonoisotopicMass(masses, options = {}) { | ||
module.exports = async function fromMonoisotopicMass(masses, options = {}) { | ||
if (typeof masses === 'string') { | ||
@@ -35,3 +37,6 @@ masses = masses.split(/[ ,;\r\n\t]/).map(Number); | ||
} | ||
let results = masses.map((mass) => findMFs(mass, options)); | ||
let results = []; | ||
for (let mass of masses) { | ||
results.push(await findMFs(mass, options)); | ||
} | ||
return { | ||
@@ -38,0 +43,0 @@ mfs: results.map((entry) => entry.mfs).flat(), |
@@ -10,6 +10,7 @@ 'use strict'; | ||
* | ||
* @param {string} [sequence] Sequence as a string of 1 letter or 3 letters code. Could also be a correct molecular formula respecting uppercase, lowercase | ||
* @param {string} [sequencesString] Sequence as a string of 1 letter or 3 letters code. Could also be a correct molecular formula respecting uppercase, lowercase | ||
* @param {object} [options={}] | ||
* @param {boolean} [options.estimate=false] - estimate the number of MF without filters | ||
* @param {number} [options.limit=100000] | ||
* @param {boolean} [options.estimate=false] - estimate the number of MF without filters | ||
* @param {function} [options.onStep] - Callback to do after each step | ||
* @param {number} [options.limit=100000] | ||
* @param {string} [options.ionizations=''] | ||
@@ -43,10 +44,14 @@ * @param {object} [options.info={}] | ||
* @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge | ||
* @param {number} [options.filter.unsaturation={}] | ||
* @param {object} [options.filter.unsaturation={}] | ||
* @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation | ||
* @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {boolean} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {boolean} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @returns {Promise} | ||
*/ | ||
module.exports = function fromNucleicSequence(sequencesString, options = {}) { | ||
module.exports = async function fromNucleicSequence( | ||
sequencesString, | ||
options = {}, | ||
) { | ||
const { | ||
@@ -63,3 +68,2 @@ mfsArray = [], | ||
let sequences = nucleotide.sequenceToMF(sequencesString, info).split('.'); | ||
let fragmentsArray = sequences.slice(); | ||
@@ -83,3 +87,3 @@ | ||
let combined = combineMFs(mfsArray, { | ||
let combined = await combineMFs(mfsArray, { | ||
ionizations, | ||
@@ -86,0 +90,0 @@ filter, |
@@ -15,2 +15,3 @@ 'use strict'; | ||
* @param {string} [options.ionizations=''] | ||
* @param {function} [options.onStep] - Callback to do after each step | ||
* @param {array} [options.mfsArray=[]] | ||
@@ -54,11 +55,12 @@ * @param {boolean} [options.protonation=false] | ||
* @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge | ||
* @param {number} [options.filter.unsaturation={}] | ||
* @param {object} [options.filter.unsaturation={}] | ||
* @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation | ||
* @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {boolean} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {boolean} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {function} [options.filter.callback] - a function to filter the MF | ||
* @returns {Promise} | ||
*/ | ||
module.exports = function fromPeptidicSequence(sequences, options = {}) { | ||
module.exports = async function fromPeptidicSequence(sequences, options = {}) { | ||
const { | ||
@@ -100,3 +102,3 @@ digestion = {}, | ||
let combined = generateMFs(mfsArrayUnlinked, { | ||
let combined = await generateMFs(mfsArrayUnlinked, { | ||
ionizations, | ||
@@ -111,3 +113,3 @@ filter, | ||
combined.push( | ||
...generateMFs(mfsArrayLinked, { | ||
...(await generateMFs(mfsArrayLinked, { | ||
ionizations, | ||
@@ -118,3 +120,3 @@ filter, | ||
links, | ||
}), | ||
})), | ||
); | ||
@@ -121,0 +123,0 @@ } |
@@ -7,11 +7,12 @@ 'use strict'; | ||
* Generates a database 'generated' from an array of molecular formula | ||
* @param {string} range - a string representing the range to search | ||
* @param {string} rangesString - a string representing the range to search | ||
* @param {object} [options={}] | ||
* @param {boolean} [options.estimate=false] - estimate the number of MF without filters | ||
* @param {function} [options.onStep] - Callback to do after each step | ||
* @param {string} [options.databaseName='generated'] | ||
* @param {number} [options.limit=100000] - Maximum number of results | ||
* @param {boolean} [canonizeMF=true] - Canonize molecular formula | ||
* @param {boolean} [uniqueMFs=true] - Force canonization and make MF unique | ||
* @param {string} [ionizations=''] - Comma separated list of ionizations (to charge the molecule) | ||
* @param {number} [options.filter={}] | ||
* @param {boolean} [options.canonizeMF=true] - Canonize molecular formula | ||
* @param {boolean} [options.uniqueMFs=true] - Force canonization and make MF unique | ||
* @param {string} [options.ionizations=''] - Comma separated list of ionizations (to charge the molecule) | ||
* @param {object} [options.filter={}] | ||
* @param {number} [options.filter.minMass=0] - Minimal monoisotopic mass | ||
@@ -26,13 +27,12 @@ * @param {number} [options.filter.maxMass=+Infinity] - Maximal monoisotopic mass | ||
* | ||
* @param {number} [options.filter.unsaturation={}] | ||
* @param {object} [options.filter.unsaturation={}] | ||
* @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation | ||
* @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {boolean} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {boolean} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {function} [options.filter.callback] - a function to filter the MF | ||
* @param {object} [options.filter.atoms] - object of atom:{min, max} | ||
* | ||
* @returns {Promise} - list of possible molecular formula | ||
* | ||
* @returns {array} - list of possible molecular formula | ||
* | ||
* @example | ||
@@ -46,3 +46,3 @@ * const EMDB = require('emdb'); | ||
module.exports = function fromRange(rangesString, options = {}) { | ||
module.exports = async function fromRange(rangesString, options = {}) { | ||
let ranges = rangesString.split(/ *[;\r\n] */); | ||
@@ -49,0 +49,0 @@ for (let i = 0; i < ranges.length; i++) { |
@@ -86,12 +86,14 @@ 'use strict'; | ||
DBManager.prototype.loadTest = function loadTest() { | ||
this.fromArray(['C1-100'], { databaseName: 'test', ionizations: '+' }); | ||
DBManager.prototype.loadTest = async function loadTest() { | ||
await this.fromArray(['C1-100'], { databaseName: 'test', ionizations: '+' }); | ||
}; | ||
DBManager.prototype.loadNeutralTest = function loadNeutralTest(options = {}) { | ||
DBManager.prototype.loadNeutralTest = async function loadNeutralTest( | ||
options = {}, | ||
) { | ||
const { maxC = 100 } = options; | ||
this.fromArray([`C1-${maxC}`], { databaseName: 'test' }); | ||
await this.fromArray([`C1-${maxC}`], { databaseName: 'test' }); | ||
}; | ||
DBManager.prototype.fromMonoisotopicMass = function fromMonoisotopicMass( | ||
DBManager.prototype.fromMonoisotopicMass = async function fromMonoisotopicMass( | ||
mass, | ||
@@ -101,3 +103,3 @@ options = {}, | ||
const { databaseName = 'monoisotopic', append = false } = options; | ||
let result = require('./from/fromMonoisotopicMass')(mass, options); | ||
let result = await require('./from/fromMonoisotopicMass')(mass, options); | ||
replaceOrAppend(this, databaseName, result.mfs, append); | ||
@@ -107,5 +109,8 @@ return result; | ||
DBManager.prototype.fromArray = function fromArray(sequence, options = {}) { | ||
DBManager.prototype.fromArray = async function fromArray( | ||
sequence, | ||
options = {}, | ||
) { | ||
const { databaseName = 'generated', append = false, estimate } = options; | ||
const results = require('./from/fromArray')(sequence, options); | ||
const results = await require('./from/fromArray')(sequence, options); | ||
if (estimate) return results; | ||
@@ -115,5 +120,8 @@ replaceOrAppend(this, databaseName, results, append); | ||
DBManager.prototype.fromRange = function fromRange(sequence, options = {}) { | ||
DBManager.prototype.fromRange = async function fromRange( | ||
sequence, | ||
options = {}, | ||
) { | ||
const { databaseName = 'generated', append = false, estimate } = options; | ||
const results = require('./from/fromRange')(sequence, options); | ||
const results = await require('./from/fromRange')(sequence, options); | ||
if (estimate) return results; | ||
@@ -123,3 +131,3 @@ replaceOrAppend(this, databaseName, results, append); | ||
DBManager.prototype.fromPeptidicSequence = function fromPeptidicSequence( | ||
DBManager.prototype.fromPeptidicSequence = async function fromPeptidicSequence( | ||
sequence, | ||
@@ -129,3 +137,6 @@ options = {}, | ||
const { databaseName = 'peptidic', append = false, estimate } = options; | ||
const results = require('./from/fromPeptidicSequence')(sequence, options); | ||
const results = await require('./from/fromPeptidicSequence')( | ||
sequence, | ||
options, | ||
); | ||
if (estimate) return results; | ||
@@ -135,3 +146,24 @@ replaceOrAppend(this, databaseName, results, append); | ||
DBManager.prototype.fromNucleicSequence = function fromNucleicSequence( | ||
/** | ||
* | ||
* @param {string} databaseName | ||
* @param {object} [options={}] | ||
* @param {number} [options.precision=100] | ||
* @param {string} [options.ionizations=''] | ||
* @returns | ||
*/ | ||
DBManager.prototype.appendFragmentsInfo = async function appendFragmentsInfo( | ||
databaseName, | ||
options = {}, | ||
) { | ||
const database = this.databases[databaseName]; | ||
await require('./append/appendFragmentsInfo')( | ||
this.experimentalSpectrum, | ||
database, | ||
options, | ||
); | ||
return database; | ||
}; | ||
DBManager.prototype.fromNucleicSequence = async function fromNucleicSequence( | ||
sequence, | ||
@@ -141,3 +173,6 @@ options = {}, | ||
const { databaseName = 'nucleic', append = false, estimate } = options; | ||
const results = require('./from/fromNucleicSequence')(sequence, options); | ||
const results = await require('./from/fromNucleicSequence')( | ||
sequence, | ||
options, | ||
); | ||
if (estimate) return results; | ||
@@ -144,0 +179,0 @@ replaceOrAppend(this, databaseName, results, append); |
@@ -12,20 +12,20 @@ 'use strict'; | ||
* @param {boolean} [options.flatten=false] - should we return the array as a flat result | ||
* @param {string} [options.ionizations] - list the allowed ionizations possibilities | ||
* @param {object} [options.filter={}] | ||
* @param {string} [options.ionizations] - list the allowed ionizations possibilities | ||
* @param {number} [options.filter.targetMass] - Target mass, allows to calculate error and filter results | ||
* @param {Array<number>} [options.filter.targetMasses] - Target masses: SORTED array of numbers | ||
* @param {Array<number>} [options.filter.targetIntensities] - Target intensities: SORTED array of numbers | ||
* @param {number} [options.filter.minEM=0] - Minimal monoisotopic mass | ||
* @param {number} [options.filter.maxEM=+Infinity] - Maximal monoisotopic mass | ||
* @param {number} [options.filter.minMSEM=0] - Minimal monoisotopic mass observed by mass | ||
* @param {number} [options.filter.maxMSEM=+Infinity] - Maximal monoisotopic mass observed by mass | ||
* @param {number} [options.filter.minCharge=-Infinity] - Minimal charge | ||
* @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge | ||
* @param {object} [options.filter.unsaturation={}}] | ||
* @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation | ||
* @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {object} [options.filter.callback] - a function to filter the MF | ||
* @param {object} [options.filter.atoms] - object of atom:{min, max} | ||
* @param {number} [options.filter.targetMass] - Target mass, allows to calculate error and filter results | ||
* @param {Array<number>} [options.filter.targetMasses] - Target masses: SORTED array of numbers | ||
* @param {Array<number>} [options.filter.targetIntensities] - Target intensities: SORTED array of numbers | ||
* @param {number} [options.filter.minEM=0] - Minimal monoisotopic mass | ||
* @param {number} [options.filter.maxEM=+Infinity] - Maximal monoisotopic mass | ||
* @param {number} [options.filter.minMSEM=0] - Minimal monoisotopic mass observed by mass | ||
* @param {number} [options.filter.maxMSEM=+Infinity] - Maximal monoisotopic mass observed by mass | ||
* @param {number} [options.filter.minCharge=-Infinity] - Minimal charge | ||
* @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge | ||
* @param {object} [options.filter.unsaturation={}] | ||
* @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation | ||
* @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {object} [options.filter.callback] - a function to filter the MF | ||
* @param {object} [options.filter.atoms] - object of atom:{min, max} | ||
*/ | ||
@@ -32,0 +32,0 @@ |
@@ -10,2 +10,3 @@ 'use strict'; | ||
* @param {boolean} [options.flatten] - should we return the array as a flat result | ||
* @param {function} [options.onStep] - Callback to do after each step | ||
* @param {string} [options.ionizations=''] - Comma separated list of ionizations (to charge the molecule) | ||
@@ -20,7 +21,7 @@ * @param {object} [options.minSimilarity=0.5] - min similarity value | ||
* @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge | ||
* @param {object} [options.filter.unsaturation={}}] | ||
* @param {object} [options.filter.unsaturation={}] | ||
* @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation | ||
* @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {number} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {boolean} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation | ||
* @param {boolean} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation | ||
* @param {object} [options.filter.atoms] - object of atom:{min, max} | ||
@@ -36,6 +37,7 @@ * @param {object} [options.filter.callback] - a function to filter the MF | ||
* @param {object} [options.similarity.common] | ||
* @returns {Promise} | ||
*/ | ||
module.exports = function searchSimilarity(options = {}) { | ||
const { similarity = {}, minSimilarity = 0.5, filter = {} } = options; | ||
module.exports = async function searchSimilarity(options = {}) { | ||
const { similarity = {}, minSimilarity = 0.5, filter = {}, onStep } = options; | ||
@@ -91,3 +93,5 @@ let width = { | ||
for (let entry of flatEntries) { | ||
for (let i = 0; i < flatEntries.length; i++) { | ||
const entry = flatEntries[i]; | ||
if (onStep) await onStep(i); | ||
let isotopicDistribution = new IsotopicDistribution(entry.mf, { | ||
@@ -94,0 +98,0 @@ allowNeutral: false, |
1252071
48
2157
3
Updatedmf-finder@^1.2.1
Updatedmf-from-google-sheet@^1.1.25
Updatedmf-generator@^1.3.13
Updatedms-spectrum@^1.4.7