use of net.sf.mzmine.modules.visualization.mzhistogram.chart.EHistogramDialog in project mzmine2 by mzmine.
the class MZDistributionHistoTask method run.
/**
* @see Runnable#run()
*/
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Starting to build mz distribution histogram for " + dataFile);
// all selected scans
scans = scanSelection.getMatchingScans(dataFile);
totalScans = scans.length;
// histo data
DoubleArrayList data = new DoubleArrayList();
for (Scan scan : scans) {
if (isCanceled())
return;
// retention time in range
if (!useRTRange || rtRange.contains(scan.getRetentionTime())) {
// go through all mass lists
MassList massList = scan.getMassList(massListName);
if (massList == null) {
setStatus(TaskStatus.ERROR);
setErrorMessage("Scan " + dataFile + " #" + scan.getScanNumber() + " does not have a mass list " + massListName);
return;
}
DataPoint[] mzValues = massList.getDataPoints();
// insert all mz in order and count them
Arrays.stream(mzValues).mapToDouble(dp -> dp.getMZ()).filter(mz -> mzRange.contains(mz)).forEach(mz -> data.add(mz));
processedScans++;
}
}
if (!data.isEmpty()) {
// to array
double[] histo = new double[data.size()];
for (int i = 0; i < data.size(); i++) histo[i] = data.get(i);
// create histogram dialog
EHistogramDialog dialog = new EHistogramDialog("m/z distribution", "m/z", new HistogramData(histo), binWidth);
dialog.setVisible(true);
} else {
throw new MSDKRuntimeException("Data was empty. Review your selected filters.");
}
setStatus(TaskStatus.FINISHED);
logger.info("Finished mz distribution histogram on " + dataFile);
}
Aggregations