Skip to content

josoriom/direct-manager

Repository files navigation

direct-manager

NPM version build status Test coverage npm download

Installation

$ npm i direct-manager

Usage

import direct from 'ml-direct';
import DirectManager from 'direct-manager';
import SD from 'spectra-data';

// The prediction should be obtained with SPINUS.
const directManager = new DirectManager(prediction);
const boundaries = directManager.getBoundaries();
const buildPredictionFile = directManager.tidyUpParameters();

const spectraProperties = {
  frequency: 400,
  from: 0,
  to: 10,
  lineWidth: 3,
  nbPoints: 4096,
  maxClusterSize: 8,
  output: 'xy',
};

const predicted = direct(
  objectiveFunction,
  boundaries.lower,
  boundaries.upper,
  { iterations: 10 },
);

// target: Experimental spectrum.
function objectiveFunction(parameters) {
  const testSignals = buildPredictionFile(parameters);
  const simulation = SD.NMR.fromSignals(testSignals, spectraProperties);
  simulation.setMinMax(0, 1);
  const simulated = simulation.getYData();
  let result = 0;
  for (let i = 0; i < target.length; i++) {
    result += (target[i] - simulated[i]) ** 2;
  }
  return result;
}

Cheminfo tools

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published