multiplet-analysis
Advanced tools
Comparing version 2.1.2 to 2.1.3
'use strict'; | ||
var maxY = require('ml-array-xy-max-y'); | ||
var mlSpectraProcessing = require('ml-spectra-processing'); | ||
var FFT = require('fft.js'); | ||
@@ -242,3 +242,2 @@ | ||
sign, // sign of the split 1: ++ -1: +- | ||
chopTail, // 1: cut tail | ||
multiplicity, | ||
@@ -468,8 +467,8 @@ incrementForSpeed, | ||
/**@typedef {import('../multiplet-analysis').AnalizeMultipletOptions} AnalizeMultipletOptions */ | ||
/**@typedef {import('cheminfo-types').DataXY} DataXY */ | ||
/** | ||
* Analyse a multiplet | ||
* @param {object} [data] object of the kind {x:[], y:[]} containing the multiplet | ||
* @param {object} [options={}] | ||
* @param {number} [options.frequency=400] frequency | ||
* @param {boolean} [options.debug=false] generate debug information if true | ||
* @param {DataXY} [data] xy data containing the multiplet. | ||
* @param {AnalizeMultipletOptions} [options] | ||
*/ | ||
@@ -512,9 +511,2 @@ | ||
let factorResolution = resolutionHz / minimalResolution; | ||
let nextPowerTwo = 2 ** Math.ceil(Math.log2(x.length * factorResolution)); | ||
let nextPowerTwoInital = 2 ** Math.ceil(Math.log2(x.length)); | ||
let integerFactorResolution = nextPowerTwo / nextPowerTwoInital; | ||
let scale; | ||
@@ -538,3 +530,7 @@ let spectrum; | ||
if (resolutionHz > minimalResolution) { | ||
// need increase resolution | ||
const nextPoTwoInital = mlSpectraProcessing.nextPowerOfTwo(x.length); | ||
const factorResolution = resolutionHz / minimalResolution; | ||
const nextPofTwo = mlSpectraProcessing.nextPowerOfTwo(x.length * factorResolution); | ||
const integerFactorResolution = nextPofTwo / nextPoTwoInital; | ||
let returned = trigInterpolate( | ||
@@ -555,9 +551,9 @@ x, | ||
spectrum = y; | ||
} //satnoeuhs | ||
} | ||
[spectrum, scale] = removeShift(spectrum, scale, 95); | ||
if (checkSymmetryFirst) { | ||
const result = removeShift(spectrum, scale, 95); | ||
let symFactor = getSymFactor(result.spectrum); | ||
let symFactor = getSymFactor(spectrum); | ||
if (symFactor < 0.98) { | ||
let maxAmplitudePosition = maxY({ x: scale, y: spectrum }); | ||
let maxAmplitudePosition = mlSpectraProcessing.xyMaxYPoint({ x: scale, y: spectrum }); | ||
return { | ||
@@ -568,6 +564,10 @@ chemShift: scale[maxAmplitudePosition.index], | ||
} else { | ||
scale = result.scale; | ||
spectrum = symmetrize(result.spectrum); | ||
spectrum = symmetrize(spectrum); | ||
} | ||
} | ||
let incrementForSpeed = 1; | ||
let curIncrementForSpeed; | ||
incrementForSpeed = (1 + 0.3 / minimalResolution) | 0; // 1 could be set better (according to line widht ?!) | ||
resolutionPpm = | ||
@@ -578,3 +578,3 @@ Math.abs(scale[0] - scale[scale.length - 1]) / (scale.length - 1); | ||
let minTestedPt = Math.trunc(minTestedJ / resolutionHz) + 1; | ||
let minTestedPt = Math.trunc(minTestedJ / resolutionHz) - incrementForSpeed; | ||
// will find center of symmetry of the multiplet | ||
@@ -586,5 +586,2 @@ // add zeroes as to make it symetrical if requested... and needed | ||
let incrementForSpeed = 1; | ||
let curIncrementForSpeed; | ||
incrementForSpeed = (1 + 0.3 / minimalResolution) | 0; // 1 could be set better (according to line widht ?!) | ||
for ( | ||
@@ -597,13 +594,13 @@ let loopoverJvalues = 1; | ||
let jStarArray = []; | ||
for (let jStar = 0; jStar < minTestedPt; jStar++) { | ||
for (let jStar = 0; jStar < minTestedPt + incrementForSpeed; jStar++) { | ||
jStarArray[jStar] = jStar * resolutionHz; | ||
scalProd[jStar] = 0; | ||
} | ||
let beforeSymSpe = new Float64Array(spectrum.length); | ||
//symmetrize if requested to | ||
if (symmetrizeEachStep === true) { | ||
//symmetrize if requested to | ||
const result = removeShift(spectrum, scale, 95); | ||
scale = result.scale; | ||
spectrum = result.spectrum; | ||
[spectrum, scale] = removeShift(spectrum, scale, 95); | ||
if (debug) { | ||
@@ -636,3 +633,7 @@ // save this to plot it as well | ||
let jStarFine; | ||
for (let jStar = minTestedPt; jStar < maxTestedPt; jStar++) { | ||
for ( | ||
let jStar = minTestedPt + incrementForSpeed; | ||
jStar < maxTestedPt; | ||
jStar++ | ||
) { | ||
jStarArray[jStar] = jStar * resolutionHz; | ||
@@ -650,8 +651,7 @@ scalProd[jStar] = -1; | ||
sign, | ||
chopTail, | ||
multiplicity, | ||
curIncrementForSpeed, | ||
); | ||
jStarArray[jStar] = jStar * resolutionHz; | ||
jStarArray[jStar] = jStar * resolutionHz; | ||
if (!gotJValue) { | ||
@@ -686,3 +686,2 @@ if (scalProd[jStar] > topValue) { | ||
sign, | ||
chopTail, | ||
multiplicity, | ||
@@ -762,3 +761,3 @@ curIncrementForSpeed, | ||
); // for next step | ||
if (chopTail) { | ||
if (chopTail || takeBestPartMultiplet) { | ||
let remove = 0.5 * topPosJ * (2 * multiplicity); | ||
@@ -774,3 +773,3 @@ scale = scale.slice(remove, scale.length - remove); | ||
let maxAmplitudePosition = maxY({ x: scale, y: spectrum }); | ||
let maxAmplitudePosition = mlSpectraProcessing.xyMaxYPoint({ x: scale, y: spectrum }); | ||
result.chemShift = scale[maxAmplitudePosition.index]; | ||
@@ -930,5 +929,5 @@ return result; | ||
} | ||
return { spectrum, scale }; | ||
return [spectrum, scale]; | ||
} | ||
exports.analyseMultiplet = analyseMultiplet; |
{ | ||
"name": "multiplet-analysis", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "Extract coupling constants from a complex NMR multiiplet", | ||
"main": "lib/index.js", | ||
"types": "multiplet-analysis.d.ts", | ||
"module": "src/index.js", | ||
@@ -12,10 +13,11 @@ "files": [ | ||
"scripts": { | ||
"build": "cheminfo-build --entry src/index.js --root AirPLS", | ||
"compile": "rollup -c", | ||
"prepack": "npm run compile", | ||
"eslint": "eslint src", | ||
"eslint-fix": "npm run eslint -- --fix", | ||
"prepack": "rollup -c", | ||
"prettier": "prettier --check src", | ||
"prettier-write": "prettier --write src", | ||
"test": "npm run test-coverage && npm run eslint && npm run prettier", | ||
"test-coverage": "jest --coverage", | ||
"test-only": "jest" | ||
"test": "npm run test-only && npm run eslint && npm run prettier", | ||
"test-only": "jest --coverage" | ||
}, | ||
@@ -50,2 +52,3 @@ "repository": { | ||
"jest-matcher-deep-close-to": "^3.0.2", | ||
"nmr-processing": "^14.0.5", | ||
"nmr-simulation": "^1.0.21", | ||
@@ -56,5 +59,7 @@ "prettier": "^2.8.8", | ||
"dependencies": { | ||
"cheminfo-types": "^1.8.1", | ||
"fft.js": "^4.0.4", | ||
"ml-array-xy-max-y": "^1.0.2" | ||
"ml-airpls": "^2.0.0", | ||
"ml-spectra-processing": "^14.7.0" | ||
} | ||
} |
@@ -8,3 +8,3 @@ /** | ||
import maxY from 'ml-array-xy-max-y'; | ||
import { nextPowerOfTwo, xyMaxYPoint } from 'ml-spectra-processing'; | ||
@@ -19,8 +19,8 @@ import { appendDebug } from './appendDebug'; | ||
/**@typedef {import('../multiplet-analysis').AnalizeMultipletOptions} AnalizeMultipletOptions */ | ||
/**@typedef {import('cheminfo-types').DataXY} DataXY */ | ||
/** | ||
* Analyse a multiplet | ||
* @param {object} [data] object of the kind {x:[], y:[]} containing the multiplet | ||
* @param {object} [options={}] | ||
* @param {number} [options.frequency=400] frequency | ||
* @param {boolean} [options.debug=false] generate debug information if true | ||
* @param {DataXY} [data] xy data containing the multiplet. | ||
* @param {AnalizeMultipletOptions} [options] | ||
*/ | ||
@@ -63,9 +63,2 @@ | ||
let factorResolution = resolutionHz / minimalResolution; | ||
let nextPowerTwo = 2 ** Math.ceil(Math.log2(x.length * factorResolution)); | ||
let nextPowerTwoInital = 2 ** Math.ceil(Math.log2(x.length)); | ||
let integerFactorResolution = nextPowerTwo / nextPowerTwoInital; | ||
let scale; | ||
@@ -89,3 +82,7 @@ let spectrum; | ||
if (resolutionHz > minimalResolution) { | ||
// need increase resolution | ||
const nextPoTwoInital = nextPowerOfTwo(x.length); | ||
const factorResolution = resolutionHz / minimalResolution; | ||
const nextPofTwo = nextPowerOfTwo(x.length * factorResolution); | ||
const integerFactorResolution = nextPofTwo / nextPoTwoInital; | ||
let returned = trigInterpolate( | ||
@@ -106,9 +103,9 @@ x, | ||
spectrum = y; | ||
} //satnoeuhs | ||
} | ||
[spectrum, scale] = removeShift(spectrum, scale, 95); | ||
if (checkSymmetryFirst) { | ||
const result = removeShift(spectrum, scale, 95); | ||
let symFactor = getSymFactor(result.spectrum); | ||
let symFactor = getSymFactor(spectrum); | ||
if (symFactor < 0.98) { | ||
let maxAmplitudePosition = maxY({ x: scale, y: spectrum }); | ||
let maxAmplitudePosition = xyMaxYPoint({ x: scale, y: spectrum }); | ||
return { | ||
@@ -119,6 +116,10 @@ chemShift: scale[maxAmplitudePosition.index], | ||
} else { | ||
scale = result.scale; | ||
spectrum = symmetrize(result.spectrum); | ||
spectrum = symmetrize(spectrum); | ||
} | ||
} | ||
let incrementForSpeed = 1; | ||
let curIncrementForSpeed; | ||
incrementForSpeed = (1 + 0.3 / minimalResolution) | 0; // 1 could be set better (according to line widht ?!) | ||
resolutionPpm = | ||
@@ -129,3 +130,3 @@ Math.abs(scale[0] - scale[scale.length - 1]) / (scale.length - 1); | ||
let minTestedPt = Math.trunc(minTestedJ / resolutionHz) + 1; | ||
let minTestedPt = Math.trunc(minTestedJ / resolutionHz) - incrementForSpeed; | ||
// will find center of symmetry of the multiplet | ||
@@ -137,5 +138,2 @@ // add zeroes as to make it symetrical if requested... and needed | ||
let incrementForSpeed = 1; | ||
let curIncrementForSpeed; | ||
incrementForSpeed = (1 + 0.3 / minimalResolution) | 0; // 1 could be set better (according to line widht ?!) | ||
for ( | ||
@@ -148,13 +146,13 @@ let loopoverJvalues = 1; | ||
let jStarArray = []; | ||
for (let jStar = 0; jStar < minTestedPt; jStar++) { | ||
for (let jStar = 0; jStar < minTestedPt + incrementForSpeed; jStar++) { | ||
jStarArray[jStar] = jStar * resolutionHz; | ||
scalProd[jStar] = 0; | ||
} | ||
let beforeSymSpe = new Float64Array(spectrum.length); | ||
//symmetrize if requested to | ||
if (symmetrizeEachStep === true) { | ||
//symmetrize if requested to | ||
const result = removeShift(spectrum, scale, 95); | ||
scale = result.scale; | ||
spectrum = result.spectrum; | ||
[spectrum, scale] = removeShift(spectrum, scale, 95); | ||
if (debug) { | ||
@@ -187,3 +185,7 @@ // save this to plot it as well | ||
let jStarFine; | ||
for (let jStar = minTestedPt; jStar < maxTestedPt; jStar++) { | ||
for ( | ||
let jStar = minTestedPt + incrementForSpeed; | ||
jStar < maxTestedPt; | ||
jStar++ | ||
) { | ||
jStarArray[jStar] = jStar * resolutionHz; | ||
@@ -201,8 +203,7 @@ scalProd[jStar] = -1; | ||
sign, | ||
chopTail, | ||
multiplicity, | ||
curIncrementForSpeed, | ||
); | ||
jStarArray[jStar] = jStar * resolutionHz; | ||
jStarArray[jStar] = jStar * resolutionHz; | ||
if (!gotJValue) { | ||
@@ -237,3 +238,2 @@ if (scalProd[jStar] > topValue) { | ||
sign, | ||
chopTail, | ||
multiplicity, | ||
@@ -313,3 +313,3 @@ curIncrementForSpeed, | ||
); // for next step | ||
if (chopTail) { | ||
if (chopTail || takeBestPartMultiplet) { | ||
let remove = 0.5 * topPosJ * (2 * multiplicity); | ||
@@ -325,3 +325,3 @@ scale = scale.slice(remove, scale.length - remove); | ||
let maxAmplitudePosition = maxY({ x: scale, y: spectrum }); | ||
let maxAmplitudePosition = xyMaxYPoint({ x: scale, y: spectrum }); | ||
result.chemShift = scale[maxAmplitudePosition.index]; | ||
@@ -481,3 +481,3 @@ return result; | ||
} | ||
return { spectrum, scale }; | ||
return [spectrum, scale]; | ||
} |
@@ -8,3 +8,2 @@ import { decofast1, decofast2 } from './deco'; | ||
sign, // sign of the split 1: ++ -1: +- | ||
chopTail, // 1: cut tail | ||
multiplicity, | ||
@@ -11,0 +10,0 @@ incrementForSpeed, |
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
61235
14
1724
4
10
+ Addedcheminfo-types@^1.8.1
+ Addedml-airpls@^2.0.0
+ Addedcheminfo-types@1.8.1(transitive)
+ Addedcuthill-mckee@1.0.0(transitive)
+ Addedd3-array@0.7.1(transitive)
+ Addedis-any-array@2.0.1(transitive)
+ Addedml-airpls@2.0.0(transitive)
+ Addedml-array-max@1.2.4(transitive)
+ Addedml-array-min@1.2.3(transitive)
+ Addedml-array-rescale@1.3.7(transitive)
+ Addedml-matrix@6.12.0(transitive)
+ Addedml-spectra-processing@14.9.1(transitive)
+ Addedml-xsadd@3.0.1(transitive)
+ Addedspline-interpolator@1.0.0(transitive)
- Removedml-array-xy-max-y@^1.0.2
- Removedml-array-xy-max-y@1.0.2(transitive)
- Removednum-sort@2.1.0(transitive)