cheminfo-js / nmr-predictor

NMR chemical shift predictor
MIT License
0 stars 2 forks source link

API #3

Closed andcastillo closed 7 years ago

andcastillo commented 7 years ago
// what should un predictor now ???
// nucleus, frequency, from, to ?
// url 13C, url 1H, url spinus

// do we need to create an instance ???
// I guess yes, because in that way we can re-use the instance for many simulations.

// options = {atomLabel: ["C", "H"]} ? based on the name of the method we could guess the atomLabel

// if from smiles
var molfile = OCL.Molecule.fromSmiles('CCCC').toMolfile();

var prediction1H=Predictor.spinus(molfile, options); // returns a Promise
var prediction1H=Predictor.proton(molfile, options); // returns a Promise
var prediction13C=Predictor.carbon(molfile, options); // returns a Promise

// options2D = {fromLabel: "H", toLabel: "H", minLength: 1, maxLength: 3}
Predictor.twoD(prediction1H, prediction13C, molfile, options2D); //This will need the paths in the molecule. Should be a parameter? Where is the ref to the mol?

// because the 2D may have different kind of 1D (spinus or your hose code) maybe it would make sense to calculate them first separately
// so the code for a hsqc would be

var predictions = await Promise.all([Predictor.spinus(molfile), Predictor.carbon(molfile)]);   // await can currently only be used in the visualizer
var options2D = {fromLabel: "H", toLabel: "C", minLength: 1, maxLength: 3}; //Ok
var hmbc = await Predictor.twoD(predictions[0], predictions[1], molfile, options2D); //Ok
// we should think about converting this hmbc to annotations
var jcamp or annotations = Simulator.xxx(hmbc, options); //Ok We should use the same stragegy here I guess then ?

SD2D.fromPrediction of fromMolfile  ??

// to have a 1D
var prediction1H=await Predictor.spinus(molfile, options);

var jcamp=await Simulator.jcamp(prediction1H, options); //This should be SD.fromPrediction?? or SD.fromMolfile as discused? and then sd.toJcamp()  // ok perfect
                                                                                                                // need to think about a similar approach for the 2D but I don't know how far is SD2 ?
                                                        // I need to create the simulator2D that will give a sd object 
                                                        // you have any special SD object for 2D ?
                                                        // It is the same. The toJcamp should work if the sd is correctly defined.
                                                        // I mean, there is currently NMR1D and NMR2D in SD package. If I load a 2D I can re-export to jcamp
                                                        // ok looks good to me. 
                                                        // for the hose data file you can put it in github but we will have to move it soon beause github limits file to 20Mb I think
var annotations=await Simulator.annotations(prediction1H, options);

Simulation is indeed another package ! // options = from, to, frequency, <= This is really for the simulation

var predictor = new Predictor('spinus', options);
predictor.predict(molfile);

var predictor = new Predictor('1h', {url:'url to json hose code file'});
predictor.predict(molfile);

var predictor = new Predictor('13c', {url:'url to json hose code file'});
predictor.predict(molfile);

//How it works now
//For 1D
var predictor = new lib.NmrPredictor1D("spinus");
predictor.predict(molfile).then(prediction => {...

//For 2D
var predictor = new lib.NmrPredictor2D(hoseDB);
predictor.predict(molfile, {fromLabel: "H", toLabel: "H", minLength: 1, maxLength: 3}).then(prediction => {...