isotopic-distribution
Advanced tools
Comparing version 1.1.5 to 1.1.6
{ | ||
"name": "isotopic-distribution", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Calculate the isotopic distribution of a molecular formula", | ||
@@ -26,3 +26,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "3d54e43ef65fd47d783aa3e2700ff53a9da46bc0" | ||
"gitHead": "a050244fb520455170803831c05926df4925113c" | ||
} |
@@ -44,2 +44,24 @@ 'use strict'; | ||
}); | ||
it('create distribution of C10000 and getGaussian with maxValue', () => { | ||
let isotopicDistribution = new IsotopicDistribution('C10000', { | ||
fwhm: 0.001, | ||
}); | ||
let gaussian = isotopicDistribution.getGaussian({ | ||
maxValue: 100, | ||
maxLength: 1e7, | ||
}); | ||
expect(Math.max(...gaussian.x)).toBeCloseTo(120159.5334, 1); | ||
expect(Math.max(...gaussian.y)).toBeCloseTo(100, 0); | ||
}); | ||
it('create distribution of C10000 and getGaussian too big', () => { | ||
let isotopicDistribution = new IsotopicDistribution('C10000', { | ||
fwhm: 0.001, | ||
}); | ||
expect(() => { | ||
isotopicDistribution.getGaussian({}); | ||
}).toThrow('Number of points is over the maxLength'); | ||
}); | ||
}); |
@@ -28,3 +28,2 @@ 'use strict'; | ||
* @param {number} [options.ensureCase=false] - Ensure uppercase / lowercase | ||
* | ||
* @param {number} [options.allowNeutral=true] - Should we keep the distribution if the molecule has no charge | ||
@@ -235,6 +234,7 @@ */ | ||
* @param {object} [options={}] | ||
* @param {number} [guassianWidth=10] | ||
* @param {number} [threshold=0.00001] // minimal height to return point | ||
* @param {number} [maxValue] // rescale Y to reach maxValue | ||
* @param {function} [peakWidthFct=(mz)=>(this.fwhm)] | ||
* @param {number} [options.gaussianWidth=10] | ||
* @param {number} [options.threshold=0.00001] // minimal height to return point | ||
* @param {number} [options.maxLength=1e6] // minimal height to return point | ||
* @param {number} [options.maxValue] // rescale Y to reach maxValue | ||
* @param {function} [options.peakWidthFct=(mz)=>(this.fwhm)] | ||
* @return {XY} isotopic distribution as an object containing 2 properties: x:[] and y:[] | ||
@@ -247,10 +247,17 @@ */ | ||
threshold = 0.00001, | ||
gaussianWidth = 10, | ||
maxValue, | ||
maxLength = 1e6, | ||
} = options; | ||
let points = this.getTable({ maxValue }); | ||
if (points.length === 0) return []; | ||
if (points.length === 0) return { x: [], y: [] }; | ||
const from = Math.floor(options.from || points[0].x - 2); | ||
const to = Math.ceil(options.to || points[points.length - 1].x + 2); | ||
const nbPoints = Math.round(((to - from) * 10) / this.fwhm + 1); | ||
const nbPoints = Math.round(((to - from) * gaussianWidth) / this.fwhm + 1); | ||
if (nbPoints > maxLength) { | ||
throw Error( | ||
`Number of points is over the maxLength: ${nbPoints}>${maxLength}`, | ||
); | ||
} | ||
let gaussianOptions = { | ||
@@ -257,0 +264,0 @@ from, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37891
997