peaks-similarity
TypeScript icon, indicating that this package has built-in type declarations

3.1.1 • Public • Published

peaks-similarity

NPM version [![build status][travis-image]][travis-url] [![David deps][david-image]][david-url] npm download

Peaks similarity - calculate a similarity between 0 and 1 of 2 arrays of [x,y] points.

Description

The idea is to calculate a similarity value between 0 and 1 between two arrays of peaks ([x,y] points).

const peaks1 = [
  [1, 1],
  [2, 2],
];
const peaks2 = [
  [1, 2],
  [2, 1],
];

import Comparator from 'peaks-similarity';
const comparator = new Comparator({ widthBottom: 4, widthTop: 2 });
const result = comparator.getSimilarity(peaks1, peaks2);

console.log(result);

options

  • widthBottom : bottom width of the trapezoid (default: 2)
  • widthTop : top width of the trapezoid (default: 1)
  • trapezoid : Should we use overlapping of trapezoids surface (default: false). If trapezoid is false it is based only on peaks and not surface.
  • common: Only take the common part of the array based on the widthBottom of the trapezoid (default: false)
    • true: take the common part between the 2 array
    • first: keep first array and take the common part of the second one
    • second: keep second array and take the common part of the first one

Methods

  • setOptions(newOptions)
  • setPeaks1(anArray)
  • setPeaks2(anArray)
  • getExtract1()
  • getExtract2()
  • getExtractInfo1()
  • getExtractInfo2()
  • setTrapezoid(newWidthBottom, newWidthTop)
  • setFromTo(newFrom, newTo)
  • getOverlap(x1, y1, x2, y2)
  • getOverlapTrapezoid(x1, y1, x2, y2)
  • calculateDiff()
  • checkArray(points)
  • getSimilarity(newPeaks1, newPeaks2)
  • fastSimilarity(newPeaks2, from, to)
    • newPeaks2 has to be normalized (sum to 1)
    • fastSimilarity will use the common parameter. This parameter may be 'second' and will take the peaks1 that are at a distance less than widthBottom of any peak of peaks2

License

MIT

Dependencies (1)

Dev Dependencies (9)

Package Sidebar

Install

npm i peaks-similarity

Weekly Downloads

511

Version

3.1.1

License

MIT

Unpacked Size

133 kB

Total Files

93

Last publish

Collaborators

  • targos
  • lpatiny
  • cheminfo-bot