nmr-predictor
Advanced tools
Comparing version 0.4.0 to 0.5.1
{ | ||
"name": "nmr-predictor", | ||
"version": "0.4.0", | ||
"version": "0.5.1", | ||
"description": "NMR chemical shift predictor", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -46,3 +46,3 @@ 'use strict'; | ||
describe('URL JSON 13C prediction', function () { | ||
this.timeout(20000); | ||
this.timeout(10000); | ||
it('13C chemical shift prediction expanded', function (done) { | ||
@@ -61,2 +61,10 @@ fetch('https://raw.githubusercontent.com/cheminfo-js/nmr-predictor/master/data/nmrshiftdb2.json', { | ||
}); | ||
it('13C chemical shift prediction grouped', function (done) { | ||
var predictor = new NmrPredictor(); | ||
predictor.carbon(molfile, {group:false}).then(prediction => { | ||
prediction.length.should.eql(8); | ||
done(); | ||
}).catch(reason => {return new Error(reason)}); | ||
}); | ||
}); |
@@ -48,3 +48,2 @@ const Predictor = require('../index.js'); | ||
var predictor = new Predictor('spinus'); | ||
debugger; | ||
predictor.spinus(molfile).then(prediction => { | ||
@@ -51,0 +50,0 @@ //var a = simule2DNmrSpectrum(prediction, {nbPointsX: 100, nbPointsY: 100}); |
@@ -50,12 +50,20 @@ 'use strict' | ||
proton(molfile, options) { | ||
let result = this.protonSync(molfile, options); | ||
return new Promise(function(resolve, reject){ | ||
resolve(result); | ||
}); | ||
if(!this.db) | ||
this.db = {}; | ||
if(!this.db['H']) { | ||
return fetch('https://raw.githubusercontent.com/cheminfo-js/nmr-predictor/master/data/h1.json', {timeout: 5000}) | ||
.then(value => {return value.text()}).then(body => { | ||
this.db['H'] = JSON.parse(body); | ||
return this.protonSync(molfile, options); | ||
}); | ||
} else { | ||
let result = this.protonSync(molfile, options); | ||
return new Promise(function(resolve, reject){ | ||
resolve(result); | ||
}); | ||
} | ||
} | ||
carbonSync(molfile, options) { | ||
if(!this.db) { | ||
this.db = {"C": fetchDB("C")}; | ||
} | ||
var mol = molfile; | ||
@@ -72,6 +80,19 @@ if(typeof molfile === 'string') { | ||
carbon(molfile, options) { | ||
let result = this.carbonSync(molfile, options); | ||
return new Promise(function(resolve, reject){ | ||
resolve(result); | ||
}); | ||
if(!this.db) | ||
this.db = {}; | ||
if(!this.db['C']) { | ||
return fetch('https://raw.githubusercontent.com/cheminfo-js/nmr-predictor/master/data/nmrshiftdb2.json', | ||
{timeout: 20000}) | ||
.then(value => {return value.text()}).then(body => { | ||
this.db['C'] = JSON.parse(body); | ||
return this.carbonSync(molfile, options); | ||
}); | ||
} else { | ||
let result = this.carbonSync(molfile, options); | ||
return new Promise(function(resolve, reject){ | ||
resolve(result); | ||
}); | ||
} | ||
} | ||
@@ -386,3 +407,3 @@ | ||
var idx = ids[withID]; | ||
jc[i][idx] = (+tokens[6 + 3 * j]) / 2; | ||
jc[i][idx] = (+tokens[6 + 3 * j]); | ||
} | ||
@@ -389,0 +410,0 @@ } |
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
33695
710
5