nmr-processing
Advanced tools
Comparing version 3.2.0 to 3.3.0
# Changelog | ||
## [3.3.0](https://www.github.com/cheminfo/nmr-processing/compare/v3.2.0...v3.3.0) (2021-10-12) | ||
### Features | ||
* add integration in impurities ([26d97ea](https://www.github.com/cheminfo/nmr-processing/commit/26d97ea839505b53ed138631c6f4c567703c4263)) | ||
* add smiles in solvent impurities ([e2c3d6f](https://www.github.com/cheminfo/nmr-processing/commit/e2c3d6f9a44a901445e81e2f74361f2b8264070f)) | ||
* add some smiles in database ([bff15d7](https://www.github.com/cheminfo/nmr-processing/commit/bff15d7a4ff2b68b4138bb85c23d00aa79d6ad95)) | ||
* update n adapt to new version of ml-gsd ([#108](https://www.github.com/cheminfo/nmr-processing/issues/108)) ([d008691](https://www.github.com/cheminfo/nmr-processing/commit/d008691cf3d9c9e2dd908d7bb5639ee4dc41a2e3)) | ||
### Bug Fixes | ||
* add multiplicity in range ([1d4eaf5](https://www.github.com/cheminfo/nmr-processing/commit/1d4eaf56f9ae039dc9ee48b1a2ee1d54259e4ead)) | ||
* check default values at interfaces close [#105](https://www.github.com/cheminfo/nmr-processing/issues/105) ([ba6c82c](https://www.github.com/cheminfo/nmr-processing/commit/ba6c82ce7cafdc851d1c61ecb98f26006f064e59)) | ||
* correct integration and range in impurities ([96c687c](https://www.github.com/cheminfo/nmr-processing/commit/96c687cdf025423ef6a233082b1521de6d4e9072)) | ||
* remove useless ranges ([2b6119d](https://www.github.com/cheminfo/nmr-processing/commit/2b6119d47d6d05943266db5c871c5b7f3e45742f)) | ||
* rename nucleus to nuclei when it is array ([d815868](https://www.github.com/cheminfo/nmr-processing/commit/d8158687a94d8f62768830983384edfad93f6696)) | ||
* **resurrect:** regular expression for frequency ([fad1ed3](https://www.github.com/cheminfo/nmr-processing/commit/fad1ed3965ffcd1796a4b3defdc54333a49097ee)) | ||
* wrong info for water in impurities ([290eb9e](https://www.github.com/cheminfo/nmr-processing/commit/290eb9ef297e972bf103209ee05380bef797cbb7)) | ||
## [3.2.0](https://www.github.com/cheminfo/nmr-processing/compare/v3.1.0...v3.2.0) (2021-10-05) | ||
@@ -4,0 +25,0 @@ |
@@ -22,2 +22,3 @@ /** | ||
export * from './utilities/resurrect'; | ||
export * from './utilities/rangeFromSignal'; | ||
export * from './xy/xyAutoPeaksPicking'; | ||
@@ -24,0 +25,0 @@ export * from './xy/xyAutoRangesPicking'; |
@@ -32,3 +32,3 @@ import { impurities } from '../constants/impurities'; | ||
while (j--) { | ||
tolerance = error + peakList[j].width; | ||
tolerance = error + peakList[j].shape.width; | ||
difference = Math.abs(impurity[i].shift - peakList[j].x); | ||
@@ -35,0 +35,0 @@ if (difference < tolerance) { |
@@ -20,9 +20,9 @@ import { xyIntegration } from 'ml-spectra-processing'; | ||
kind: 'signal', | ||
startX: peak.x - peak.width, | ||
stopX: peak.x + peak.width, | ||
startX: peak.x - peak.shape.width, | ||
stopX: peak.x + peak.shape.width, | ||
observe: frequency, | ||
nucleus, | ||
integralData: { | ||
from: peak.x - peak.width * 3, | ||
to: peak.x + peak.width * 3, | ||
from: peak.x - peak.shape.width * 3, | ||
to: peak.x + peak.shape.width * 3, | ||
value: 0, | ||
@@ -34,3 +34,5 @@ }, | ||
intensity: peak.y, | ||
width: peak.width, | ||
shape: { | ||
width: peak.shape.width, | ||
}, | ||
}, | ||
@@ -81,3 +83,9 @@ ], | ||
let peakR = signal.peaks.splice(j, 1)[0]; | ||
peaksO.push({ x: peakR.x, y: peakR.intensity, width: peakR.width }); | ||
peaksO.push({ | ||
x: peakR.x, | ||
y: peakR.intensity, | ||
shape: { | ||
width: peakR.shape.width, | ||
}, | ||
}); | ||
signal.mask.splice(j, 1); | ||
@@ -192,3 +200,3 @@ signal.mask2.splice(j, 1); | ||
else { | ||
let tmp = peak.x + peak.width; | ||
let tmp = peak.x + peak.shape.width; | ||
signal1D.stopX = Math.max(signal1D.stopX, tmp); | ||
@@ -200,6 +208,8 @@ signal1D.startX = Math.min(signal1D.startX, tmp); | ||
intensity: peak.y, | ||
width: peak.width, | ||
shape: { | ||
width: peak.shape.width, | ||
}, | ||
}); | ||
signal1D.integralData.from = Math.min(signal1D.integralData.from, peak.x - peak.width * 3); | ||
signal1D.integralData.to = Math.max(signal1D.integralData.to, peak.x + peak.width * 3); | ||
signal1D.integralData.from = Math.min(signal1D.integralData.from, peak.x - peak.shape.width * 3); | ||
signal1D.integralData.to = Math.max(signal1D.integralData.to, peak.x + peak.shape.width * 3); | ||
if (peak.kind) | ||
@@ -248,4 +258,4 @@ signal1D.kind = peak.kind; | ||
function computeArea(peak) { | ||
return Math.abs(peak.intensity * peak.width * 1.57); // todo add an option with this value: 1.772453851 | ||
return Math.abs(peak.intensity * peak.shape.width * 1.57); // todo add an option with this value: 1.772453851 | ||
} | ||
//# sourceMappingURL=peaksToRanges.js.map |
@@ -153,8 +153,9 @@ /* | ||
let nbPeaks = peaks.length; | ||
signal.startX = peaks[0].x / signal.observe - peaks[0].width; | ||
signal.startX = peaks[0].x / signal.observe - peaks[0].shape.width; | ||
signal.stopX = | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width; | ||
signal.integralData.from = peaks[0].x / signal.observe - peaks[0].width * 3; | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].shape.width; | ||
signal.integralData.from = | ||
peaks[0].x / signal.observe - peaks[0].shape.width * 3; | ||
signal.integralData.to = | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width * 3; | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].shape.width * 3; | ||
// Compile the pattern and format the constant couplings | ||
@@ -378,3 +379,5 @@ signal.maskPattern = signal.mask2; | ||
intensity: peak[intensity], | ||
width: peak.width, | ||
shape: { | ||
width: peak.shape.width, | ||
}, | ||
}; | ||
@@ -391,3 +394,3 @@ } | ||
peaks[i].intensity /= 2; | ||
peaks[i].width += peaks[i + 1].width; | ||
peaks[i].shape.width += peaks[i + 1].shape.width; | ||
peaks.splice(i + 1, 1); | ||
@@ -440,5 +443,5 @@ } | ||
avg = Math.min(peaks[left].intensity, peaks[right].intensity); | ||
avgWidth = Math.min(peaks[left].width, peaks[right].width); | ||
avgWidth = Math.min(peaks[left].shape.width, peaks[right].shape.width); | ||
peaks[left].intensity = peaks[right].intensity = avg; | ||
peaks[left].width = peaks[right].width = avgWidth; | ||
peaks[left].shape.width = peaks[right].shape.width = avgWidth; | ||
middle = [ | ||
@@ -620,4 +623,4 @@ middle[0] + (peaks[right].x + peaks[left].x) / 2, | ||
function getArea(peak) { | ||
return Math.abs(peak.intensity * peak.width * 1.57); // 1.772453851); | ||
return Math.abs(peak.intensity * peak.shape.width * 1.57); // 1.772453851); | ||
} | ||
//# sourceMappingURL=jAnalyzer.js.map |
import { agnes } from 'ml-hclust'; | ||
import { Matrix } from 'ml-matrix'; | ||
import { getGroupedDiastereotopicAtomIDs, getPathsInfo, } from 'openchemlib-utils'; | ||
import { getNucleus } from './getNucleus'; | ||
import { getNuclei } from './getNuclei'; | ||
import { getPredictions } from './getPredictions'; | ||
@@ -91,3 +91,3 @@ function checkFromTo(options) { | ||
diaIDs: spectra.x.diaIDs, | ||
nucleus: getNucleus({ from, to }), | ||
nuclei: getNuclei({ from, to }), | ||
joinedSignals, | ||
@@ -94,0 +94,0 @@ signals: splitSignals(joinedSignals), |
@@ -0,4 +1,4 @@ | ||
import arraySequentialFill from 'ml-array-sequential-fill'; | ||
import { SpectrumGenerator } from 'spectrum-generator'; | ||
import { hackSignalsToXY } from '../signals/hackSignalsToXY'; | ||
import { fromToArray } from '../utilities/fromToArray'; | ||
function checkForSignals(ranges) { | ||
@@ -44,3 +44,3 @@ for (let range of ranges) { | ||
return { | ||
x: fromToArray(from, to, nbPoints), | ||
x: arraySequentialFill({ from, to, size: nbPoints }), | ||
y: spectrum, | ||
@@ -47,0 +47,0 @@ }; |
@@ -0,1 +1,2 @@ | ||
import { rangeFromSignal } from '../utilities/rangeFromSignal'; | ||
function checkNbAtoms(signals) { | ||
@@ -14,7 +15,5 @@ for (let signal of signals) { | ||
wrapped.forEach((signal) => { | ||
let halfWidth = (signal.original.js || []).reduce((total, j) => (total += j.coupling / frequency), 0) / | ||
2 + | ||
tolerance; | ||
signal.from = signal.original.delta - halfWidth; | ||
signal.to = signal.original.delta + halfWidth; | ||
const fromTo = rangeFromSignal(signal.original, { frequency, tolerance }); | ||
signal.from = fromTo.from; | ||
signal.to = fromTo.to; | ||
}); | ||
@@ -21,0 +20,0 @@ wrapped = wrapped.sort((signal1, signal2) => signal1.from - signal2.from); |
import rescale from 'ml-array-rescale'; | ||
import { fromToArray } from '../utilities/fromToArray'; | ||
import arraySequentialFill from 'ml-array-sequential-fill'; | ||
import { signalsToSpinSystem } from './simulation/signalsToSpinSystem'; | ||
@@ -30,3 +30,3 @@ import simulate1D from './simulation/simulate1D'; | ||
return { | ||
x: fromToArray(from, to, nbPoints), | ||
x: arraySequentialFill({ from, to, size: nbPoints }), | ||
y: Array.from(new Float64Array(nbPoints)), | ||
@@ -33,0 +33,0 @@ }; |
@@ -25,3 +25,4 @@ import { resurrectRange } from './resurrectRange'; | ||
else { | ||
const range = resurrectRange(part); | ||
const { frequency, nucleus } = data.experiment; | ||
const range = resurrectRange(part, { frequency, nucleus }); | ||
if (range) | ||
@@ -50,3 +51,3 @@ data.ranges.push(range); | ||
if (frequencyParts.length) { | ||
const frequency = frequencyParts[0].replace(/[^[0-9.]]/g, ''); | ||
const frequency = frequencyParts[0].replace(/[^0-9]/g, ''); | ||
if (frequency.length > 1) | ||
@@ -53,0 +54,0 @@ data.experiment.frequency = Number(frequency); |
@@ -0,5 +1,6 @@ | ||
import { rangeFromSignal } from './rangeFromSignal'; | ||
import { splitParenthesis } from './splitParenthesis'; | ||
import { splitPatterns } from './splitPatterns'; | ||
export function resurrectRange(part, options = {}) { | ||
const { tolerance = 0.05, frequency = 400 } = options; | ||
const { nucleus = '1h', frequency = 400 } = options; | ||
const split = splitParenthesis(part); | ||
@@ -65,7 +66,3 @@ if (!split.before) | ||
if (range.from === range.to) { | ||
let halfWidth = (signal.js || []).reduce((total, j) => (total += j.coupling / frequency), 0) / | ||
2 + | ||
tolerance; | ||
range.from = signal.delta - halfWidth; | ||
range.to = signal.delta + halfWidth; | ||
range = { ...range, ...rangeFromSignal(signal, { nucleus, frequency }) }; | ||
} | ||
@@ -72,0 +69,0 @@ return range; |
@@ -32,2 +32,3 @@ import { gsd, joinBroadPeaks, optimizePeaks } from 'ml-gsd'; | ||
let peakList = gsd(data, { | ||
shape, | ||
sgOptions, | ||
@@ -34,0 +35,0 @@ minMaxRatio, |
@@ -20,3 +20,3 @@ import { Matrix } from 'ml-matrix'; | ||
export function xyzAutoPeaksPicking(spectraData, options) { | ||
let { sizeToPad = 14, realTopDetection = true, thresholdFactor = 0.5, nucleus = ['1H', '1H'], observedFrequencies, enhanceSymmetry = false, clean = true, maxPercentCutOff = 0.03, tolerances = [24, 24], convolutionByFFT = true, kernel: kernelOptions, } = options; | ||
let { sizeToPad = 14, realTopDetection = true, thresholdFactor = 0.5, nuclei = ['1H', '1H'], observedFrequencies, enhanceSymmetry = false, clean = true, maxPercentCutOff = 0.03, tolerances = [24, 24], convolutionByFFT = true, kernel: kernelOptions, } = options; | ||
if (!Array.isArray(observedFrequencies) && | ||
@@ -75,3 +75,3 @@ !ArrayBuffer.isView(observedFrequencies)) { | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
observedFrequencies, | ||
@@ -86,4 +86,4 @@ realTopDetection, | ||
const createSignals2D = (peaks, options) => { | ||
let { nCols, nRows, absoluteData, originalData, observedFrequencies, tolerances, nucleus, realTopDetection, minY, maxY, minX, maxX, } = options; | ||
let [nucleusX, nucleusY] = nucleus; | ||
let { nCols, nRows, absoluteData, originalData, observedFrequencies, tolerances, nuclei, realTopDetection, minY, maxY, minX, maxX, } = options; | ||
let [nucleusX, nucleusY] = nuclei; | ||
let [toleranceX, toleranceY] = tolerances; | ||
@@ -90,0 +90,0 @@ let [observeFrequencyX, observeFrequencyY] = observedFrequencies; |
import simpleClustering from 'ml-simple-clustering'; | ||
import jAnalyzer from '../peaks/util/jAnalyzer'; | ||
export function xyzJResAnalyzer(signals, options = {}) { | ||
let { reference = 0, referenceMaxShiftError = 0.08, tolerances = [10, 100], nucleus = ['1H', '1H'], observedFrequencies = [400, 400], jAnalyzer = { | ||
let { reference = 0, referenceMaxShiftError = 0.08, tolerances = [10, 100], nuclei = ['1H', '1H'], observedFrequencies = [400, 400], jAnalyzer = { | ||
jAxisKey: { jAxis: 'y', intensity: 'z' }, | ||
@@ -10,3 +10,3 @@ }, } = options; | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
jAnalyzer, | ||
@@ -25,7 +25,7 @@ }); | ||
function compilePattern(signals, options) { | ||
let { observedFrequencies, tolerances, nucleus, jAnalyzer: jAnalyzerOptions, } = options; | ||
let { observedFrequencies, tolerances, nuclei, jAnalyzer: jAnalyzerOptions, } = options; | ||
let signalOptions = { | ||
observedFrequencies, | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
dx: signals[0].x.resolution, | ||
@@ -85,5 +85,5 @@ dy: signals[0].y.resolution, | ||
function createSignals2D(peaksInput, options) { | ||
let { observedFrequencies, tolerances, nucleus, dx, dy } = options; | ||
let { observedFrequencies, tolerances, nuclei, dx, dy } = options; | ||
const peaks = JSON.parse(JSON.stringify(peaksInput)); | ||
let [nucleusX, nucleusY] = nucleus; | ||
let [nucleusX, nucleusY] = nuclei; | ||
let [toleranceX, toleranceY] = tolerances; | ||
@@ -90,0 +90,0 @@ let [observeFrequencyX, observeFrequencyY] = observedFrequencies; |
@@ -1,2 +0,2 @@ | ||
import { DatabaseNMREntry } from './DatabaseNMREntry'; | ||
import type { DatabaseNMREntry } from './DatabaseNMREntry'; | ||
export declare const carbonImpurities: DatabaseNMREntry[]; |
@@ -1,2 +0,2 @@ | ||
import { DatabaseNMREntry } from './DatabaseNMREntry'; | ||
import type { DatabaseNMREntry } from './DatabaseNMREntry'; | ||
export declare const protonImpurities: DatabaseNMREntry[]; |
@@ -22,2 +22,3 @@ /** | ||
export * from './utilities/resurrect'; | ||
export * from './utilities/rangeFromSignal'; | ||
export * from './xy/xyAutoPeaksPicking'; | ||
@@ -24,0 +25,0 @@ export * from './xy/xyAutoRangesPicking'; |
@@ -34,2 +34,3 @@ "use strict"; | ||
__exportStar(require("./utilities/resurrect"), exports); | ||
__exportStar(require("./utilities/rangeFromSignal"), exports); | ||
__exportStar(require("./xy/xyAutoPeaksPicking"), exports); | ||
@@ -36,0 +37,0 @@ __exportStar(require("./xy/xyAutoRangesPicking"), exports); |
import { impurities } from '../constants/impurities'; | ||
import { GSDPeak } from '../types/GSDPeak'; | ||
import type { NMRPeak1D } from '../types/NMRPeak1D'; | ||
declare type Solvent = keyof typeof impurities; | ||
@@ -23,3 +23,3 @@ export interface OptionsPeaksFilterImpurities { | ||
*/ | ||
export declare function peaksFilterImpurities(peakList: GSDPeak[], options?: OptionsPeaksFilterImpurities): GSDPeak[]; | ||
export declare function peaksFilterImpurities(peakList: NMRPeak1D[], options?: OptionsPeaksFilterImpurities): NMRPeak1D[]; | ||
export {}; |
@@ -36,3 +36,3 @@ "use strict"; | ||
while (j--) { | ||
tolerance = error + peakList[j].width; | ||
tolerance = error + peakList[j].shape.width; | ||
difference = Math.abs(impurity[i].shift - peakList[j].x); | ||
@@ -39,0 +39,0 @@ if (difference < tolerance) { |
import type { DataXY } from 'cheminfo-types'; | ||
import type { GSDPeak } from '../types/GSDPeak'; | ||
import { NMRPeak1D } from '../types/NMRPeak1D'; | ||
import type { NMRRange } from '../types/NMRRange'; | ||
@@ -60,2 +60,2 @@ export interface OptionsPeaksToRanges { | ||
*/ | ||
export declare function peaksToRanges(data: DataXY, peakList: GSDPeak[], options?: OptionsPeaksToRanges): NMRRange[]; | ||
export declare function peaksToRanges(data: DataXY, peakList: NMRPeak1D[], options?: OptionsPeaksToRanges): NMRRange[]; |
@@ -26,9 +26,9 @@ "use strict"; | ||
kind: 'signal', | ||
startX: peak.x - peak.width, | ||
stopX: peak.x + peak.width, | ||
startX: peak.x - peak.shape.width, | ||
stopX: peak.x + peak.shape.width, | ||
observe: frequency, | ||
nucleus, | ||
integralData: { | ||
from: peak.x - peak.width * 3, | ||
to: peak.x + peak.width * 3, | ||
from: peak.x - peak.shape.width * 3, | ||
to: peak.x + peak.shape.width * 3, | ||
value: 0, | ||
@@ -40,3 +40,5 @@ }, | ||
intensity: peak.y, | ||
width: peak.width, | ||
shape: { | ||
width: peak.shape.width, | ||
}, | ||
}, | ||
@@ -87,3 +89,9 @@ ], | ||
let peakR = signal.peaks.splice(j, 1)[0]; | ||
peaksO.push({ x: peakR.x, y: peakR.intensity, width: peakR.width }); | ||
peaksO.push({ | ||
x: peakR.x, | ||
y: peakR.intensity, | ||
shape: { | ||
width: peakR.shape.width, | ||
}, | ||
}); | ||
signal.mask.splice(j, 1); | ||
@@ -199,3 +207,3 @@ signal.mask2.splice(j, 1); | ||
else { | ||
let tmp = peak.x + peak.width; | ||
let tmp = peak.x + peak.shape.width; | ||
signal1D.stopX = Math.max(signal1D.stopX, tmp); | ||
@@ -207,6 +215,8 @@ signal1D.startX = Math.min(signal1D.startX, tmp); | ||
intensity: peak.y, | ||
width: peak.width, | ||
shape: { | ||
width: peak.shape.width, | ||
}, | ||
}); | ||
signal1D.integralData.from = Math.min(signal1D.integralData.from, peak.x - peak.width * 3); | ||
signal1D.integralData.to = Math.max(signal1D.integralData.to, peak.x + peak.width * 3); | ||
signal1D.integralData.from = Math.min(signal1D.integralData.from, peak.x - peak.shape.width * 3); | ||
signal1D.integralData.to = Math.max(signal1D.integralData.to, peak.x + peak.shape.width * 3); | ||
if (peak.kind) | ||
@@ -255,4 +265,4 @@ signal1D.kind = peak.kind; | ||
function computeArea(peak) { | ||
return Math.abs(peak.intensity * peak.width * 1.57); // todo add an option with this value: 1.772453851 | ||
return Math.abs(peak.intensity * peak.shape.width * 1.57); // todo add an option with this value: 1.772453851 | ||
} | ||
//# sourceMappingURL=peaksToRanges.js.map |
@@ -1,3 +0,3 @@ | ||
import type { GSDPeak } from '../../types/GSDPeak'; | ||
import { MakeMandatory } from '../../types/MakeMandatory'; | ||
import { NMRPeak1D } from '../../types/NMRPeak1D'; | ||
export interface JAxisKeys { | ||
@@ -13,3 +13,3 @@ [key: string]: string; | ||
} | ||
export declare type Peak1DIntern = Omit<GSDPeak, 'y'> & { | ||
export declare type Peak1DIntern = Omit<NMRPeak1D, 'y'> & { | ||
intensity: number; | ||
@@ -16,0 +16,0 @@ }; |
@@ -155,8 +155,9 @@ "use strict"; | ||
let nbPeaks = peaks.length; | ||
signal.startX = peaks[0].x / signal.observe - peaks[0].width; | ||
signal.startX = peaks[0].x / signal.observe - peaks[0].shape.width; | ||
signal.stopX = | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width; | ||
signal.integralData.from = peaks[0].x / signal.observe - peaks[0].width * 3; | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].shape.width; | ||
signal.integralData.from = | ||
peaks[0].x / signal.observe - peaks[0].shape.width * 3; | ||
signal.integralData.to = | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width * 3; | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].shape.width * 3; | ||
// Compile the pattern and format the constant couplings | ||
@@ -380,3 +381,5 @@ signal.maskPattern = signal.mask2; | ||
intensity: peak[intensity], | ||
width: peak.width, | ||
shape: { | ||
width: peak.shape.width, | ||
}, | ||
}; | ||
@@ -393,3 +396,3 @@ } | ||
peaks[i].intensity /= 2; | ||
peaks[i].width += peaks[i + 1].width; | ||
peaks[i].shape.width += peaks[i + 1].shape.width; | ||
peaks.splice(i + 1, 1); | ||
@@ -442,5 +445,5 @@ } | ||
avg = Math.min(peaks[left].intensity, peaks[right].intensity); | ||
avgWidth = Math.min(peaks[left].width, peaks[right].width); | ||
avgWidth = Math.min(peaks[left].shape.width, peaks[right].shape.width); | ||
peaks[left].intensity = peaks[right].intensity = avg; | ||
peaks[left].width = peaks[right].width = avgWidth; | ||
peaks[left].shape.width = peaks[right].shape.width = avgWidth; | ||
middle = [ | ||
@@ -622,4 +625,4 @@ middle[0] + (peaks[right].x + peaks[left].x) / 2, | ||
function getArea(peak) { | ||
return Math.abs(peak.intensity * peak.width * 1.57); // 1.772453851); | ||
return Math.abs(peak.intensity * peak.shape.width * 1.57); // 1.772453851); | ||
} | ||
//# sourceMappingURL=jAnalyzer.js.map |
@@ -61,3 +61,3 @@ import { Molecule } from 'openchemlib'; | ||
diaIDs: string[]; | ||
nucleus: string[]; | ||
nuclei: string[]; | ||
joinedSignals: import("../types/NMRSignal2D").NMRSignal2D[]; | ||
@@ -64,0 +64,0 @@ signals: any[]; |
@@ -60,3 +60,3 @@ import { Molecule } from 'openchemlib'; | ||
diaIDs: string[]; | ||
nucleus: string[]; | ||
nuclei: string[]; | ||
joinedSignals: import("../types/NMRSignal2D").NMRSignal2D[]; | ||
@@ -63,0 +63,0 @@ signals: any[]; |
@@ -60,3 +60,3 @@ import { Molecule } from 'openchemlib'; | ||
diaIDs: string[]; | ||
nucleus: string[]; | ||
nuclei: string[]; | ||
joinedSignals: import("../types/NMRSignal2D").NMRSignal2D[]; | ||
@@ -63,0 +63,0 @@ signals: any[]; |
@@ -5,5 +5,2 @@ import type { Molecule } from 'openchemlib'; | ||
* Makes a prediction using proton. | ||
* @param {Molecule} molecule - OCL Molecule instance. | ||
* @param {object} [options={}] | ||
* @param {function} [options.cache] A callback receiving a molfile and the result | ||
* @returns {Promise<object>} - object with molfile, diaIDs, signals, joined signals by diaIDs and ranges. | ||
@@ -10,0 +7,0 @@ */ |
@@ -79,3 +79,3 @@ import { Molecule } from 'openchemlib'; | ||
diaIDs: string[]; | ||
nucleus: string[]; | ||
nuclei: string[]; | ||
joinedSignals: NMRSignal2D[]; | ||
@@ -82,0 +82,0 @@ signals: any[]; |
@@ -7,3 +7,3 @@ "use strict"; | ||
const openchemlib_utils_1 = require("openchemlib-utils"); | ||
const getNucleus_1 = require("./getNucleus"); | ||
const getNuclei_1 = require("./getNuclei"); | ||
const getPredictions_1 = require("./getPredictions"); | ||
@@ -95,3 +95,3 @@ function checkFromTo(options) { | ||
diaIDs: spectra.x.diaIDs, | ||
nucleus: (0, getNucleus_1.getNucleus)({ from, to }), | ||
nuclei: (0, getNuclei_1.getNuclei)({ from, to }), | ||
joinedSignals, | ||
@@ -98,0 +98,0 @@ signals: splitSignals(joinedSignals), |
import type { NMRRange } from '../types/NMRRange'; | ||
export interface RangesToACSOptions { | ||
/** | ||
* nucleus | ||
* @default '1H' | ||
*/ | ||
nucleus?: string; | ||
@@ -8,6 +12,8 @@ ascending?: boolean; | ||
* default value depends of nucleus | ||
* @default 1|2 | ||
*/ | ||
nbDecimalDelta?: number; | ||
/** | ||
* default value depends of nucleus | ||
* Number of decimals to round the scalar coupling value | ||
* @default 1 | ||
*/ | ||
@@ -17,2 +23,3 @@ nbDecimalJ?: number; | ||
* default value depends of nucleus | ||
* @default 400|100 | ||
*/ | ||
@@ -19,0 +26,0 @@ observedFrequency?: number; |
@@ -0,5 +1,38 @@ | ||
import type { Shape1DOption } from 'spectrum-generator'; | ||
import type { NMRRange } from '../types/NMRRange'; | ||
export interface RangeToXYOptions { | ||
/** | ||
* frequency observed | ||
* @default 400 | ||
*/ | ||
frequency: number; | ||
/** | ||
* line width to draw the signals | ||
* @default 1 | ||
*/ | ||
lineWidth: number; | ||
/** | ||
* lower limit in the spectrum. | ||
* @default 0 | ||
*/ | ||
from: number; | ||
/** | ||
* upper limit in the spectrum. | ||
* @default 10 | ||
*/ | ||
to: number; | ||
/** | ||
* number of points of the spectrum. | ||
* @default 16384 | ||
*/ | ||
nbPoints: number; | ||
/** | ||
* options of signals. | ||
* @default { kind: 'gaussian' } | ||
*/ | ||
shape: Shape1DOption; | ||
} | ||
export declare function rangesToXY(ranges: NMRRange[], options?: any): { | ||
x: Float64Array; | ||
x: number[]; | ||
y: Float64Array; | ||
}; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.rangesToXY = void 0; | ||
const ml_array_sequential_fill_1 = __importDefault(require("ml-array-sequential-fill")); | ||
const spectrum_generator_1 = require("spectrum-generator"); | ||
const hackSignalsToXY_1 = require("../signals/hackSignalsToXY"); | ||
const fromToArray_1 = require("../utilities/fromToArray"); | ||
function checkForSignals(ranges) { | ||
@@ -47,3 +50,3 @@ for (let range of ranges) { | ||
return { | ||
x: (0, fromToArray_1.fromToArray)(from, to, nbPoints), | ||
x: (0, ml_array_sequential_fill_1.default)({ from, to, size: nbPoints }), | ||
y: spectrum, | ||
@@ -50,0 +53,0 @@ }; |
import type { XYNumber } from 'spectrum-generator'; | ||
import type { NMRSignal2D } from '../types/NMRSignal2D'; | ||
interface signals2DToZOptions { | ||
/** | ||
* lower limit in the spectrum, if it is a number the value will be defined for both axes | ||
* @default -1 | ||
*/ | ||
from?: number | XYNumber; | ||
/** | ||
* upper limit in the spectrum, if it is a number the value will be defined for both axes | ||
* @default 12 | ||
*/ | ||
to?: number | XYNumber; | ||
/** | ||
* Number of points of each dimension of the spectrum, | ||
* if it is a number the value will be defined for both axes | ||
* @default 512 | ||
*/ | ||
nbPoints?: number | XYNumber; | ||
/** | ||
* full width at half maximum of signals for each dimension, | ||
* if it is a number the value will be defined for both axes. | ||
* @default 0.02 | ||
*/ | ||
width?: number | XYNumber; | ||
@@ -8,0 +26,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.signalsToRanges = void 0; | ||
const rangeFromSignal_1 = require("../utilities/rangeFromSignal"); | ||
function checkNbAtoms(signals) { | ||
@@ -17,7 +18,5 @@ for (let signal of signals) { | ||
wrapped.forEach((signal) => { | ||
let halfWidth = (signal.original.js || []).reduce((total, j) => (total += j.coupling / frequency), 0) / | ||
2 + | ||
tolerance; | ||
signal.from = signal.original.delta - halfWidth; | ||
signal.to = signal.original.delta + halfWidth; | ||
const fromTo = (0, rangeFromSignal_1.rangeFromSignal)(signal.original, { frequency, tolerance }); | ||
signal.from = fromTo.from; | ||
signal.to = fromTo.to; | ||
}); | ||
@@ -24,0 +23,0 @@ wrapped = wrapped.sort((signal1, signal2) => signal1.from - signal2.from); |
@@ -8,3 +8,3 @@ "use strict"; | ||
const ml_array_rescale_1 = __importDefault(require("ml-array-rescale")); | ||
const fromToArray_1 = require("../utilities/fromToArray"); | ||
const ml_array_sequential_fill_1 = __importDefault(require("ml-array-sequential-fill")); | ||
const signalsToSpinSystem_1 = require("./simulation/signalsToSpinSystem"); | ||
@@ -37,3 +37,3 @@ const simulate1D_1 = __importDefault(require("./simulation/simulate1D")); | ||
return { | ||
x: (0, fromToArray_1.fromToArray)(from, to, nbPoints), | ||
x: (0, ml_array_sequential_fill_1.default)({ from, to, size: nbPoints }), | ||
y: Array.from(new Float64Array(nbPoints)), | ||
@@ -40,0 +40,0 @@ }; |
@@ -29,3 +29,4 @@ "use strict"; | ||
else { | ||
const range = (0, resurrectRange_1.resurrectRange)(part); | ||
const { frequency, nucleus } = data.experiment; | ||
const range = (0, resurrectRange_1.resurrectRange)(part, { frequency, nucleus }); | ||
if (range) | ||
@@ -54,3 +55,3 @@ data.ranges.push(range); | ||
if (frequencyParts.length) { | ||
const frequency = frequencyParts[0].replace(/[^[0-9.]]/g, ''); | ||
const frequency = frequencyParts[0].replace(/[^0-9]/g, ''); | ||
if (frequency.length > 1) | ||
@@ -57,0 +58,0 @@ data.experiment.frequency = Number(frequency); |
@@ -1,2 +0,2 @@ | ||
import { NMRRange } from '../types/NMRRange'; | ||
import type { NMRRange } from '../types/NMRRange'; | ||
export declare function resurrectRange(part: string, options?: any): NMRRange | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resurrectRange = void 0; | ||
const rangeFromSignal_1 = require("./rangeFromSignal"); | ||
const splitParenthesis_1 = require("./splitParenthesis"); | ||
const splitPatterns_1 = require("./splitPatterns"); | ||
function resurrectRange(part, options = {}) { | ||
const { tolerance = 0.05, frequency = 400 } = options; | ||
const { nucleus = '1h', frequency = 400 } = options; | ||
const split = (0, splitParenthesis_1.splitParenthesis)(part); | ||
@@ -68,7 +69,3 @@ if (!split.before) | ||
if (range.from === range.to) { | ||
let halfWidth = (signal.js || []).reduce((total, j) => (total += j.coupling / frequency), 0) / | ||
2 + | ||
tolerance; | ||
range.from = signal.delta - halfWidth; | ||
range.to = signal.delta + halfWidth; | ||
range = { ...range, ...(0, rangeFromSignal_1.rangeFromSignal)(signal, { nucleus, frequency }) }; | ||
} | ||
@@ -75,0 +72,0 @@ return range; |
import { DataXY } from 'cheminfo-types'; | ||
import { GSDPeak } from '../types/GSDPeak'; | ||
import type { NMRPeak1D } from '../types/NMRPeak1D'; | ||
interface OptionsGetPeakList { | ||
@@ -90,3 +90,3 @@ /** | ||
} | ||
export declare function xyAutoPeaksPicking(data: DataXY, options?: OptionsXYAutoPeaksPicking): GSDPeak[]; | ||
export declare function xyAutoPeaksPicking(data: DataXY, options?: OptionsXYAutoPeaksPicking): NMRPeak1D[]; | ||
export {}; |
@@ -36,2 +36,3 @@ "use strict"; | ||
let peakList = (0, ml_gsd_1.gsd)(data, { | ||
shape, | ||
sgOptions, | ||
@@ -38,0 +39,0 @@ minMaxRatio, |
@@ -27,6 +27,6 @@ import type { GetKernelOptions } from '../peaks/util/getKernel'; | ||
/** | ||
* specify the nucleus of each dimension | ||
* specify the nuclei of each dimension | ||
* @default ['1H','1H'] | ||
*/ | ||
nucleus?: string[]; | ||
nuclei?: string[]; | ||
/** | ||
@@ -79,3 +79,3 @@ * specify the frequency for each dimension. | ||
tolerances: number[]; | ||
nucleus: string[]; | ||
nuclei: string[]; | ||
realTopDetection: boolean; | ||
@@ -82,0 +82,0 @@ minY: number; |
@@ -45,3 +45,3 @@ "use strict"; | ||
function xyzAutoPeaksPicking(spectraData, options) { | ||
let { sizeToPad = 14, realTopDetection = true, thresholdFactor = 0.5, nucleus = ['1H', '1H'], observedFrequencies, enhanceSymmetry = false, clean = true, maxPercentCutOff = 0.03, tolerances = [24, 24], convolutionByFFT = true, kernel: kernelOptions, } = options; | ||
let { sizeToPad = 14, realTopDetection = true, thresholdFactor = 0.5, nuclei = ['1H', '1H'], observedFrequencies, enhanceSymmetry = false, clean = true, maxPercentCutOff = 0.03, tolerances = [24, 24], convolutionByFFT = true, kernel: kernelOptions, } = options; | ||
if (!Array.isArray(observedFrequencies) && | ||
@@ -100,3 +100,3 @@ !ArrayBuffer.isView(observedFrequencies)) { | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
observedFrequencies, | ||
@@ -112,4 +112,4 @@ realTopDetection, | ||
const createSignals2D = (peaks, options) => { | ||
let { nCols, nRows, absoluteData, originalData, observedFrequencies, tolerances, nucleus, realTopDetection, minY, maxY, minX, maxX, } = options; | ||
let [nucleusX, nucleusY] = nucleus; | ||
let { nCols, nRows, absoluteData, originalData, observedFrequencies, tolerances, nuclei, realTopDetection, minY, maxY, minX, maxX, } = options; | ||
let [nucleusX, nucleusY] = nuclei; | ||
let [toleranceX, toleranceY] = tolerances; | ||
@@ -116,0 +116,0 @@ let [observeFrequencyX, observeFrequencyY] = observedFrequencies; |
@@ -6,3 +6,3 @@ import type { JAxisKeys } from '../peaks/util/jAnalyzer'; | ||
tolerances?: number[] | Float64Array; | ||
nucleus?: string[]; | ||
nuclei?: string[]; | ||
jAnalyzer?: { | ||
@@ -13,3 +13,11 @@ jAxisKey: JAxisKeys; | ||
interface XYZJResAnalyzerOptions extends CompilePatternOptions { | ||
/** | ||
* maximum difference in Hz to discard if the signal is symmetric. | ||
* @default 0.08 | ||
*/ | ||
referenceMaxShiftError?: number; | ||
/** | ||
* reference value in Hz | ||
* @default 0 | ||
*/ | ||
reference?: number; | ||
@@ -16,0 +24,0 @@ } |
@@ -10,3 +10,3 @@ "use strict"; | ||
function xyzJResAnalyzer(signals, options = {}) { | ||
let { reference = 0, referenceMaxShiftError = 0.08, tolerances = [10, 100], nucleus = ['1H', '1H'], observedFrequencies = [400, 400], jAnalyzer = { | ||
let { reference = 0, referenceMaxShiftError = 0.08, tolerances = [10, 100], nuclei = ['1H', '1H'], observedFrequencies = [400, 400], jAnalyzer = { | ||
jAxisKey: { jAxis: 'y', intensity: 'z' }, | ||
@@ -17,3 +17,3 @@ }, } = options; | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
jAnalyzer, | ||
@@ -33,7 +33,7 @@ }); | ||
function compilePattern(signals, options) { | ||
let { observedFrequencies, tolerances, nucleus, jAnalyzer: jAnalyzerOptions, } = options; | ||
let { observedFrequencies, tolerances, nuclei, jAnalyzer: jAnalyzerOptions, } = options; | ||
let signalOptions = { | ||
observedFrequencies, | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
dx: signals[0].x.resolution, | ||
@@ -93,5 +93,5 @@ dy: signals[0].y.resolution, | ||
function createSignals2D(peaksInput, options) { | ||
let { observedFrequencies, tolerances, nucleus, dx, dy } = options; | ||
let { observedFrequencies, tolerances, nuclei, dx, dy } = options; | ||
const peaks = JSON.parse(JSON.stringify(peaksInput)); | ||
let [nucleusX, nucleusY] = nucleus; | ||
let [nucleusX, nucleusY] = nuclei; | ||
let [toleranceX, toleranceY] = tolerances; | ||
@@ -98,0 +98,0 @@ let [observeFrequencyX, observeFrequencyY] = observedFrequencies; |
{ | ||
"name": "nmr-processing", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Pure functions allowing to process NMR spectra.", | ||
@@ -50,18 +50,18 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@types/jest": "^27.0.1", | ||
"@types/jest": "^27.0.2", | ||
"cheminfo-build": "^1.1.11", | ||
"cheminfo-types": "^0.3.1", | ||
"cheminfo-types": "^0.6.0", | ||
"eslint": "^7.32.0", | ||
"eslint-config-cheminfo-typescript": "^8.0.9", | ||
"esm": "^3.2.25", | ||
"jest": "^27.0.6", | ||
"jest-matcher-deep-close-to": "^2.0.1", | ||
"jest": "^27.2.4", | ||
"jest-matcher-deep-close-to": "^3.0.0", | ||
"md5": "^2.3.0", | ||
"ml-array-median": "^1.1.5", | ||
"nmr-xy-testdata": "^0.2.1", | ||
"openchemlib": "^7.4.2", | ||
"prettier": "^2.3.2", | ||
"openchemlib": "^7.4.3", | ||
"prettier": "^2.4.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^27.0.5", | ||
"typescript": "^4.4.2" | ||
"typescript": "^4.4.3" | ||
}, | ||
@@ -73,8 +73,9 @@ "dependencies": { | ||
"form-data": "^4.0.0", | ||
"is-any-array": "^1.0.0", | ||
"is-any-array": "^1.0.1", | ||
"ml-array-mean": "^1.1.5", | ||
"ml-array-rescale": "^1.3.6", | ||
"ml-array-sequential-fill": "^1.1.7", | ||
"ml-array-sum": "^1.1.5", | ||
"ml-gsd": "^6.8.2", | ||
"ml-hclust": "^3.0.0", | ||
"ml-gsd": "^7.0.1", | ||
"ml-hclust": "^3.1.0", | ||
"ml-levenberg-marquardt": "^3.1.1", | ||
@@ -89,5 +90,5 @@ "ml-matrix": "^6.8.0", | ||
"ml-tree-set": "^0.1.1", | ||
"openchemlib-utils": "^1.5.0", | ||
"openchemlib-utils": "^1.5.1", | ||
"spectrum-generator": "^5.4.0" | ||
} | ||
} |
@@ -28,2 +28,3 @@ /** | ||
export * from './utilities/resurrect'; | ||
export * from './utilities/rangeFromSignal'; | ||
@@ -30,0 +31,0 @@ export * from './xy/xyAutoPeaksPicking'; |
import { impurities } from '../constants/impurities'; | ||
import type { ImpuritySignal } from '../constants/impurities'; | ||
import { GSDPeak } from '../types/GSDPeak'; | ||
import type { NMRPeak1D } from '../types/NMRPeak1D'; | ||
@@ -37,3 +37,3 @@ const toCheck = ['solvent', 'h2o', 'tms']; | ||
export function peaksFilterImpurities( | ||
peakList: GSDPeak[], | ||
peakList: NMRPeak1D[], | ||
options: OptionsPeaksFilterImpurities = {}, | ||
@@ -60,3 +60,3 @@ ) { | ||
function checkImpurity( | ||
peakList: GSDPeak[], | ||
peakList: NMRPeak1D[], | ||
impurity: ImpuritySignal[], | ||
@@ -71,3 +71,3 @@ options: OptionsCheckImpurity, | ||
while (j--) { | ||
tolerance = error + peakList[j].width; | ||
tolerance = error + peakList[j].shape.width; | ||
difference = Math.abs(impurity[i].shift - peakList[j].x); | ||
@@ -74,0 +74,0 @@ if (difference < tolerance) { |
import type { DataXY } from 'cheminfo-types'; | ||
import type { GSDPeak } from 'ml-gsd'; | ||
import { xyIntegration } from 'ml-spectra-processing'; | ||
import type { GSDPeak } from '../types/GSDPeak'; | ||
import { MakeMandatory } from '../types/MakeMandatory'; | ||
import { NMRPeak1D } from '../types/NMRPeak1D'; | ||
import type { NMRRange } from '../types/NMRRange'; | ||
@@ -86,3 +87,3 @@ import type { NMRSignal1D } from '../types/NMRSignal1D'; | ||
const assignSignal = ( | ||
peak: GSDPeak, | ||
peak: NMRPeak1D, | ||
frequency: number, | ||
@@ -95,9 +96,9 @@ nucleus: string, | ||
kind: 'signal', | ||
startX: peak.x - peak.width, | ||
stopX: peak.x + peak.width, | ||
startX: peak.x - peak.shape.width, | ||
stopX: peak.x + peak.shape.width, | ||
observe: frequency, | ||
nucleus, | ||
integralData: { | ||
from: peak.x - peak.width * 3, | ||
to: peak.x + peak.width * 3, | ||
from: peak.x - peak.shape.width * 3, | ||
to: peak.x + peak.shape.width * 3, | ||
value: 0, | ||
@@ -109,3 +110,5 @@ }, | ||
intensity: peak.y, | ||
width: peak.width, | ||
shape: { | ||
width: peak.shape.width, | ||
}, | ||
}, | ||
@@ -121,3 +124,3 @@ ], | ||
data: DataXY, | ||
peakList: GSDPeak[], | ||
peakList: NMRPeak1D[], | ||
options: OptionsPeaksToRanges = {}, | ||
@@ -179,3 +182,9 @@ ): NMRRange[] { | ||
let peakR = signal.peaks.splice(j, 1)[0]; | ||
peaksO.push({ x: peakR.x, y: peakR.intensity, width: peakR.width }); | ||
peaksO.push({ | ||
x: peakR.x, | ||
y: peakR.intensity, | ||
shape: { | ||
width: peakR.shape.width, | ||
}, | ||
}); | ||
signal.mask.splice(j, 1); | ||
@@ -283,3 +292,3 @@ signal.mask2.splice(j, 1); | ||
data: DataXY, | ||
peakList: GSDPeak[], | ||
peakList: NMRPeak1D[], | ||
options: OptionsDetectSignals = {}, | ||
@@ -307,3 +316,3 @@ ): SignalIntern[] { | ||
} else { | ||
let tmp = peak.x + peak.width; | ||
let tmp = peak.x + peak.shape.width; | ||
signal1D.stopX = Math.max(signal1D.stopX, tmp); | ||
@@ -315,11 +324,13 @@ signal1D.startX = Math.min(signal1D.startX, tmp); | ||
intensity: peak.y, | ||
width: peak.width, | ||
shape: { | ||
width: peak.shape.width, | ||
}, | ||
}); | ||
signal1D.integralData.from = Math.min( | ||
signal1D.integralData.from, | ||
peak.x - peak.width * 3, | ||
peak.x - peak.shape.width * 3, | ||
); | ||
signal1D.integralData.to = Math.max( | ||
signal1D.integralData.to, | ||
peak.x + peak.width * 3, | ||
peak.x + peak.shape.width * 3, | ||
); | ||
@@ -372,3 +383,3 @@ if (peak.kind) signal1D.kind = peak.kind; | ||
function computeArea(peak: Peak1DIntern) { | ||
return Math.abs(peak.intensity * peak.width * 1.57); // todo add an option with this value: 1.772453851 | ||
return Math.abs(peak.intensity * peak.shape.width * 1.57); // todo add an option with this value: 1.772453851 | ||
} |
@@ -1,3 +0,3 @@ | ||
import type { GSDPeak } from '../../types/GSDPeak'; | ||
import { MakeMandatory } from '../../types/MakeMandatory'; | ||
import { NMRPeak1D } from '../../types/NMRPeak1D'; | ||
@@ -32,3 +32,3 @@ /* | ||
export type Peak1DIntern = Omit<GSDPeak, 'y'> & { intensity: number }; | ||
export type Peak1DIntern = Omit<NMRPeak1D, 'y'> & { intensity: number }; | ||
@@ -223,8 +223,9 @@ export interface SignalIntern { | ||
let nbPeaks = peaks.length; | ||
signal.startX = peaks[0].x / signal.observe - peaks[0].width; | ||
signal.startX = peaks[0].x / signal.observe - peaks[0].shape.width; | ||
signal.stopX = | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width; | ||
signal.integralData.from = peaks[0].x / signal.observe - peaks[0].width * 3; | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].shape.width; | ||
signal.integralData.from = | ||
peaks[0].x / signal.observe - peaks[0].shape.width * 3; | ||
signal.integralData.to = | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width * 3; | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].shape.width * 3; | ||
// Compile the pattern and format the constant couplings | ||
@@ -470,3 +471,5 @@ signal.maskPattern = signal.mask2; | ||
intensity: peak[intensity], | ||
width: peak.width, | ||
shape: { | ||
width: peak.shape.width, | ||
}, | ||
}; | ||
@@ -483,3 +486,3 @@ } | ||
peaks[i].intensity /= 2; | ||
peaks[i].width += peaks[i + 1].width; | ||
peaks[i].shape.width += peaks[i + 1].shape.width; | ||
peaks.splice(i + 1, 1); | ||
@@ -531,5 +534,8 @@ } | ||
avg = Math.min(peaks[left].intensity, peaks[right].intensity); | ||
avgWidth = Math.min(peaks[left].width, peaks[right].width); | ||
avgWidth = Math.min( | ||
peaks[left].shape.width, | ||
peaks[right].shape.width, | ||
); | ||
peaks[left].intensity = peaks[right].intensity = avg; | ||
peaks[left].width = peaks[right].width = avgWidth; | ||
peaks[left].shape.width = peaks[right].shape.width = avgWidth; | ||
middle = [ | ||
@@ -714,3 +720,3 @@ middle[0] + (peaks[right].x + peaks[left].x) / 2, | ||
function getArea(peak: Peak1DIntern) { | ||
return Math.abs(peak.intensity * peak.width * 1.57); // 1.772453851); | ||
return Math.abs(peak.intensity * peak.shape.width * 1.57); // 1.772453851); | ||
} |
@@ -17,5 +17,2 @@ import fetch from 'cross-fetch'; | ||
* Makes a prediction using proton. | ||
* @param {Molecule} molecule - OCL Molecule instance. | ||
* @param {object} [options={}] | ||
* @param {function} [options.cache] A callback receiving a molfile and the result | ||
* @returns {Promise<object>} - object with molfile, diaIDs, signals, joined signals by diaIDs and ranges. | ||
@@ -22,0 +19,0 @@ */ |
@@ -21,3 +21,3 @@ import { agnes, Cluster } from 'ml-hclust'; | ||
import { getNucleus } from './getNucleus'; | ||
import { getNuclei } from './getNuclei'; | ||
import { getPredictions } from './getPredictions'; | ||
@@ -244,3 +244,3 @@ | ||
diaIDs: spectra.x.diaIDs, | ||
nucleus: getNucleus({ from, to }), | ||
nuclei: getNuclei({ from, to }), | ||
joinedSignals, | ||
@@ -247,0 +247,0 @@ signals: splitSignals(joinedSignals), |
@@ -28,2 +28,6 @@ import { signalJoinCouplings } from '../signal/signalJoinCouplings'; | ||
export interface RangesToACSOptions { | ||
/** | ||
* nucleus | ||
* @default '1H' | ||
*/ | ||
nucleus?: string; | ||
@@ -34,6 +38,8 @@ ascending?: boolean; | ||
* default value depends of nucleus | ||
* @default 1|2 | ||
*/ | ||
nbDecimalDelta?: number; | ||
/** | ||
* default value depends of nucleus | ||
* Number of decimals to round the scalar coupling value | ||
* @default 1 | ||
*/ | ||
@@ -43,2 +49,3 @@ nbDecimalJ?: number; | ||
* default value depends of nucleus | ||
* @default 400|100 | ||
*/ | ||
@@ -45,0 +52,0 @@ observedFrequency?: number; |
import { DoubleArray } from 'cheminfo-types'; | ||
import arraySequentialFill from 'ml-array-sequential-fill'; | ||
import { SpectrumGenerator } from 'spectrum-generator'; | ||
import type { Shape1DOption } from 'spectrum-generator'; | ||
import { hackSignalsToXY } from '../signals/hackSignalsToXY'; | ||
import { MakeMandatory } from '../types/MakeMandatory'; | ||
import type { MakeMandatory } from '../types/MakeMandatory'; | ||
import type { NMRRange } from '../types/NMRRange'; | ||
import type { NMRSignal1D } from '../types/NMRSignal1D'; | ||
import { fromToArray } from '../utilities/fromToArray'; | ||
type rangeWithSignal = MakeMandatory<NMRRange, 'signals'>; | ||
export interface RangeToXYOptions { | ||
/** | ||
* frequency observed | ||
* @default 400 | ||
*/ | ||
frequency: number; | ||
/** | ||
* line width to draw the signals | ||
* @default 1 | ||
*/ | ||
lineWidth: number; | ||
/** | ||
* lower limit in the spectrum. | ||
* @default 0 | ||
*/ | ||
from: number; | ||
/** | ||
* upper limit in the spectrum. | ||
* @default 10 | ||
*/ | ||
to: number; | ||
/** | ||
* number of points of the spectrum. | ||
* @default 16384 | ||
*/ | ||
nbPoints: number; | ||
/** | ||
* options of signals. | ||
* @default { kind: 'gaussian' } | ||
*/ | ||
shape: Shape1DOption; | ||
} | ||
function checkForSignals( | ||
@@ -65,3 +99,3 @@ ranges: NMRRange[], | ||
return { | ||
x: fromToArray(from, to, nbPoints), | ||
x: arraySequentialFill({ from, to, size: nbPoints }), | ||
y: spectrum, | ||
@@ -68,0 +102,0 @@ }; |
@@ -7,5 +7,23 @@ import { generateSpectrum2D } from 'spectrum-generator'; | ||
interface signals2DToZOptions { | ||
/** | ||
* lower limit in the spectrum, if it is a number the value will be defined for both axes | ||
* @default -1 | ||
*/ | ||
from?: number | XYNumber; | ||
/** | ||
* upper limit in the spectrum, if it is a number the value will be defined for both axes | ||
* @default 12 | ||
*/ | ||
to?: number | XYNumber; | ||
/** | ||
* Number of points of each dimension of the spectrum, | ||
* if it is a number the value will be defined for both axes | ||
* @default 512 | ||
*/ | ||
nbPoints?: number | XYNumber; | ||
/** | ||
* full width at half maximum of signals for each dimension, | ||
* if it is a number the value will be defined for both axes. | ||
* @default 0.02 | ||
*/ | ||
width?: number | XYNumber; | ||
@@ -12,0 +30,0 @@ } |
import { MakeMandatory } from '../types/MakeMandatory'; | ||
import type { NMRRange } from '../types/NMRRange'; | ||
import type { NMRSignal1D } from '../types/NMRSignal1D'; | ||
import { rangeFromSignal } from '../utilities/rangeFromSignal'; | ||
@@ -27,3 +28,5 @@ interface SignalsToRangesOptions { | ||
function checkNbAtoms(signals: NMRSignal1D[]): asserts signals is Signals1DWithNbAtoms[] { | ||
function checkNbAtoms( | ||
signals: NMRSignal1D[], | ||
): asserts signals is Signals1DWithNbAtoms[] { | ||
for (let signal of signals) { | ||
@@ -47,11 +50,5 @@ if (!signal.nbAtoms) throw new Error('nbAtoms is mandatory'); | ||
wrapped.forEach((signal) => { | ||
let halfWidth = | ||
(signal.original.js || []).reduce( | ||
(total, j) => (total += j.coupling / frequency), | ||
0, | ||
) / | ||
2 + | ||
tolerance; | ||
signal.from = signal.original.delta - halfWidth; | ||
signal.to = signal.original.delta + halfWidth; | ||
const fromTo = rangeFromSignal(signal.original, { frequency, tolerance }); | ||
signal.from = fromTo.from; | ||
signal.to = fromTo.to; | ||
}); | ||
@@ -64,3 +61,2 @@ | ||
for (let signal of wrapped) { | ||
if (range.from === undefined || signal.from > range.to) { | ||
@@ -67,0 +63,0 @@ range = { |
import rescale from 'ml-array-rescale'; | ||
import arraySequentialFill from 'ml-array-sequential-fill'; | ||
import type { Shape1DOption } from 'spectrum-generator'; | ||
@@ -7,3 +8,2 @@ | ||
import { Jcoupling } from '../types/jcoupling'; | ||
import { fromToArray } from '../utilities/fromToArray'; | ||
@@ -95,3 +95,3 @@ import { signalsToSpinSystem } from './simulation/signalsToSpinSystem'; | ||
return { | ||
x: fromToArray(from, to, nbPoints), | ||
x: arraySequentialFill({ from, to, size: nbPoints }), | ||
y: Array.from(new Float64Array(nbPoints)), | ||
@@ -98,0 +98,0 @@ }; |
@@ -10,3 +10,4 @@ import type { NMRSignal1D } from './NMRSignal1D'; | ||
integration?: number; | ||
multiplicity?: string; | ||
signals?: NMRSignal1D[]; | ||
} |
@@ -1,3 +0,3 @@ | ||
import { GSDPeak } from './GSDPeak'; | ||
import type { Jcoupling } from './jcoupling'; | ||
import { GSDPeak } from './ml-gsd/index.d'; | ||
@@ -4,0 +4,0 @@ interface NMRSignal1D { |
@@ -40,3 +40,4 @@ import type { NMRRange } from '../types/NMRRange'; | ||
} else { | ||
const range = resurrectRange(part); | ||
const { frequency, nucleus } = data.experiment; | ||
const range = resurrectRange(part, { frequency, nucleus }); | ||
if (range) data.ranges.push(range); | ||
@@ -67,3 +68,4 @@ } | ||
if (frequencyParts.length) { | ||
const frequency = frequencyParts[0].replace(/[^[0-9.]]/g, ''); | ||
const frequency = frequencyParts[0].replace(/[^0-9]/g, ''); | ||
if (frequency.length > 1) data.experiment.frequency = Number(frequency); | ||
@@ -70,0 +72,0 @@ } |
@@ -1,4 +0,5 @@ | ||
import { NMRRange } from '../types/NMRRange'; | ||
import { NMRSignal1D } from '../types/NMRSignal1D'; | ||
import type { NMRRange } from '../types/NMRRange'; | ||
import type { NMRSignal1D } from '../types/NMRSignal1D'; | ||
import { rangeFromSignal } from './rangeFromSignal'; | ||
import { splitParenthesis } from './splitParenthesis'; | ||
@@ -8,3 +9,3 @@ import { splitPatterns } from './splitPatterns'; | ||
export function resurrectRange(part: string, options: any = {}) { | ||
const { tolerance = 0.05, frequency = 400 } = options; | ||
const { nucleus = '1h', frequency = 400 } = options; | ||
const split = splitParenthesis(part); | ||
@@ -77,11 +78,3 @@ if (!split.before) return; | ||
if (range.from === range.to) { | ||
let halfWidth = | ||
(signal.js || []).reduce( | ||
(total, j) => (total += j.coupling / frequency), | ||
0, | ||
) / | ||
2 + | ||
tolerance; | ||
range.from = signal.delta - halfWidth; | ||
range.to = signal.delta + halfWidth; | ||
range = { ...range, ...rangeFromSignal(signal, { nucleus, frequency }) }; | ||
} | ||
@@ -88,0 +81,0 @@ |
@@ -9,3 +9,3 @@ import { DataXY } from 'cheminfo-types'; | ||
import { GSDPeak } from '../types/GSDPeak'; | ||
import type { NMRPeak1D } from '../types/NMRPeak1D'; | ||
/** | ||
@@ -109,3 +109,3 @@ * Implementation of the peak picking method described by Cobas in: | ||
options: OptionsXYAutoPeaksPicking = {}, | ||
): GSDPeak[] { | ||
): NMRPeak1D[] { | ||
const { | ||
@@ -156,3 +156,2 @@ from, | ||
} | ||
return peaks; | ||
@@ -177,2 +176,3 @@ } | ||
let peakList = gsd(data, { | ||
shape, | ||
sgOptions, | ||
@@ -179,0 +179,0 @@ minMaxRatio, |
@@ -50,6 +50,6 @@ import { Matrix } from 'ml-matrix'; | ||
/** | ||
* specify the nucleus of each dimension | ||
* specify the nuclei of each dimension | ||
* @default ['1H','1H'] | ||
*/ | ||
nucleus?: string[]; | ||
nuclei?: string[]; | ||
/** | ||
@@ -98,3 +98,3 @@ * specify the frequency for each dimension. | ||
thresholdFactor = 0.5, | ||
nucleus = ['1H', '1H'], | ||
nuclei = ['1H', '1H'], | ||
observedFrequencies, | ||
@@ -174,3 +174,3 @@ enhanceSymmetry = false, | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
observedFrequencies, | ||
@@ -200,3 +200,3 @@ realTopDetection, | ||
tolerances: number[]; | ||
nucleus: string[]; | ||
nuclei: string[]; | ||
realTopDetection: boolean; | ||
@@ -216,3 +216,3 @@ minY: number; | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
realTopDetection, | ||
@@ -225,3 +225,3 @@ minY, | ||
let [nucleusX, nucleusY] = nucleus; | ||
let [nucleusX, nucleusY] = nuclei; | ||
let [toleranceX, toleranceY] = tolerances; | ||
@@ -228,0 +228,0 @@ let [observeFrequencyX, observeFrequencyY] = observedFrequencies; |
@@ -12,3 +12,3 @@ import simpleClustering from 'ml-simple-clustering'; | ||
tolerances?: number[] | Float64Array; | ||
nucleus?: string[]; | ||
nuclei?: string[]; | ||
jAnalyzer?: { jAxisKey: JAxisKeys }; | ||
@@ -18,3 +18,11 @@ } | ||
interface XYZJResAnalyzerOptions extends CompilePatternOptions { | ||
/** | ||
* maximum difference in Hz to discard if the signal is symmetric. | ||
* @default 0.08 | ||
*/ | ||
referenceMaxShiftError?: number; | ||
/** | ||
* reference value in Hz | ||
* @default 0 | ||
*/ | ||
reference?: number; | ||
@@ -25,3 +33,3 @@ } | ||
CompilePatternOptions, | ||
'observedFrequencies' | 'tolerances' | 'nucleus' | 'jAnalyzer' | ||
'observedFrequencies' | 'tolerances' | 'nuclei' | 'jAnalyzer' | ||
>; | ||
@@ -37,3 +45,3 @@ | ||
tolerances = [10, 100], | ||
nucleus = ['1H', '1H'], | ||
nuclei = ['1H', '1H'], | ||
observedFrequencies = [400, 400], | ||
@@ -47,3 +55,3 @@ jAnalyzer = { | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
jAnalyzer, | ||
@@ -68,3 +76,3 @@ }); | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
jAnalyzer: jAnalyzerOptions, | ||
@@ -76,3 +84,3 @@ } = options; | ||
tolerances, | ||
nucleus, | ||
nuclei, | ||
dx: signals[0].x.resolution, | ||
@@ -152,7 +160,7 @@ dy: signals[0].y.resolution, | ||
function createSignals2D(peaksInput: MPFPeak[], options: any) { | ||
let { observedFrequencies, tolerances, nucleus, dx, dy } = options; | ||
let { observedFrequencies, tolerances, nuclei, dx, dy } = options; | ||
const peaks: Peak2DHack[] = JSON.parse(JSON.stringify(peaksInput)); | ||
let [nucleusX, nucleusY] = nucleus; | ||
let [nucleusX, nucleusY] = nuclei; | ||
let [toleranceX, toleranceY] = tolerances; | ||
@@ -159,0 +167,0 @@ let [observeFrequencyX, observeFrequencyY] = observedFrequencies; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3927036
339
109846
4
22
+ Addedml-gsd@7.0.1(transitive)
+ Addedml-spectra-fitting@2.0.0(transitive)
Updatedis-any-array@^1.0.1
Updatedml-gsd@^7.0.1
Updatedml-hclust@^3.1.0
Updatedopenchemlib-utils@^1.5.1