Search in sources :

Example 1 with Weights

use of net.sf.mzmine.util.scans.similarity.Weights in project mzmine2 by mzmine.

the class CompositeCosineSpectralSimilarity method getSimilarity.

/**
 * Returns mass and intensity values detected in given scan
 */
@Override
public SpectralSimilarity getSimilarity(ParameterSet parameters, MZTolerance mzTol, int minMatch, DataPoint[] library, DataPoint[] query) {
    Weights weights = parameters.getParameter(CompositeCosineSpectralSimilarityParameters.weight).getValue();
    double minCos = parameters.getParameter(CompositeCosineSpectralSimilarityParameters.minCosine).getValue();
    boolean removeUnmatched = parameters.getParameter(CompositeCosineSpectralSimilarityParameters.removeUnmatched).getValue();
    // align
    List<DataPoint[]> aligned = alignDataPoints(mzTol, library, query);
    // removes all signals which were not found in both masslists
    if (removeUnmatched)
        aligned = removeUnaligned(aligned);
    int queryN = query.length;
    int overlap = calcOverlap(aligned);
    if (overlap >= minMatch) {
        // relative factor ranges from 0-1
        double relativeFactor = calcRelativeNeighbourFactor(aligned);
        // weighted cosine
        double[][] diffArray = ScanAlignment.toIntensityMatrixWeighted(aligned, weights.getIntensity(), weights.getMz());
        double diffCosine = Similarity.COSINE.calc(diffArray);
        // composite dot product identity score
        // NIST search similar
        double composite = (queryN * diffCosine + overlap * relativeFactor) / (queryN + overlap);
        if (composite >= minCos)
            return new SpectralSimilarity(getName(), composite, overlap, library, query, aligned);
        else
            return null;
    }
    return null;
}
Also used : Weights(net.sf.mzmine.util.scans.similarity.Weights) SpectralSimilarity(net.sf.mzmine.util.scans.similarity.SpectralSimilarity) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 2 with Weights

use of net.sf.mzmine.util.scans.similarity.Weights in project mzmine2 by mzmine.

the class WeightedCosineSpectralSimilarity method getSimilarity.

/**
 * Returns mass and intensity values detected in given scan
 */
@Override
public SpectralSimilarity getSimilarity(ParameterSet parameters, MZTolerance mzTol, int minMatch, DataPoint[] library, DataPoint[] query) {
    Weights weights = parameters.getParameter(WeightedCosineSpectralSimilarityParameters.weight).getValue();
    double minCos = parameters.getParameter(WeightedCosineSpectralSimilarityParameters.minCosine).getValue();
    boolean removeUnmatched = parameters.getParameter(WeightedCosineSpectralSimilarityParameters.removeUnmatched).getValue();
    // align
    List<DataPoint[]> aligned = alignDataPoints(mzTol, library, query);
    // removes all signals which were not found in both masslists
    if (removeUnmatched)
        aligned = removeUnaligned(aligned);
    // overlapping within mass tolerance
    int overlap = calcOverlap(aligned);
    if (overlap >= minMatch) {
        // weighted cosine
        double[][] diffArray = ScanAlignment.toIntensityMatrixWeighted(aligned, weights.getIntensity(), weights.getMz());
        double diffCosine = Similarity.COSINE.calc(diffArray);
        if (diffCosine >= minCos)
            return new SpectralSimilarity(getName(), diffCosine, overlap, library, query, aligned);
        else
            return null;
    }
    return null;
}
Also used : Weights(net.sf.mzmine.util.scans.similarity.Weights) SpectralSimilarity(net.sf.mzmine.util.scans.similarity.SpectralSimilarity) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Aggregations

DataPoint (net.sf.mzmine.datamodel.DataPoint)2 SpectralSimilarity (net.sf.mzmine.util.scans.similarity.SpectralSimilarity)2 Weights (net.sf.mzmine.util.scans.similarity.Weights)2