nmr-simulation
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "nmr-simulation", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Simulate NMR spectra from spin systems", | ||
@@ -53,3 +53,3 @@ "main": "src/index.js", | ||
"babili": "0.0.8", | ||
"cheminfo-tools": "^1.3.4", | ||
"cheminfo-tools": "^1.11.0", | ||
"eslint": "^3.9.1", | ||
@@ -61,4 +61,4 @@ "eslint-config-cheminfo": "^1.5.2", | ||
"should": "^11.1.1", | ||
"nmr-predictor": "0.2.3" | ||
"nmr-predictor": "0.5.2" | ||
} | ||
} |
@@ -33,3 +33,3 @@ 'use strict'; | ||
const predictor = new NmrPredictor('spinus'); | ||
predictor.predict(molfile, {group: false}).then(prediction => { | ||
predictor.spinus(molfile, {group: true}).then(prediction => { | ||
@@ -36,0 +36,0 @@ const spinSystem = nmr.SpinSystem.fromPrediction(prediction); |
@@ -55,3 +55,3 @@ 'use strict'; | ||
const intensities = []; | ||
if (cluster.length>maxClusterSize) { | ||
if (cluster.length > maxClusterSize) { | ||
//This is a single spin, but the cluster exceeds the maxClusterSize criteria | ||
@@ -67,3 +67,3 @@ //we use the simple multiplicity algorithm | ||
if (cluster[i] < 0) { | ||
jc = spinSystem.couplingConstants[index][clusterFake[i]]; | ||
jc = spinSystem.couplingConstants[index][clusterFake[i]] / 2; | ||
currentSize = frequencies.length; | ||
@@ -280,3 +280,3 @@ for ( j=0 ; j < currentSize; j++) { | ||
clusterHam.add(kron1.mul(couplingConstants[n][k])); | ||
clusterHam.add(kron1.mul(couplingConstants[n][k] / 2)); | ||
} | ||
@@ -283,0 +283,0 @@ } |
@@ -38,3 +38,3 @@ 'use strict'; | ||
var idx = ids[withID]; | ||
jc[i][idx] = +tokens[6 + 3 * j]/2; | ||
jc[i][idx] = +tokens[6 + 3 * j]; | ||
} | ||
@@ -51,4 +51,5 @@ } | ||
static fromPrediction(result) { | ||
const nSpins = result.length; | ||
static fromPrediction(input) { | ||
let predictions = SpinSystem._ungroupAtoms(input); | ||
const nSpins = predictions.length; | ||
const cs = new Array(nSpins); | ||
@@ -60,14 +61,14 @@ const jc = Matrix.zeros(nSpins, nSpins); | ||
for(i=0;i<nSpins;i++) { | ||
cs[i] = result[i].delta; | ||
ids[result[i].atomIDs[0]] = i; | ||
cs[i] = predictions[i].delta; | ||
ids[predictions[i].atomIDs[0]] = i; | ||
} | ||
for( i = 0; i < nSpins; i++) { | ||
cs[i] = result[i].delta; | ||
j = result[i].j; | ||
cs[i] = predictions[i].delta; | ||
j = predictions[i].j; | ||
for( k = 0; k < j.length; k++) { | ||
//console.log(ids[result[i].atomIDs[0]],ids[j[k].assignment]); | ||
jc[ids[result[i].atomIDs[0]]][ids[j[k].assignment]] = j[k].coupling; | ||
jc[ids[j[k].assignment]][ids[result[i].atomIDs[0]]] = j[k].coupling; | ||
jc[ids[predictions[i].atomIDs[0]]][ids[j[k].assignment]] = j[k].coupling; | ||
jc[ids[j[k].assignment]][ids[predictions[i].atomIDs[0]]] = j[k].coupling; | ||
} | ||
multiplicity[i] = result[i].integral+1; | ||
multiplicity[i] = predictions[i].integral+1; | ||
} | ||
@@ -78,2 +79,19 @@ | ||
static _ungroupAtoms(prediction) { | ||
let result = []; | ||
prediction.forEach(pred => { | ||
let atomIDs = pred['atomIDs']; | ||
for(let i = 0; i < atomIDs.length; i++) { | ||
let tempPred = JSON.parse(JSON.stringify(pred)); | ||
tempPred.atomIDs = [atomIDs[i]]; | ||
tempPred.integral = 1; | ||
result.push(tempPred); | ||
} | ||
}); | ||
return result; | ||
} | ||
_initClusters() { | ||
@@ -80,0 +98,0 @@ this.clusters = simpleClustering(this.connectivity, {out:"indexes"}); |
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
26514
9
597