ms-spectrum
Advanced tools
Comparing version 1.6.15 to 1.6.16
{ | ||
"name": "ms-spectrum", | ||
"version": "1.6.15", | ||
"version": "1.6.16", | ||
"description": "A mass spectrum", | ||
"main": "src/index.js", | ||
"main": "lib/index.js", | ||
"module": "src/index.js", | ||
"files": [ | ||
"src" | ||
"src", | ||
"lib" | ||
], | ||
@@ -19,21 +21,18 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/cheminfo/mass-tools/tree/master/packages/emdb#readme", | ||
"homepage": "https://github.com/cheminfo/mass-tools/tree/main/packages/emdb#readme", | ||
"dependencies": { | ||
"emdb": "^1.13.2", | ||
"emdb": "^1.13.3", | ||
"is-any-array": "^2.0.0", | ||
"mf-parser": "^1.4.7", | ||
"ml-array-max": "^1.2.4", | ||
"ml-array-min": "^1.2.3", | ||
"ml-array-normed": "^1.3.7", | ||
"ml-gsd": "^10.2.0", | ||
"mf-parser": "^1.4.8", | ||
"ml-gsd": "^12.1.2", | ||
"ml-regression-power": "^2.0.0", | ||
"ml-spectra-processing": "^11.1.0", | ||
"peaks-similarity": "^2.3.1", | ||
"xy-parser": "^5.0.2" | ||
"ml-spectra-processing": "^11.14.0", | ||
"peaks-similarity": "^3.1.1", | ||
"xy-parser": "^5.0.3" | ||
}, | ||
"devDependencies": { | ||
"jest-matcher-deep-close-to": "^3.0.2", | ||
"spectrum-generator": "^8.0.1" | ||
"spectrum-generator": "^8.0.6" | ||
}, | ||
"gitHead": "09dc5f380182d586410e390df190c8d27101fc3e" | ||
"gitHead": "bd2c06e05f2196c5f9c6ff011cf3ef41e1b6a0f9" | ||
} |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { appendPeaksCharge } from '../appendPeaksCharge'; | ||
const appendPeaksCharge = require('../appendPeaksCharge'); | ||
describe('test appendPeaksCharge', () => { | ||
@@ -6,0 +4,0 @@ it('custom options', () => { |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { getBestPeaks } from '../getBestPeaks'; | ||
const getBestPeaks = require('../getBestPeaks'); | ||
describe('test getBestPeaks', () => { | ||
@@ -6,0 +4,0 @@ let peaks = [ |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { getFragmentPeaks } from '../getFragmentPeaks'; | ||
const getFragmentPeaks = require('../getFragmentPeaks'); | ||
describe('test getFragmentPeaks', () => { | ||
@@ -6,0 +4,0 @@ let peaks = [ |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { getMassRemainder } from '../getMassRemainder'; | ||
const getMassRemainder = require('../getMassRemainder'); | ||
describe('test getMassRemainder', () => { | ||
@@ -6,0 +4,0 @@ let spectrum = { |
@@ -1,6 +0,4 @@ | ||
'use strict'; | ||
import { Spectrum } from '../Spectrum'; | ||
import { getPeakChargeBySimilarity } from '../getPeakChargeBySimilarity'; | ||
const Spectrum = require('../Spectrum'); | ||
const getPeakChargeBySimilarity = require('../getPeakChargeBySimilarity'); | ||
describe('test getPeakChargeBySimilarity', () => { | ||
@@ -7,0 +5,0 @@ let data = { |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { getPeaks } from '../getPeaks'; | ||
const getPeaks = require('../getPeaks'); | ||
describe('test getPeaks', () => { | ||
@@ -6,0 +4,0 @@ let peaks = [ |
@@ -1,10 +0,8 @@ | ||
'use strict'; | ||
import { readFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
const { readFileSync } = require('fs'); | ||
const { join } = require('path'); | ||
import { parseXY } from 'xy-parser'; | ||
const { parseXY } = require('xy-parser'); | ||
import { isContinuous } from '../isContinuous'; | ||
const isContinuous = require('../isContinuous'); | ||
describe('test isContinuous', () => { | ||
@@ -11,0 +9,0 @@ it('to small', () => { |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { peaksWidth } from '../peaksWidth'; | ||
const peaksWidth = require('../peaksWidth'); | ||
describe('test test peakWidth', () => { | ||
@@ -6,0 +4,0 @@ it('five peaks', () => { |
@@ -1,8 +0,6 @@ | ||
'use strict'; | ||
import { readFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
const { readFileSync } = require('fs'); | ||
const { join } = require('path'); | ||
import { fromText } from '../Spectrum'; | ||
const Spectrum = require('../Spectrum'); | ||
describe('test appendPeakCharge on Spectrum', () => { | ||
@@ -14,3 +12,3 @@ let chargedText = readFileSync( | ||
it('multicharged', () => { | ||
let spectrum = Spectrum.fromText(chargedText); | ||
let spectrum = fromText(chargedText); | ||
let peaks = spectrum.peakPicking(); | ||
@@ -17,0 +15,0 @@ peaks = peaks.filter((peak) => peak.y > 1000); |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { fromPeaks } from '../Spectrum'; | ||
const Spectrum = require('../Spectrum'); | ||
test('Spectrum fromPeaks', () => { | ||
@@ -39,5 +37,5 @@ const peaks = [ | ||
const spectrum = Spectrum.fromPeaks(peaks); | ||
const spectrum = fromPeaks(peaks); | ||
expect(Object.keys(spectrum.data)).toStrictEqual(['x', 'y', 'composition']); | ||
}); |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { JsGraph } from '..'; | ||
const Spectrum = require('../Spectrum'); | ||
describe('test Spectrum JSGraph', () => { | ||
@@ -15,3 +13,3 @@ it('getAnnotation', async () => { | ||
]; | ||
let annotations = await Spectrum.JsGraph.getPeaksAnnotation(peaks); | ||
let annotations = await JsGraph.getPeaksAnnotation(peaks); | ||
@@ -18,0 +16,0 @@ expect(annotations).toHaveLength(3); |
@@ -1,12 +0,10 @@ | ||
'use strict'; | ||
import { readFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
const { readFileSync } = require('fs'); | ||
const { join } = require('path'); | ||
import { fromText } from '../Spectrum'; | ||
const Spectrum = require('../Spectrum'); | ||
describe('peakPicking on Spectrum', () => { | ||
let chargedText = readFileSync(join(__dirname, 'data/lowres2.txt'), 'utf8'); | ||
it('lowres2', () => { | ||
let spectrum = Spectrum.fromText(chargedText); | ||
let spectrum = fromText(chargedText); | ||
let peaks = spectrum.peakPicking(); | ||
@@ -13,0 +11,0 @@ |
@@ -1,9 +0,6 @@ | ||
/* eslint-disable jest/no-if */ | ||
'use strict'; | ||
import { toBeDeepCloseTo } from 'jest-matcher-deep-close-to'; | ||
import { generateSpectrum } from 'spectrum-generator'; | ||
const { toBeDeepCloseTo } = require('jest-matcher-deep-close-to'); | ||
const generateSpectrum = require('spectrum-generator').generateSpectrum; | ||
import { Spectrum, fromText } from '../Spectrum'; | ||
const Spectrum = require('../Spectrum'); | ||
expect.extend({ toBeDeepCloseTo }); | ||
@@ -14,3 +11,3 @@ | ||
expect(() => { | ||
Spectrum(1); | ||
new Spectrum(1); | ||
}).toThrow('Spectrum data must be an object'); | ||
@@ -26,3 +23,6 @@ }); | ||
new Spectrum({ x: [1, 2, 3, 4], y: [1, 1, 1, 1] }).normedY().data, | ||
).toStrictEqual({ x: [1, 2, 3, 4], y: [0.25, 0.25, 0.25, 0.25] }); | ||
).toStrictEqual({ | ||
x: [1, 2, 3, 4], | ||
y: Float64Array.from([0.25, 0.25, 0.25, 0.25]), | ||
}); | ||
}); | ||
@@ -89,3 +89,3 @@ | ||
it('gsd realtop', () => { | ||
it('peak picking and same y value', () => { | ||
const peaks = [{ x: 5, y: 10000, width: 0.2 }]; | ||
@@ -107,10 +107,10 @@ | ||
}); | ||
}); | ||
it('fromText', () => { | ||
let spectrum = Spectrum.fromText(`Title of spectrum | ||
test('fromText', () => { | ||
let spectrum = fromText(`Title of spectrum | ||
1 2 | ||
2 3 | ||
3 4`); | ||
expect(spectrum.data).toStrictEqual({ x: [1, 2, 3], y: [2, 3, 4] }); | ||
}); | ||
expect(spectrum.data).toStrictEqual({ x: [1, 2, 3], y: [2, 3, 4] }); | ||
}); |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
/** | ||
@@ -14,3 +12,3 @@ * @param {object} [options={}] | ||
function appendPeaksCharge(peaks, options = {}) { | ||
export function appendPeaksCharge(peaks, options = {}) { | ||
let { | ||
@@ -140,3 +138,1 @@ precision = 100, | ||
} | ||
module.exports = appendPeaksCharge; |
@@ -1,8 +0,3 @@ | ||
'use strict'; | ||
import { xyObjectMaxXPoint, xyObjectMinXPoint } from 'ml-spectra-processing'; | ||
const { | ||
xyObjectMaxXPoint, | ||
xyObjectMinXPoint, | ||
} = require('ml-spectra-processing'); | ||
/** | ||
@@ -25,3 +20,3 @@ * Filter the array by taking the higher peaks and only | ||
function getBestPeaks(peaks, options = {}) { | ||
export function getBestPeaks(peaks, options = {}) { | ||
const { | ||
@@ -98,3 +93,1 @@ searchMonoisotopicRatio = 0, | ||
} | ||
module.exports = getBestPeaks; |
@@ -1,7 +0,6 @@ | ||
'use strict'; | ||
import { EMDB } from 'emdb'; | ||
import { MF } from 'mf-parser'; | ||
const { MF } = require('mf-parser'); | ||
import { getPeaks } from './getPeaks.js'; | ||
const getPeaks = require('./getPeaks.js'); | ||
/** | ||
@@ -21,4 +20,4 @@ * Filter the array of peaks | ||
async function getFragmentPeaks(peaks, mf, options = {}) { | ||
const emdb = new (require('emdb'))(); | ||
export async function getFragmentPeaks(peaks, mf, options = {}) { | ||
const emdb = new EMDB(); | ||
@@ -44,3 +43,1 @@ const { ionizations = '', precision } = options; | ||
} | ||
module.exports = getFragmentPeaks; |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { xySortX, xyJoinX } from 'ml-spectra-processing'; | ||
const { xySortX, xyJoinX } = require('ml-spectra-processing'); | ||
/** | ||
@@ -13,3 +11,3 @@ * Remove an integer number of time the specifiedd monoisotopic mass | ||
*/ | ||
function getMassRemainder(spectrum, mass, options = {}) { | ||
export function getMassRemainder(spectrum, mass, options = {}) { | ||
const { delta = 0.001 } = options; | ||
@@ -25,3 +23,1 @@ const x = spectrum.x.slice(); | ||
} | ||
module.exports = getMassRemainder; |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { Comparator } from 'peaks-similarity'; | ||
const Similarity = require('peaks-similarity'); | ||
/** | ||
@@ -21,3 +19,3 @@ * @param {object} [options={}] | ||
function getPeakChargeBySimilarity(spectrum, targetMass, options = {}) { | ||
export function getPeakChargeBySimilarity(spectrum, targetMass, options = {}) { | ||
let { similarity = {}, minCharge = 1, maxCharge = 10 } = options; | ||
@@ -42,3 +40,3 @@ let { zone = {}, widthFunction } = similarity; | ||
let experimentalData = spectrum.data; | ||
let similarityProcessor = new Similarity(similarity); | ||
let similarityProcessor = new Comparator(similarity); | ||
similarityProcessor.setPeaks1([experimentalData.x, experimentalData.y]); | ||
@@ -97,3 +95,1 @@ | ||
} | ||
module.exports = getPeakChargeBySimilarity; |
@@ -1,8 +0,6 @@ | ||
'use strict'; | ||
const { | ||
import { | ||
xyObjectMaxXPoint, | ||
xyObjectMinXPoint, | ||
xyObjectSumY, | ||
} = require('ml-spectra-processing'); | ||
} from 'ml-spectra-processing'; | ||
@@ -21,3 +19,3 @@ /** | ||
function getPeaks(peaks, options = {}) { | ||
export function getPeaks(peaks, options = {}) { | ||
const { | ||
@@ -54,3 +52,1 @@ from = xyObjectMinXPoint(peaks).x, | ||
} | ||
module.exports = getPeaks; |
@@ -1,6 +0,5 @@ | ||
'use strict'; | ||
export * from './Spectrum.js'; | ||
export * from './getPeaks.js'; | ||
export * from './getBestPeaks.js'; | ||
module.exports.Spectrum = require('./Spectrum'); | ||
module.exports.getPeaks = require('./getPeaks'); | ||
module.exports.getBestPeaks = require('./getBestPeaks'); | ||
export * from './jsgraph/index.js'; |
@@ -1,4 +0,2 @@ | ||
'use strict'; | ||
const max = require('ml-array-max/lib/index'); | ||
import { xMaxValue } from 'ml-spectra-processing'; | ||
/** | ||
@@ -17,3 +15,3 @@ * When a spectrum is continous ? | ||
function isContinuous(spectrum, options = {}) { | ||
export function isContinuous(spectrum, options = {}) { | ||
const { | ||
@@ -24,3 +22,3 @@ minLength = 100, | ||
} = options; | ||
const minHeight = max(spectrum.data.y) * relativeHeightThreshold; | ||
const minHeight = xMaxValue(spectrum.data.y) * relativeHeightThreshold; | ||
const minRadio = 1 / maxDeltaRatio; | ||
@@ -66,3 +64,1 @@ const maxRatio = 1 * maxDeltaRatio; | ||
} | ||
module.exports = isContinuous; |
@@ -1,5 +0,3 @@ | ||
'use strict'; | ||
import { getPeaksAnnotation } from '../getPeaksAnnotation'; | ||
const getPeaksAnnotation = require('../getPeaksAnnotation'); | ||
describe('test getPeaksAnnotation', () => { | ||
@@ -6,0 +4,0 @@ let peaks = [ |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
import { EMDB } from 'emdb'; | ||
@@ -20,6 +20,6 @@ /** | ||
async function getPeaksAnnotation(bestPeaks, options = {}) { | ||
const emdb = new (require('emdb'))(); | ||
export async function getPeaksAnnotation(bestPeaks, options = {}) { | ||
const emdb = new EMDB(); | ||
options = Object.assign({ limit: 5, precision: 100 }, options); | ||
options = { limit: 5, precision: 100, ...options }; | ||
@@ -133,6 +133,7 @@ let { | ||
// neutral loss | ||
let currentMfPrefs = Object.assign({}, mfPrefs, { | ||
let currentMfPrefs = { | ||
...mfPrefs, | ||
allowNeutral: true, | ||
ionizations: '', | ||
}); | ||
}; | ||
// we need to deal with the precision and increase it | ||
@@ -196,3 +197,1 @@ currentMfPrefs.precision = | ||
} | ||
module.exports = getPeaksAnnotation; |
@@ -1,5 +0,5 @@ | ||
'use strict'; | ||
import { getPeaksAnnotation } from './getPeaksAnnotation.js'; | ||
module.exports = { | ||
getPeaksAnnotation: require('./getPeaksAnnotation'), | ||
export const JsGraph = { | ||
getPeaksAnnotation, | ||
}; |
@@ -1,8 +0,6 @@ | ||
'use strict'; | ||
import { gsd } from 'ml-gsd'; | ||
import { xyEnsureGrowingX } from 'ml-spectra-processing'; | ||
const gsd = require('ml-gsd').gsd; | ||
const { xyEnsureGrowingX } = require('ml-spectra-processing'); | ||
import { appendPeaksCharge } from './appendPeaksCharge'; | ||
const appendPeaksCharge = require('./appendPeaksCharge'); | ||
/** | ||
@@ -21,3 +19,3 @@ * Filter the array of peaks | ||
function peakPicking(spectrum, options = {}) { | ||
export function peakPicking(spectrum, options = {}) { | ||
const { charge: chargeOptions = {} } = options; | ||
@@ -69,3 +67,1 @@ if (!spectrum.peaks || spectrum.peaks.length === 0) { | ||
} | ||
module.exports = peakPicking; |
@@ -1,8 +0,5 @@ | ||
'use strict'; | ||
import Regression from 'ml-regression-power'; | ||
import { xMaxValue, xMinValue } from 'ml-spectra-processing'; | ||
const max = require('ml-array-max/lib/index'); | ||
const min = require('ml-array-min/lib/index'); | ||
const Regression = require('ml-regression-power/lib/index.js'); | ||
function peaksWidth(peaks) { | ||
export function peaksWidth(peaks) { | ||
let xs = peaks.map((peak) => peak.x); | ||
@@ -25,4 +22,4 @@ let widths = peaks.map((peak) => peak.width); | ||
let from = min(xs); | ||
let to = max(xs); | ||
let from = xMinValue(xs); | ||
let to = xMaxValue(xs); | ||
@@ -49,3 +46,1 @@ let regressionChart = { x: [], y: [] }; | ||
} | ||
module.exports = peaksWidth; |
@@ -1,150 +0,145 @@ | ||
'use strict'; | ||
import { isAnyArray } from 'is-any-array'; | ||
import { xMaxValue, xNormed } from 'ml-spectra-processing'; | ||
import { parseXY } from 'xy-parser'; | ||
const { isAnyArray } = require('is-any-array'); | ||
const max = require('ml-array-max/lib/index.js'); | ||
const normed = require('ml-array-normed/lib/index.js'); | ||
const { parseXY } = require('xy-parser'); | ||
import { getBestPeaks } from './getBestPeaks'; | ||
import { getFragmentPeaks } from './getFragmentPeaks'; | ||
import { getMassRemainder } from './getMassRemainder'; | ||
import { getPeakChargeBySimilarity } from './getPeakChargeBySimilarity'; | ||
import { getPeaks } from './getPeaks'; | ||
import { isContinuous } from './isContinuous'; | ||
import { peakPicking } from './peakPicking'; | ||
import { peaksWidth } from './peaksWidth'; | ||
const getBestPeaks = require('./getBestPeaks'); | ||
const getFragmentPeaks = require('./getFragmentPeaks'); | ||
const getMassRemainder = require('./getMassRemainder'); | ||
const getPeakChargeBySimilarity = require('./getPeakChargeBySimilarity'); | ||
const getPeaks = require('./getPeaks'); | ||
const isContinuous = require('./isContinuous'); | ||
const peakPicking = require('./peakPicking'); | ||
const peaksWidth = require('./peaksWidth'); | ||
/** | ||
* Class dealing with mass spectra and peak picking | ||
*/ | ||
export class Spectrum { | ||
constructor(data = { x: [], y: [] }) { | ||
if ( | ||
typeof data !== 'object' || | ||
!isAnyArray(data.x) || | ||
!isAnyArray(data.y) | ||
) { | ||
throw new TypeError('Spectrum data must be an object with x:[], y:[]'); | ||
} | ||
this.data = {}; // we make a copy so that we can add new properties | ||
for (let key in data) { | ||
this.data[key] = data[key]; | ||
} | ||
Object.defineProperty(this.data, 'xOriginal', { | ||
enumerable: false, | ||
writable: true, | ||
}); | ||
this.cache = {}; | ||
this.peaks = []; | ||
} | ||
function Spectrum(data = { x: [], y: [] }) { | ||
if (typeof data !== 'object' || !isAnyArray(data.x) || !isAnyArray(data.y)) { | ||
throw new TypeError('Spectrum data must be an object with x:[], y:[]'); | ||
maxY() { | ||
return xMaxValue(this.data.y); | ||
} | ||
this.data = {}; // we make a copy so that we can add new properties | ||
for (let key in data) { | ||
this.data[key] = data[key]; | ||
sumY() { | ||
if (!this.cache.sumY) { | ||
this.cache.sumY = this.data.y.reduce( | ||
(previous, current) => previous + current, | ||
0, | ||
); | ||
} | ||
return this.cache.sumY; | ||
} | ||
Object.defineProperty(this.data, 'xOriginal', { | ||
enumerable: false, | ||
writable: true, | ||
}); | ||
this.cache = {}; | ||
this.peaks = []; | ||
} | ||
Spectrum.fromPeaks = function fromPeaks(peaks) { | ||
if (peaks.length === 0) return new Spectrum(); | ||
const data = {}; | ||
for (let key of Object.keys(peaks[0])) { | ||
data[key] = peaks.map((peak) => peak[key]); | ||
scaleY(intensity = 1) { | ||
let basePeak = this.maxY() / intensity; | ||
this.data.y = this.data.y.map((y) => y / basePeak); | ||
return this; | ||
} | ||
return new Spectrum(data); | ||
}; | ||
Spectrum.fromText = function fromText(text) { | ||
const data = parseXY(text); | ||
return new Spectrum(data); | ||
}; | ||
rescaleX(callback) { | ||
this.ensureOriginalX(); | ||
Spectrum.prototype.maxY = function maxY() { | ||
return max(this.data.y); | ||
}; | ||
for (let i = 0; i < this.data.x.length; i++) { | ||
this.data.x[i] = callback(this.data.xOriginal[i]); | ||
} | ||
Spectrum.prototype.sumY = function sumY() { | ||
if (!this.cache.sumY) { | ||
this.cache.sumY = this.data.y.reduce( | ||
(previous, current) => previous + current, | ||
0, | ||
); | ||
return this; | ||
} | ||
return this.cache.sumY; | ||
}; | ||
Spectrum.prototype.scaleY = function scaleY(intensity = 1) { | ||
let basePeak = this.maxY() / intensity; | ||
this.data.y = this.data.y.map((y) => y / basePeak); | ||
return this; | ||
}; | ||
ensureOriginalX() { | ||
if (!this.data.xOriginal) { | ||
this.data.xOriginal = this.data.x.slice(0); | ||
} | ||
} | ||
Spectrum.prototype.rescaleX = function rescaleX(callback) { | ||
this.ensureOriginalX(); | ||
normedY(total = 1) { | ||
this.data.y = xNormed(this.data.y); | ||
if (total !== 1) { | ||
this.data.y = this.data.y.map((y) => y * total); | ||
} | ||
return this; | ||
} | ||
for (let i = 0; i < this.data.x.length; i++) { | ||
this.data.x[i] = callback(this.data.xOriginal[i]); | ||
peakPicking() { | ||
peakPicking(this); | ||
return this.peaks; | ||
} | ||
return this; | ||
}; | ||
Spectrum.prototype.ensureOriginalX = function ensureOriginalX() { | ||
if (!this.data.xOriginal) { | ||
this.data.xOriginal = this.data.x.slice(0); | ||
peaksWidth() { | ||
peakPicking(this); | ||
return peaksWidth(this.peaks); | ||
} | ||
}; | ||
Spectrum.prototype.normedY = function normedY(total = 1) { | ||
this.data.y = normed(this.data.y); | ||
if (total !== 1) { | ||
this.data.y = this.data.y.map((y) => y * total); | ||
getBestPeaks(options) { | ||
peakPicking(this); | ||
return getBestPeaks(this.peaks, options); | ||
} | ||
return this; | ||
}; | ||
Spectrum.prototype.peakPicking = function peakPickingFct() { | ||
peakPicking(this); | ||
return this.peaks; | ||
}; | ||
Spectrum.prototype.peaksWidth = function peaksWidthFct() { | ||
peakPicking(this); | ||
return peaksWidth(this.peaks); | ||
}; | ||
Spectrum.prototype.getBestPeaks = function getBestPeaksFct(options) { | ||
peakPicking(this); | ||
return getBestPeaks(this.peaks, options); | ||
}; | ||
Spectrum.prototype.getPeakChargeBySimilarity = | ||
function getPeakChargeBySimilarityFct(targetMass, options) { | ||
getPeakChargeBySimilarity(targetMass, options) { | ||
return getPeakChargeBySimilarity(this, targetMass, options); | ||
}; | ||
} | ||
Spectrum.prototype.getPeaks = function getPeaksFct(options) { | ||
peakPicking(this); | ||
return getPeaks(this.peaks, options); | ||
}; | ||
getPeaks(options) { | ||
peakPicking(this); | ||
return getPeaks(this.peaks, options); | ||
} | ||
/** | ||
* Returns also peaks possible for a specific molecular formula | ||
* @example | ||
* const spectrum = new Spectrum({x:[], y:[]}) | ||
* await spectrum.getFragmentPeaks(); | ||
* @param {string} mf | ||
* @param {object} options | ||
* @returns | ||
*/ | ||
Spectrum.prototype.getFragmentPeaks = function getFragmentPeaksFct( | ||
mf, | ||
options, | ||
) { | ||
peakPicking(this); | ||
return getFragmentPeaks(this.peaks, mf, options); | ||
}; | ||
/** | ||
* Returns also peaks possible for a specific molecular formula | ||
* @example | ||
* const spectrum = new Spectrum({x:[], y:[]}) | ||
* await spectrum.getFragmentPeaks(); | ||
* @param {string} mf | ||
* @param {object} options | ||
* @returns | ||
*/ | ||
getFragmentPeaksFct(mf, options) { | ||
peakPicking(this); | ||
return getFragmentPeaks(this.peaks, mf, options); | ||
} | ||
Spectrum.prototype.isContinuous = function isContinuousFct() { | ||
return isContinuous(this); | ||
}; | ||
isContinuous() { | ||
return isContinuous(this); | ||
} | ||
/** | ||
* Remove an integer number of time the specifiedd monoisotopic mass | ||
* Mass remainder analysis (MARA): https://doi.org/10.1021/acs.analchem.7b04730 | ||
*/ | ||
Spectrum.prototype.getMassRemainder = function getMassRemainderFct( | ||
mass, | ||
options = {}, | ||
) { | ||
return getMassRemainder(this.data, mass, options); | ||
}; | ||
/** | ||
* Remove an integer number of time the specifiedd monoisotopic mass | ||
* Mass remainder analysis (MARA): https://doi.org/10.1021/acs.analchem.7b04730 | ||
*/ | ||
getMassRemainderFct(mass, options = {}) { | ||
return getMassRemainder(this.data, mass, options); | ||
} | ||
} | ||
Spectrum.JsGraph = Spectrum.prototype.JsGraph = require('./jsgraph/index'); | ||
export function fromPeaks(peaks) { | ||
if (peaks.length === 0) return new Spectrum(); | ||
const data = {}; | ||
for (let key of Object.keys(peaks[0])) { | ||
data[key] = peaks.map((peak) => peak[key]); | ||
} | ||
return new Spectrum(data); | ||
} | ||
module.exports = Spectrum; | ||
export function fromText(text) { | ||
const data = parseXY(text); | ||
return new Spectrum(data); | ||
} |
5360156
8
38
2253
2
+ Added@lukeed/csprng@1.1.0(transitive)
+ Added@lukeed/uuid@2.0.1(transitive)
+ Addedml-direct@1.0.0(transitive)
+ Addedml-gsd@12.1.8(transitive)
+ Addedml-savitzky-golay-generalized@4.2.0(transitive)
+ Addedml-spectra-fitting@4.2.4(transitive)
+ Addedpeaks-similarity@3.1.1(transitive)
- Removedml-array-max@^1.2.4
- Removedml-array-min@^1.2.3
- Removedml-array-normed@^1.3.7
Updatedemdb@^1.13.3
Updatedmf-parser@^1.4.8
Updatedml-gsd@^12.1.2
Updatedpeaks-similarity@^3.1.1
Updatedxy-parser@^5.0.3