Comparing version 0.6.3 to 0.6.4
{ | ||
"name": "emdb", | ||
"version": "0.6.3", | ||
"description": "Database manager for exact mass query", | ||
"browser": { | ||
"./src/util/fetchArrayBuffer.js": "./src/util/fetchArrayBufferBrowser.js" | ||
}, | ||
"main": "src/index.js", | ||
"files": [ | ||
"src" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/cheminfo-js/molecular-formula.git" | ||
}, | ||
"keywords": [], | ||
"author": "Luc Patiny", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/cheminfo-js/molecular-formula/issues" | ||
}, | ||
"homepage": "https://github.com/cheminfo-js/molecular-formula/tree/master/packages/emdb#readme", | ||
"dependencies": { | ||
"isotopic-distribution": "^0.6.3", | ||
"jszip": "^3.1.5", | ||
"mf-finder": "^0.6.3", | ||
"mf-from-google-sheet": "^0.6.3", | ||
"mf-generator": "^0.6.3", | ||
"mf-matcher": "^0.6.3", | ||
"mf-parser": "^0.6.3", | ||
"mf-utilities": "^0.6.3", | ||
"nucleotide": "^0.6.2", | ||
"peaks-similarity": "^2.3.0", | ||
"peptide": "^1.6.1", | ||
"request-promise-native": "^1.0.5" | ||
} | ||
"name": "emdb", | ||
"version": "0.6.4", | ||
"description": "Database manager for exact mass query", | ||
"browser": { | ||
"./src/util/fetchArrayBuffer.js": "./src/util/fetchArrayBufferBrowser.js", | ||
"./src/util/fetchJSON.js": "./src/util/fetchJSONBrowser.js" | ||
}, | ||
"main": "src/index.js", | ||
"files": [ | ||
"src" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/cheminfo-js/molecular-formula.git" | ||
}, | ||
"keywords": [], | ||
"author": "Luc Patiny", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/cheminfo-js/molecular-formula/issues" | ||
}, | ||
"homepage": "https://github.com/cheminfo-js/molecular-formula/tree/master/packages/emdb#readme", | ||
"dependencies": { | ||
"isotopic-distribution": "^0.6.4", | ||
"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", | ||
"peaks-similarity": "^2.3.0", | ||
"peptide": "^1.6.1", | ||
"request-promise-native": "^1.0.5" | ||
} | ||
} |
@@ -5,24 +5,23 @@ 'use strict'; | ||
jest.setTimeout(30000); | ||
test('test DBManager contaminants and knapSack', async () => { | ||
let dbManager = new DBManager(); | ||
let dbManager = new DBManager(); | ||
await dbManager.loadContaminants(); | ||
await dbManager.loadKnapSack(); | ||
await dbManager.loadContaminants(); | ||
await dbManager.loadKnapSack(); | ||
expect(dbManager.listDatabases()).toEqual(['contaminants', 'knapSack']); | ||
expect(dbManager.get('contaminants').length).toBeGreaterThan(1000); | ||
expect(dbManager.listDatabases()).toEqual(['contaminants', 'knapSack']); | ||
expect(dbManager.get('contaminants').length).toBeGreaterThan(1000); | ||
}); | ||
test('test DBManager fromMonoisotopicMass', () => { | ||
let dbManager = new DBManager(); | ||
let dbManager = new DBManager(); | ||
dbManager.fromMonoisotopicMass(300, { | ||
ionizations: 'H+,Na+' | ||
}); | ||
dbManager.fromMonoisotopicMass(300, { | ||
ionizations: 'H+,Na+' | ||
}); | ||
expect(dbManager.listDatabases()).toEqual(['monoisotopic']); | ||
expect(dbManager.get('monoisotopic').length).toBeGreaterThan(100); | ||
expect(dbManager.listDatabases()).toEqual(['monoisotopic']); | ||
expect(dbManager.get('monoisotopic').length).toBeGreaterThan(100); | ||
}); |
@@ -5,22 +5,22 @@ 'use strict'; | ||
test('test fromArray', () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromPeptidicSequence('AAKK', { | ||
allowNeutralLoss: false, | ||
protonation: false, | ||
protonationPH: 7, | ||
ionizations: 'H+,Na+', | ||
fragmentation: { | ||
a: true | ||
}, | ||
filter: { | ||
minMSEM: 100, | ||
maxMSEM: 300, | ||
targetMass: 150, // just to test, this is useless with precision 1e6 | ||
precision: 1e6 | ||
}, | ||
}); | ||
test('test fromPeptidicSequence', () => { | ||
let dbManager = new DBManager(); | ||
dbManager.fromPeptidicSequence('AAKK', { | ||
allowNeutralLoss: false, | ||
protonation: false, | ||
protonationPH: 7, | ||
ionizations: 'H+,Na+', | ||
fragmentation: { | ||
a: true | ||
}, | ||
filter: { | ||
minMSEM: 100, | ||
maxMSEM: 300, | ||
targetMass: 150, // just to test, this is useless with precision 1e6 | ||
precision: 1e6 | ||
} | ||
}); | ||
expect(dbManager.databases.peptidic).toHaveLength(2); | ||
expect(dbManager.databases.peptidic).toMatchSnapshot(); | ||
expect(dbManager.databases.peptidic).toHaveLength(2); | ||
expect(dbManager.databases.peptidic).toMatchSnapshot(); | ||
}); |
@@ -5,13 +5,13 @@ 'use strict'; | ||
jest.setTimeout(30000); | ||
test('test loadKnapSack', async () => { | ||
let data = await loadKnapSack(); | ||
let data = await loadKnapSack(); | ||
expect(data.length).toBeGreaterThan(40000); | ||
expect(data.length).toBeGreaterThan(40000); | ||
let first = data[0]; | ||
expect(first.mf).toBe('H3N'); | ||
expect(first.em).toBeGreaterThan(0); | ||
expect(first.charge).toBe(0); | ||
expect(first.msem).toBeUndefined(); | ||
let first = data[0]; | ||
expect(first.mf).toBe('H3N'); | ||
expect(first.em).toBeGreaterThan(0); | ||
expect(first.charge).toBe(0); | ||
expect(first.msem).toBeUndefined(); | ||
}); |
@@ -9,4 +9,10 @@ '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 {object} [options={}] | ||
* @param {string} [options.ionizations=''] | ||
* @param {array} [options.mfsArray=[]] | ||
* * @param {boolean} [options.protonation=false] | ||
* @param {number} [options.protonationPH=7] | ||
* @param {boolean} [options.allowNeutralLoss=false] | ||
* @param {object} [options.digestion={}] Object defining options for digestion | ||
* @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 {number} [options.digestion.minMissed=0] Minimal number of allowed missed cleavage | ||
@@ -49,49 +55,49 @@ * @param {number} [options.digestion.maxMissed=0] Maximal number of allowed missed cleavage | ||
module.exports = function fromPeptidicSequence(sequence, options = {}) { | ||
const { | ||
digestion = {}, | ||
mfsArray = [], | ||
allowNeutralLoss = false, | ||
protonation = false, | ||
protonationPH = 7, | ||
fragmentation = {}, | ||
filter = {}, | ||
ionizations = '' | ||
} = options; | ||
const { | ||
digestion = {}, | ||
mfsArray = [], | ||
allowNeutralLoss = false, | ||
protonation = false, | ||
protonationPH = 7, | ||
fragmentation = {}, | ||
filter = {}, | ||
ionizations = '' | ||
} = options; | ||
sequence = peptide.convertAASequence(sequence); | ||
sequence = peptide.convertAASequence(sequence); | ||
let fragmentsArray = [sequence]; | ||
// do we also have some digest fragments ? | ||
if (digestion.enzyme) { | ||
var digests = peptide.digestPeptide(sequence, digestion); | ||
if (options.protonation) { | ||
digests = peptide.chargePeptide(digests, { | ||
pH: options.protonationPH | ||
}); | ||
} | ||
fragmentsArray = fragmentsArray.concat(digests); | ||
let fragmentsArray = [sequence]; | ||
// do we also have some digest fragments ? | ||
if (digestion.enzyme) { | ||
var digests = peptide.digestPeptide(sequence, digestion); | ||
if (options.protonation) { | ||
digests = peptide.chargePeptide(digests, { | ||
pH: options.protonationPH | ||
}); | ||
} | ||
fragmentsArray = fragmentsArray.concat(digests); | ||
} | ||
// allow neutral loss | ||
if (allowNeutralLoss) { | ||
sequence = peptide.allowNeutralLoss(sequence); | ||
} | ||
// allow neutral loss | ||
if (allowNeutralLoss) { | ||
sequence = peptide.allowNeutralLoss(sequence); | ||
} | ||
// apply protonation | ||
if (protonation) { | ||
sequence = peptide.chargePeptide(sequence, { pH: protonationPH }); | ||
} | ||
// apply protonation | ||
if (protonation) { | ||
sequence = peptide.chargePeptide(sequence, { pH: protonationPH }); | ||
} | ||
// calculate fragmentation | ||
var fragments = peptide.generatePeptideFragments(sequence, fragmentation); | ||
fragmentsArray = fragmentsArray.concat(fragments); | ||
// calculate fragmentation | ||
var fragments = peptide.generatePeptideFragments(sequence, fragmentation); | ||
fragmentsArray = fragmentsArray.concat(fragments); | ||
mfsArray.push(fragmentsArray); | ||
mfsArray.push(fragmentsArray); | ||
let combined = combineMFs(mfsArray, { | ||
ionizations, | ||
filter: filter | ||
}); | ||
let combined = combineMFs(mfsArray, { | ||
ionizations, | ||
filter: filter | ||
}); | ||
return combined; | ||
return combined; | ||
}; |
@@ -8,10 +8,10 @@ 'use strict'; | ||
function DBManager() { | ||
this.databases = {}; | ||
this.experimentalSpectrum = undefined; | ||
this.databases = {}; | ||
this.experimentalSpectrum = undefined; | ||
} | ||
DBManager.prototype.setExperimentalSpectrum = function setExperimentalSpectrum( | ||
experimentalSpectrum | ||
experimentalSpectrum | ||
) { | ||
this.experimentalSpectrum = experimentalSpectrum; | ||
this.experimentalSpectrum = experimentalSpectrum; | ||
}; | ||
@@ -24,5 +24,5 @@ | ||
DBManager.prototype.loadKnapSack = async function loadKnapSack(options = {}) { | ||
const { databaseName = 'knapSack', forceReload = false } = options; | ||
if (this.databases[databaseName] && !forceReload) return; | ||
this.databases[databaseName] = await loadKnapSackPromise(); | ||
const { databaseName = 'knapSack', forceReload = false } = options; | ||
if (this.databases[databaseName] && !forceReload) return; | ||
this.databases[databaseName] = await loadKnapSackPromise(); | ||
}; | ||
@@ -35,11 +35,11 @@ | ||
DBManager.prototype.loadCommercials = async function loadCommercials( | ||
options = {} | ||
options = {} | ||
) { | ||
const { databaseName = 'commercials', forceReload = false } = options; | ||
if (this.databases[databaseName] && !forceReload) return; | ||
this.databases[databaseName] = await loadCommercialsPromise(); | ||
const { databaseName = 'commercials', forceReload = false } = options; | ||
if (this.databases[databaseName] && !forceReload) return; | ||
this.databases[databaseName] = await loadCommercialsPromise(); | ||
}; | ||
DBManager.prototype.get = function get(databaseName) { | ||
return this.databases[databaseName]; | ||
return this.databases[databaseName]; | ||
}; | ||
@@ -53,7 +53,7 @@ | ||
DBManager.prototype.loadContaminants = async function loadContaminants( | ||
options = {} | ||
options = {} | ||
) { | ||
const { databaseName = 'contaminants', forceReload = false } = options; | ||
if (this.databases[databaseName] && !forceReload) return; | ||
this.databases[databaseName] = await loadGoogleSheetPromise(); | ||
const { databaseName = 'contaminants', forceReload = false } = options; | ||
if (this.databases[databaseName] && !forceReload) return; | ||
this.databases[databaseName] = await loadGoogleSheetPromise(); | ||
}; | ||
@@ -68,41 +68,52 @@ | ||
DBManager.prototype.loadGoogleSheet = async function loadGoogleSheet( | ||
options = {} | ||
options = {} | ||
) { | ||
const { databaseName = 'sheet', forceReload = false } = options; | ||
if (this.databases[databaseName] && !forceReload) return; | ||
this.databases[databaseName] = await loadGoogleSheetPromise(); | ||
const { databaseName = 'sheet', forceReload = false } = options; | ||
if (this.databases[databaseName] && !forceReload) return; | ||
this.databases[databaseName] = await loadGoogleSheetPromise(); | ||
}; | ||
DBManager.prototype.loadTest = function loadTest() { | ||
this.fromArray(['C1-100'], { databaseName: 'test', ionizations: '+' }); | ||
this.fromArray(['C1-100'], { databaseName: 'test', ionizations: '+' }); | ||
}; | ||
DBManager.prototype.fromMonoisotopicMass = function fromMonoisotopicMass( | ||
mass, | ||
options = {} | ||
mass, | ||
options = {} | ||
) { | ||
const { databaseName = 'monoisotopic' } = options; | ||
let result = require('./fromMonoisotopicMass')(mass, options); | ||
this.databases[databaseName] = result.mfs; | ||
return result; | ||
const { databaseName = 'monoisotopic' } = options; | ||
let result = require('./fromMonoisotopicMass')(mass, options); | ||
this.databases[databaseName] = result.mfs; | ||
return result; | ||
}; | ||
DBManager.prototype.fromArray = function fromArray(sequence, options = {}) { | ||
const { databaseName = 'generated' } = options; | ||
this.databases[databaseName] = require('./fromArray')(sequence, options); | ||
const { databaseName = 'generated' } = options; | ||
this.databases[databaseName] = require('./fromArray')(sequence, options); | ||
}; | ||
DBManager.prototype.fromPeptidicSequence = function fromPeptidicSequence( | ||
sequence, | ||
options = {} | ||
) { | ||
const { databaseName = 'peptidic' } = options; | ||
this.databases[databaseName] = require('./fromPeptidicSequence')( | ||
sequence, | ||
options = {} | ||
options | ||
); | ||
}; | ||
DBManager.prototype.fromNucleicSequence = function fromNucleicSequence( | ||
sequence, | ||
options = {} | ||
) { | ||
const { databaseName = 'peptidic' } = options; | ||
this.databases[databaseName] = require('./fromPeptidicSequence')( | ||
sequence, | ||
options | ||
); | ||
const { databaseName = 'nucleic' } = options; | ||
this.databases[databaseName] = require('./fromNucleicSequence')( | ||
sequence, | ||
options | ||
); | ||
}; | ||
DBManager.prototype.listDatabases = function listDatabases() { | ||
return Object.keys(this.databases).sort(); | ||
return Object.keys(this.databases).sort(); | ||
}; | ||
@@ -115,9 +126,2 @@ | ||
DBManager.Util = { | ||
IsotopicDistribution: require('isotopic-distribution'), | ||
MF: require('mf-parser').MF, | ||
Peptide: require('peptide'), | ||
Nucleotide: require('nucleotide') | ||
}; | ||
module.exports = DBManager; |
@@ -52,8 +52,9 @@ 'use strict'; | ||
} catch (e) { | ||
console.warn(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; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
100702
1017
Updatedisotopic-distribution@^0.6.4
Updatedmf-finder@^0.6.4
Updatedmf-from-google-sheet@^0.6.4
Updatedmf-generator@^0.6.4
Updatedmf-matcher@^0.6.4
Updatedmf-parser@^0.6.4
Updatedmf-utilities@^0.6.4
Updatednucleotide@^0.6.4