Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

isotopic-distribution

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isotopic-distribution - npm Package Compare versions

Comparing version 0.5.2 to 0.5.6

src/__tests__/getGaussian.js

5

package.json
{
"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;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc