use of net.sf.mzmine.util.exceptions.MissingMassListException in project mzmine2 by mzmine.
the class SpectralMatchTask method addIdentities.
private void addIdentities(List<SpectralDBPeakIdentity> matches) {
for (SpectralDBPeakIdentity match : matches) {
try {
// TODO put into separate method and add comments
// get data points of matching scans
DataPoint[] spectraMassList = getDataPoints(currentScan);
List<DataPoint[]> alignedDataPoints = ScanAlignment.align(mzToleranceSpectra, match.getEntry().getDataPoints(), spectraMassList);
alignedSignals = ScanAlignment.removeUnaligned(alignedDataPoints);
// add new mass list to the spectra for match
DataPoint[] dataset = new DataPoint[alignedSignals.size()];
for (int i = 0; i < dataset.length; i++) {
dataset[i] = alignedSignals.get(i)[1];
}
String compoundName = match.getEntry().getField(DBEntryField.NAME).toString();
String shortName = compoundName;
// TODO remove or specify more - special naming format?
int start = compoundName.indexOf("[");
int end = compoundName.indexOf("]");
if (start != -1 && start + 1 < compoundName.length() && end != -1 && end < compoundName.length())
shortName = compoundName.substring(start + 1, end);
DataPointsDataSet detectedCompoundsDataset = new DataPointsDataSet(shortName + " " + "Score: " + COS_FORM.format(match.getSimilarity().getScore()), dataset);
spectraPlot.addDataSet(detectedCompoundsDataset, new Color((int) (Math.random() * 0x1000000)), true);
} catch (MissingMassListException e) {
logger.log(Level.WARNING, "No mass list for the selected spectrum", e);
errorCounter++;
}
}
resultWindow.addMatches(matches);
resultWindow.revalidate();
resultWindow.repaint();
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.util.exceptions.MissingMassListException in project mzmine2 by mzmine.
the class SingleRowIdentificationTask method buildMSDKSpectrum.
/**
* Construct MsSpectrum object from DataPoint array
*
* @param points MZ/Intensity pairs
* @return new MsSpectrum
*/
private MsSpectrum buildMSDKSpectrum(Scan scan, String massListName) throws MissingMassListException {
MassList ml = scan.getMassList(massListName);
if (ml == null)
throw new MissingMassListException("Scan #" + scan.getScanNumber() + " does not have mass list", massListName);
DataPoint[] points = ml.getDataPoints();
SimpleMsSpectrum spectrum = new SimpleMsSpectrum();
double[] mz = new double[points.length];
float[] intensity = new float[points.length];
for (int i = 0; i < points.length; i++) {
mz[i] = points[i].getMZ();
intensity[i] = (float) points[i].getIntensity();
}
DataPointSorter.sortDataPoints(mz, intensity, points.length, SortingProperty.MZ, SortingDirection.ASCENDING);
spectrum.setDataPoints(mz, intensity, points.length);
return spectrum;
}
use of net.sf.mzmine.util.exceptions.MissingMassListException in project mzmine2 by mzmine.
the class ScanSorter method compare.
@Override
public int compare(Scan a, Scan b) {
MassList ma = ScanUtils.getMassListOrFirst(a, massListName);
MassList mb = ScanUtils.getMassListOrFirst(b, massListName);
if (ma == null || mb == null)
throw new RuntimeException(new MissingMassListException(massListName));
return comp.compare(ma.getDataPoints(), mb.getDataPoints());
}
Aggregations