Search in sources :

Example 1 with SimpleMsSpectrum

use of io.github.msdk.datamodel.SimpleMsSpectrum 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)

Aggregations

SimpleMsSpectrum (io.github.msdk.datamodel.SimpleMsSpectrum)1 DataPoint (net.sf.mzmine.datamodel.DataPoint)1 MassList (net.sf.mzmine.datamodel.MassList)1 MissingMassListException (net.sf.mzmine.util.exceptions.MissingMassListException)1