spectra-nmr-utilities
Advanced tools
Comparing version 1.0.8 to 1.0.9
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.nmrJ = nmrJ; | ||
exports.joinCoupling = joinCoupling; | ||
exports.group = group; | ||
exports.compilePattern = compilePattern; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
@@ -14,3 +8,3 @@ const patterns = ['s', 'd', 't', 'q', 'quint', 'h', 'sept', 'o', 'n']; | ||
function nmrJ(Js, options = {}) { | ||
var jString = ''; | ||
let jString = ''; | ||
options = Object.assign({}, { separator: ', ', nbDecimal: 2 }, options); | ||
@@ -29,10 +23,10 @@ let j, i; | ||
function joinCoupling(signal, tolerance = 0.05) { | ||
var jc = signal.j; | ||
let jc = signal.j; | ||
if (jc && jc.length > 0) { | ||
var cont = jc[0].assignment ? jc[0].assignment.length : 1; | ||
let cont = jc[0].assignment ? jc[0].assignment.length : 1; | ||
var pattern = ''; | ||
var newNmrJs = []; | ||
var diaIDs = []; | ||
var atoms = []; | ||
jc.sort(function (a, b) { | ||
let newNmrJs = []; | ||
let diaIDs = []; | ||
let atoms = []; | ||
jc.sort(function(a, b) { | ||
return b.coupling - a.coupling; | ||
@@ -54,3 +48,3 @@ }); | ||
coupling: Math.abs(jc[i].coupling), | ||
multiplicity: patterns[cont] | ||
multiplicity: patterns[cont], | ||
}; | ||
@@ -76,3 +70,3 @@ if (diaIDs.length > 0) { | ||
coupling: Math.abs(jc[i].coupling), | ||
multiplicity: patterns[cont] | ||
multiplicity: patterns[cont], | ||
}; | ||
@@ -98,3 +92,3 @@ if (diaIDs.length > 0) { | ||
function group(signals, options = {}) { | ||
var i, k; | ||
let i, k; | ||
for (i = 0; i < signals.length; i++) { | ||
@@ -104,4 +98,8 @@ var j = signals[i].j; | ||
for (k = j.length - 2; k >= 0; k--) { | ||
for (var m = j.length - 1; m > k; m--) { | ||
if (j[k].diaID === j[m].diaID && j[k].coupling === j[m].coupling && j[k].distance === j[m].distance) { | ||
for (let m = j.length - 1; m > k; m--) { | ||
if ( | ||
j[k].diaID === j[m].diaID && | ||
j[k].coupling === j[m].coupling && | ||
j[k].distance === j[m].distance | ||
) { | ||
j[k].assignment = j[k].assignment.concat(j[m].assignment); | ||
@@ -134,5 +132,3 @@ j.splice(m, 1); | ||
} | ||
// signals[i].multiplicity = module.exports.compilePattern(signals[i], options.tolerance); | ||
} | ||
// console.log(signals[i]); | ||
signals[i].multiplicity = compilePattern(signals[i], options.tolerance); | ||
@@ -144,10 +140,10 @@ } | ||
function compilePattern(signal, tolerance = 0.05) { | ||
var jc = signal.j; | ||
var pattern = ''; | ||
let jc = signal.j; | ||
let pattern = ''; | ||
if (jc && jc.length > 0) { | ||
var cont = jc[0].assignment ? jc[0].assignment.length : 0; | ||
jc.sort(function (a, b) { | ||
let cont = jc[0].assignment ? jc[0].assignment.length : 0; | ||
jc.sort(function(a, b) { | ||
return b.coupling - a.coupling; | ||
}); | ||
for (var i = 0; i < jc.length - 1; i++) { | ||
for (let i = 0; i < jc.length - 1; i++) { | ||
if (Math.abs(jc[i].coupling - jc[i + 1].coupling) < tolerance) { | ||
@@ -167,2 +163,7 @@ cont += jc[i + 1].assignment ? jc[i + 1].assignment.length : 1; | ||
return pattern; | ||
} | ||
} | ||
exports.compilePattern = compilePattern; | ||
exports.group = group; | ||
exports.joinCoupling = joinCoupling; | ||
exports.nmrJ = nmrJ; |
{ | ||
"name": "spectra-nmr-utilities", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "spectra NMR utilities", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
# spectra-nmr-utilities |
@@ -1,6 +0,5 @@ | ||
const patterns = ['s', 'd', 't', 'q', 'quint', 'h', 'sept', 'o', 'n']; | ||
function nmrJ(Js, options = {}) { | ||
var jString = ''; | ||
export function nmrJ(Js, options = {}) { | ||
let jString = ''; | ||
options = Object.assign({}, { separator: ', ', nbDecimal: 2 }, options); | ||
@@ -18,11 +17,11 @@ let j, i; | ||
function joinCoupling(signal, tolerance = 0.05) { | ||
var jc = signal.j; | ||
export function joinCoupling(signal, tolerance = 0.05) { | ||
let jc = signal.j; | ||
if (jc && jc.length > 0) { | ||
var cont = jc[0].assignment ? jc[0].assignment.length : 1; | ||
let cont = jc[0].assignment ? jc[0].assignment.length : 1; | ||
var pattern = ''; | ||
var newNmrJs = []; | ||
var diaIDs = []; | ||
var atoms = []; | ||
jc.sort(function (a, b) { | ||
let newNmrJs = []; | ||
let diaIDs = []; | ||
let atoms = []; | ||
jc.sort(function(a, b) { | ||
return b.coupling - a.coupling; | ||
@@ -44,3 +43,3 @@ }); | ||
coupling: Math.abs(jc[i].coupling), | ||
multiplicity: patterns[cont] | ||
multiplicity: patterns[cont], | ||
}; | ||
@@ -66,3 +65,3 @@ if (diaIDs.length > 0) { | ||
coupling: Math.abs(jc[i].coupling), | ||
multiplicity: patterns[cont] | ||
multiplicity: patterns[cont], | ||
}; | ||
@@ -87,4 +86,4 @@ if (diaIDs.length > 0) { | ||
function group(signals, options = {}) { | ||
var i, k; | ||
export function group(signals, options = {}) { | ||
let i, k; | ||
for (i = 0; i < signals.length; i++) { | ||
@@ -94,6 +93,8 @@ var j = signals[i].j; | ||
for (k = j.length - 2; k >= 0; k--) { | ||
for (var m = j.length - 1; m > k; m--) { | ||
if (j[k].diaID === j[m].diaID && | ||
for (let m = j.length - 1; m > k; m--) { | ||
if ( | ||
j[k].diaID === j[m].diaID && | ||
j[k].coupling === j[m].coupling && | ||
j[k].distance === j[m].distance) { | ||
j[k].distance === j[m].distance | ||
) { | ||
j[k].assignment = j[k].assignment.concat(j[m].assignment); | ||
@@ -126,5 +127,3 @@ j.splice(m, 1); | ||
} | ||
// signals[i].multiplicity = module.exports.compilePattern(signals[i], options.tolerance); | ||
} | ||
// console.log(signals[i]); | ||
signals[i].multiplicity = compilePattern(signals[i], options.tolerance); | ||
@@ -135,11 +134,11 @@ } | ||
function compilePattern(signal, tolerance = 0.05) { | ||
var jc = signal.j; | ||
var pattern = ''; | ||
export function compilePattern(signal, tolerance = 0.05) { | ||
let jc = signal.j; | ||
let pattern = ''; | ||
if (jc && jc.length > 0) { | ||
var cont = jc[0].assignment ? jc[0].assignment.length : 0; | ||
jc.sort(function (a, b) { | ||
let cont = jc[0].assignment ? jc[0].assignment.length : 0; | ||
jc.sort(function(a, b) { | ||
return b.coupling - a.coupling; | ||
}); | ||
for (var i = 0; i < jc.length - 1; i++) { | ||
for (let i = 0; i < jc.length - 1; i++) { | ||
if (Math.abs(jc[i].coupling - jc[i + 1].coupling) < tolerance) { | ||
@@ -160,3 +159,1 @@ cont += jc[i + 1].assignment ? jc[i + 1].assignment.length : 1; | ||
} | ||
module.exports = {compilePattern, group, joinCoupling, nmrJ}; |
Sorry, the diff of this file is not supported yet
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
10551
294