peaks-similarity
Version:
Peaks similarity - calculate the similarity between 2 ordered arrays of peaks
144 lines • 4.09 kB
TypeScript
export const COMMON_NO: 0;
export const COMMON_FIRST: 1;
export const COMMON_SECOND: 2;
export const COMMON_BOTH: 3;
/**
* A number, or a string containing a number.
* @typedef {([number[],number[]]|[number,number][]|{x:number[],y:number[]})} Peaks
*/
/**
* Create a comparator class
* {object} [options={}]
* {string} [options.common=''] should we take only common peaks 'first', 'second', 'both', ''
* {number} [options.widthBottom=2] bottom trapezoid width for similarity evaluation
* {number} [options.widthTop=1] top trapezoid width for similarity evaluation
* {number} [options.from] from region used for similarity calculation
* {number} [options.to] to region used for similarity calculation
*/
export class Comparator {
constructor(options?: {});
array1: any[];
array2: any[];
setOptions(options?: {}): void;
common: number | undefined;
trapezoid: any;
commonFactor: any;
/**
*
* @param {Peaks} peaks
*/
setPeaks1(peaks: Peaks): void;
array1Extract: any;
array1ExtractInfo: {
sum: any;
min: any;
max: any;
} | undefined;
array2Extract: never[][] | Peaks | undefined;
array2ExtractInfo: {
sum: any;
min: any;
max: any;
} | undefined;
/**
*
* @param {Peaks} peaks
*/
setPeaks2(peaks: Peaks): void;
getExtract1(): any;
getExtract2(): never[][] | Peaks | undefined;
getExtractInfo1(): {
sum: any;
min: any;
max: any;
} | undefined;
getExtractInfo2(): {
sum: any;
min: any;
max: any;
} | undefined;
/**
* Set the new bottom and top width of the trapezoid
* @param {number} newWidthBottom
* @param {number} newWidthTop
*/
setTrapezoid(newWidthBottom: number, newWidthTop: number): void;
widthTop: number | undefined;
widthBottom: number | undefined;
widthSlope: number | undefined;
/**
* Set the from / to for comparison
* @param {number} newFrom - set the new from value
* @param {number} newTo - set the new to value
* @returns
*/
setFromTo(newFrom: number, newTo: number): void;
from: any;
to: number | undefined;
/**
*
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @returns
*/
getOverlap(x1: number, y1: number, x2: number, y2: number): number;
/**
* This is the old trapezoid similarity
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @param {number} widthTop
* @param {number} widthBottom
* @returns
*/
getOverlapTrapezoid(x1: number, y1: number, x2: number, y2: number, widthTop: number, widthBottom: number): number;
/**
* This method calculates the total diff. The sum of positive value will yield to overlap
* @returns
*/
calculateDiff(): any[];
/**
* Set the new peaks and return info
* @param {Peaks} newPeaks1
* @param {Peaks} newPeaks2
* @returns
*/
getSimilarity(newPeaks1: Peaks, newPeaks2: Peaks): {
diff: any[];
extract1: any;
extract2: never[][] | Peaks | undefined;
extractInfo1: {
sum: any;
min: any;
max: any;
} | undefined;
extractInfo2: {
sum: any;
min: any;
max: any;
} | undefined;
similarity: number;
widthBottom: number | undefined;
widthTop: number | undefined;
};
/**
* This works mainly when you have a array1 that is fixed
* newPeaks2 have to be normalized ! (sum to 1)
* @param {Peaks} newPeaks2
* @param {number} from
* @param {number} to
* @returns
*/
fastSimilarity(newPeaks2: Peaks, from: number, to: number): number;
}
/**
* A number, or a string containing a number.
*/
export type Peaks = ([number[], number[]] | [number, number][] | {
x: number[];
y: number[];
});
//# sourceMappingURL=index.d.ts.map