nmr-processing
Advanced tools
Comparing version 0.11.1 to 0.12.0
# Changelog | ||
## [0.12.0](https://www.github.com/cheminfo/nmr-processing/compare/v0.11.1...v0.12.0) (2021-03-05) | ||
### Features | ||
* add simulation of 1D nmr spectrum from signals ([247d523](https://www.github.com/cheminfo/nmr-processing/commit/247d523f80d2877713fa6d978027643b4fa78a3f)) | ||
* use spectrum-generator in simulate1D ([9489d78](https://www.github.com/cheminfo/nmr-processing/commit/9489d78e1962c6cf834e14e24f46c876be6802e8)) | ||
* use static function for spinSystem creation ([1db79c5](https://www.github.com/cheminfo/nmr-processing/commit/1db79c5c2e5901b366d48c88263116cbbb1d0972)) | ||
### Bug Fixes | ||
* eslint ([69ac997](https://www.github.com/cheminfo/nmr-processing/commit/69ac9972cae991f27fe15648952593f92bcd91b9)) | ||
* rename xyzJResAnalizer to xyzJResAnalyzer ([fbc80ee](https://www.github.com/cheminfo/nmr-processing/commit/fbc80ee9485f028f1c12f4a75571fa4eb6e6d031)) | ||
### [0.11.1](https://www.github.com/cheminfo/nmr-processing/compare/v0.11.0...v0.11.1) (2021-03-01) | ||
@@ -4,0 +19,0 @@ |
{ | ||
"name": "nmr-processing", | ||
"version": "0.11.1", | ||
"version": "0.12.0", | ||
"description": "", | ||
@@ -59,4 +59,8 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"binary-search": "^1.3.6", | ||
"form-data": "^4.0.0", | ||
"is-any-array": "^0.1.1", | ||
"assign-deep": "^1.0.1", | ||
"ml-gsd": "^6.6.0", | ||
"ml-hclust": "^1.3.0", | ||
"ml-levenberg-marquardt": "^3.1.0", | ||
@@ -68,7 +72,9 @@ "ml-matrix": "^6.6.0", | ||
"ml-simple-clustering": "^0.1.0", | ||
"ml-sparse-matrix": "^2.1.0", | ||
"ml-spectra-processing": "^5.5.3", | ||
"node-fetch": "^2.6.1", | ||
"openchemlib": "^7.3.0", | ||
"openchemlib-utils": "^0.7.0" | ||
"openchemlib-utils": "^0.7.0", | ||
"spectrum-generator": "^4.7.0" | ||
} | ||
} |
@@ -17,1 +17,2 @@ /** | ||
export * from './constants/couplingPatterns'; | ||
export * from './xyz/xyzJResAnalyzer'; |
@@ -9,2 +9,3 @@ /* | ||
let maxErrorIter2 = 1; // Hz | ||
let jAxisKeys = { jAxis: 'x', intensity: 'intensity' }; | ||
@@ -18,3 +19,4 @@ export default { | ||
*/ | ||
compilePattern: function (signal) { | ||
compilePattern: function (signal, options = {}) { | ||
let { jAxisKey = jAxisKeys } = options; | ||
signal.multiplicity = 'm'; | ||
@@ -24,3 +26,7 @@ // 1.1 symmetrize | ||
// the compilation process. The unit of those peaks will be in Hz | ||
signal.symRank = symmetrizeChoiseBest(signal, maxErrorIter1, 1); | ||
signal.symRank = symmetrizeChoiseBest(signal, { | ||
maxError: maxErrorIter1, | ||
iteration: 1, | ||
jAxisKey, | ||
}); | ||
signal.asymmetric = true; | ||
@@ -96,3 +102,2 @@ // Is the signal symmetric? | ||
for (let u = 2; u <= j; u++) { | ||
// TODO improve those loops | ||
let jSum = 0; | ||
@@ -150,7 +155,5 @@ for (let i = 0; i < u; i++) { | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width; | ||
signal.integralData.from = peaks[0].x / signal.observe - peaks[0].width * 3; | ||
signal.integralData.to = | ||
peaks[nbPeaks - 1].x / signal.observe + peaks[nbPeaks - 1].width * 3; | ||
// Compile the pattern and format the constant couplings | ||
@@ -160,6 +163,2 @@ signal.maskPattern = signal.mask2; | ||
signal.pattern = signal.multiplicity; // Our library depends on this parameter, but it is old | ||
// console.log(signal); | ||
/* if (DEBUG) { | ||
console.log('Final j-couplings: ' + JSON.stringify(Jc)); | ||
}*/ | ||
} | ||
@@ -338,4 +337,5 @@ | ||
*/ | ||
function symmetrizeChoiseBest(signal, maxError, iteration) { | ||
let symRank1 = symmetrize(signal, maxError, iteration); | ||
function symmetrizeChoiseBest(signal, options = {}) { | ||
let { maxError, iteration, jAxisKey = jAxisKeys } = options; | ||
let symRank1 = symmetrize(signal, maxError, iteration, jAxisKey); | ||
let tmpPeaks = signal.peaksComp; | ||
@@ -346,3 +346,3 @@ let tmpMask = signal.mask; | ||
(signal.peaks[0].x + signal.peaks[signal.peaks.length - 1].x) / 2; | ||
let symRank2 = symmetrize(signal, maxError, iteration); | ||
let symRank2 = symmetrize(signal, maxError, iteration, jAxisKey); | ||
if (signal.peaksComp.length > tmpPeaks.length) { | ||
@@ -367,3 +367,4 @@ return symRank2; | ||
*/ | ||
function symmetrize(signal, maxError, iteration) { | ||
function symmetrize(signal, maxError, iteration, key) { | ||
let { jAxis, intensity } = key; | ||
// Before to symmetrize we need to keep only the peaks that possibly conforms the multiplete | ||
@@ -375,4 +376,4 @@ let max, min, avg, ratio, avgWidth; | ||
peaks[i] = { | ||
x: signal.peaks[i].x * signal.observe, | ||
intensity: signal.peaks[i].intensity, | ||
x: signal.peaks[i][jAxis] * signal.observe, | ||
intensity: signal.peaks[i][intensity], | ||
width: signal.peaks[i].width, | ||
@@ -408,3 +409,4 @@ }; | ||
mask[i] = true; | ||
heightSum += signal.peaks[i].intensity; | ||
// heightSum += signal.peaks[i].intensity; | ||
heightSum += peaks[i].intensity; | ||
} | ||
@@ -510,3 +512,3 @@ | ||
if (symFactor > 0.8 && symFactor < 0.97 && iteration < 2) { | ||
return symmetrize(signal, maxErrorIter2, 2); | ||
return symmetrize(signal, maxErrorIter2, 2, key); | ||
} else { | ||
@@ -513,0 +515,0 @@ // Center the given pattern at cs and symmetrize x |
@@ -74,3 +74,3 @@ import FormData from 'form-data'; | ||
coupling: Number(couplings[i + 2]), | ||
assignment: Number(couplings[i]), | ||
assignment: Number(couplings[i] - 1), | ||
}); | ||
@@ -77,0 +77,0 @@ } |
@@ -107,7 +107,2 @@ import { Matrix } from 'ml-matrix'; | ||
// How noisy is the spectrum depending on the kind of experiment. | ||
//const getLoGnStdDevNMR = (isHomoNuclear) => { | ||
// return isHomoNuclear ? 1.5 : 3; | ||
//}; | ||
/** | ||
@@ -161,2 +156,6 @@ * This function converts a set of 2D-peaks in 2D-signals. Each signal could be composed | ||
peaks[i].y = minY + dy * y; | ||
peaks[i].minX = minX + dx * peaks[i].minX; | ||
peaks[i].minY = minY + dy * peaks[i].minY; | ||
peaks[i].maxX = minX + dx * peaks[i].maxX; | ||
peaks[i].maxY = minY + dy * peaks[i].maxY; | ||
@@ -201,9 +200,6 @@ // Still having problems to correctly detect peaks on those areas. So I'm removing everything there. | ||
let sumZ = 0; | ||
for (let jPeak = clusters[iCluster].length - 1; jPeak >= 0; jPeak--) { | ||
// for (let jPeak = clusters[iCluster].length - 1; jPeak >= 0; jPeak--) { | ||
for (let jPeak = 0; jPeak < clusters[iCluster].length; jPeak++) { | ||
if (clusters[iCluster][jPeak] === 1) { | ||
peaks2D.push({ | ||
x: peaks[jPeak].x, | ||
y: peaks[jPeak].y, | ||
z: peaks[jPeak].z, | ||
}); | ||
peaks2D.push(peaks[jPeak]); | ||
signal.shiftX += peaks[jPeak].x * peaks[jPeak].z; | ||
@@ -228,4 +224,4 @@ signal.shiftY += peaks[jPeak].y * peaks[jPeak].z; | ||
signal.fromTo = [ | ||
{ from: minX + dx * minMax1[0], to: minX + dx * minMax1[1] }, | ||
{ from: minY + dy * minMax2[0], to: minY + dy * minMax2[1] }, | ||
{ from: minMax1[0], to: minMax1[1] }, | ||
{ from: minMax2[0], to: minMax2[1] }, | ||
]; | ||
@@ -232,0 +228,0 @@ signal.shiftX /= sumZ; |
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
295911
32
11512
18
+ Addedassign-deep@^1.0.1
+ Addedbinary-search@^1.3.6
+ Addedis-any-array@^0.1.1
+ Addedml-hclust@^1.3.0
+ Addedml-sparse-matrix@^2.1.0
+ Addedspectrum-generator@^4.7.0
+ Addedbinary-search@1.3.6(transitive)
+ Addedd3-random@2.2.2(transitive)
+ Addedheap@0.2.7(transitive)
+ Addedis-any-array@0.1.1(transitive)
+ Addedml-distance-euclidean@1.0.0(transitive)
+ Addedml-distance-matrix@1.0.0(transitive)
+ Addedml-hash-table@1.0.0(transitive)
+ Addedml-hclust@1.3.0(transitive)
+ Addedml-sparse-matrix@2.1.0(transitive)
+ Addedml-xsadd@2.0.0(transitive)
+ Addednum-sort@2.1.0(transitive)
+ Addedspectrum-generator@4.8.1(transitive)