Search in sources :

Example 6 with MissingMassListException

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);
}
Also used : SpectralDBPeakIdentity(net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity) DataPoint(net.sf.mzmine.datamodel.DataPoint) Color(java.awt.Color) DataPoint(net.sf.mzmine.datamodel.DataPoint) DataPointsDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet) MissingMassListException(net.sf.mzmine.util.exceptions.MissingMassListException)

Example 7 with MissingMassListException

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;
}
Also used : SimpleMsSpectrum(io.github.msdk.datamodel.SimpleMsSpectrum) DataPoint(net.sf.mzmine.datamodel.DataPoint) MassList(net.sf.mzmine.datamodel.MassList) MissingMassListException(net.sf.mzmine.util.exceptions.MissingMassListException) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 8 with MissingMassListException

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());
}
Also used : MassList(net.sf.mzmine.datamodel.MassList) MissingMassListException(net.sf.mzmine.util.exceptions.MissingMassListException)

Aggregations

MissingMassListException (net.sf.mzmine.util.exceptions.MissingMassListException)8 DataPoint (net.sf.mzmine.datamodel.DataPoint)5 ArrayList (java.util.ArrayList)4 MassList (net.sf.mzmine.datamodel.MassList)4 Scan (net.sf.mzmine.datamodel.Scan)4 SpectralDBPeakIdentity (net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity)3 FormulaConstraints (de.unijena.bioinf.ChemistryBase.chem.FormulaConstraints)2 Ms2Experiment (de.unijena.bioinf.ChemistryBase.ms.Ms2Experiment)2 IonAnnotation (io.github.msdk.datamodel.IonAnnotation)2 IonType (io.github.msdk.datamodel.IonType)2 MsSpectrum (io.github.msdk.datamodel.MsSpectrum)2 SimpleMsSpectrum (io.github.msdk.datamodel.SimpleMsSpectrum)2 SiriusIdentificationMethod (io.github.msdk.id.sirius.SiriusIdentificationMethod)2 SiriusIonAnnotation (io.github.msdk.id.sirius.SiriusIonAnnotation)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 SpectralSimilarity (net.sf.mzmine.util.scans.similarity.SpectralSimilarity)2 SpectralDBEntry (net.sf.mzmine.util.spectraldb.entry.SpectralDBEntry)2