isotopic-distribution
Advanced tools
Comparing version 0.5.2 to 0.5.6
{ | ||
"name": "isotopic-distribution", | ||
"version": "0.5.2", | ||
"version": "0.5.6", | ||
"description": "Calculate the isotopic distribution of a molecular formula", | ||
@@ -23,4 +23,5 @@ "main": "src/index.js", | ||
"mf-parser": "^0.5.2", | ||
"mf-utilities": "^0.5.2" | ||
"mf-utilities": "^0.5.2", | ||
"spectrum-generator": "^1.0.1" | ||
} | ||
} |
@@ -27,2 +27,23 @@ 'use strict'; | ||
} | ||
get minX() { | ||
if (!this.xSorted) this.sortX(); | ||
return this.array[0].x; | ||
} | ||
get maxX() { | ||
if (!this.xSorted) this.sortX(); | ||
return this.array[this.array.length - 1].x; | ||
} | ||
get minY() { | ||
if (!this.ySorted) this.sortY(); | ||
return this.array[0].y; | ||
} | ||
get maxY() { | ||
if (!this.ySorted) this.sortY(); | ||
return this.array[this.array.length - 1]; | ||
} | ||
} | ||
@@ -29,0 +50,0 @@ |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const ELECTRON_MASS = require('chemical-elements').ELECTRON_MASS; | ||
const SpectrumGenerator = require('spectrum-generator').SpectrumGenerator; | ||
@@ -11,3 +12,10 @@ // for each element we need to find the isotopes | ||
class IsotopicDistribution { | ||
/** | ||
* Class that manage isotopic distribution | ||
* @param {string} mf - Molecular formula | ||
* @param {object} [options={}] | ||
* @param {number} [fwhm=0.001] - Amount of Dalton under which 2 peaks are joined | ||
*/ | ||
constructor(mf, options = {}) { | ||
@@ -24,2 +32,6 @@ this.mf = new MF(mf); | ||
/** | ||
* @return {Distribution} returns the internal object that contains the isotopic distribution | ||
*/ | ||
getDistribution() { | ||
@@ -50,2 +62,13 @@ let options = { | ||
/** | ||
* An object containing two arrays | ||
* @typedef {object} XY | ||
* @property {Array<number>} x - The x array | ||
* @property {Array<number>} y - The y array | ||
*/ | ||
/** | ||
* @return {XY} an object containing 2 properties: x:[] and y:[] | ||
*/ | ||
getXY() { | ||
@@ -66,4 +89,23 @@ let points = this.getDistribution().array; | ||
getGaussian(options = {}) { | ||
let distribution = this.getDistribution(); | ||
let points = distribution.array; | ||
if (points.length === 0) return []; | ||
let gaussianOptions = { | ||
start: Math.floor(options.from || distribution.minX - 10), | ||
end: Math.ceil(options.to || distribution.maxX + 10), | ||
pointsPerUnit: options.pointsPerUnit || 10, | ||
getWidth: options.getWidth ? options.getWidth : () => 0.1, | ||
}; | ||
let spectrumGenerator = new SpectrumGenerator(gaussianOptions); | ||
for (let point of points) { | ||
spectrumGenerator.addPeak([point.x, point.y]); | ||
} | ||
let spectrum = spectrumGenerator.getSpectrum(); | ||
return spectrum; | ||
} | ||
} | ||
module.exports = IsotopicDistribution; |
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
20765
23
531
4
+ Addedspectrum-generator@^1.0.1
+ Addedspectrum-generator@1.1.0(transitive)