Handling large JSON files with experimental and predicted mass spectra. Computing similarity between an experiment and a predicted spectrum and finding best match.
$ npm i dereplication
The code underneath allows you to have a lot of information about the similarity results between experiments and predictions. To see the debug information, use this command:
DEBUG=testSimilarity node --max-old-space-size=8192 -r esm index.js
The --max-old-space-size=8192
option has to be used because Node.js cannot handle files this large otherwise.
The code underneath should be the contents of index.js
.
import { similarity as Similarity } from 'ml-distance';
import computeSimilarities from './computeSimilarities';
const intersection = Similarity.intersection;
const experimental = './data/matchingExperiments.json';
const predicted = './data/predictions.json';
computeSimilarities(experimental, predicted, {
numExperiments: undefined,
bestMatch: {
massFilter: 0.05,
},
loadData: {
numberMaxPeaks: undefined,
mergeSpan: 0.05,
norm: true,
},
similarity: {
alignDelta: 0.05,
algorithm: intersection,
norm: false,
},
});
CLick on this link to access the API documentation.