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;
}
Aggregations