use of net.sf.mzmine.util.scans.similarity.SpectralSimilarity 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;
}
Aggregations