Search in sources :

Example 81 with DataPoint

use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.

the class RecursiveMassDetector method getMassValues.

public DataPoint[] getMassValues(DataPoint[] dataPoints, ParameterSet parameters) {
    double noiseLevel = parameters.getParameter(RecursiveMassDetectorParameters.noiseLevel).getValue();
    double minimumMZPeakWidth = parameters.getParameter(RecursiveMassDetectorParameters.minimumMZPeakWidth).getValue();
    double maximumMZPeakWidth = parameters.getParameter(RecursiveMassDetectorParameters.maximumMZPeakWidth).getValue();
    TreeSet<DataPoint> mzPeaks = new TreeSet<DataPoint>(new DataPointSorter(SortingProperty.MZ, SortingDirection.Ascending));
    // Find MzPeaks
    recursiveThreshold(mzPeaks, dataPoints, 1, dataPoints.length - 1, noiseLevel, minimumMZPeakWidth, maximumMZPeakWidth, 0);
    return mzPeaks.toArray(new DataPoint[0]);
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) TreeSet(java.util.TreeSet) DataPointSorter(net.sf.mzmine.util.DataPointSorter)

Example 82 with DataPoint

use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.

the class WaveletMassDetector method performCWT.

/**
 * Perform the CWT over raw data points in the selected scale level
 *
 * @param dataPoints
 */
private SimpleDataPoint[] performCWT(DataPoint[] dataPoints, double waveletWindow, int scaleLevel) {
    int length = dataPoints.length;
    SimpleDataPoint[] cwtDataPoints = new SimpleDataPoint[length];
    double wstep = ((WAVELET_ESR - WAVELET_ESL) / NPOINTS);
    double[] W = new double[(int) NPOINTS];
    double waveletIndex = WAVELET_ESL;
    for (int j = 0; j < NPOINTS; j++) {
        // Pre calculate the values of the wavelet
        W[j] = cwtMEXHATreal(waveletIndex, waveletWindow, 0.0);
        waveletIndex += wstep;
    }
    /*
     * We only perform Translation of the wavelet in the selected scale
     */
    int d = (int) NPOINTS / (WAVELET_ESR - WAVELET_ESL);
    int a_esl = scaleLevel * WAVELET_ESL;
    int a_esr = scaleLevel * WAVELET_ESR;
    double sqrtScaleLevel = Math.sqrt(scaleLevel);
    for (int dx = 0; dx < length; dx++) {
        /* Compute wavelet boundaries */
        int t1 = a_esl + dx;
        if (t1 < 0)
            t1 = 0;
        int t2 = a_esr + dx;
        if (t2 >= length)
            t2 = (length - 1);
        /* Perform convolution */
        double intensity = 0.0;
        for (int i = t1; i <= t2; i++) {
            int ind = (int) (NPOINTS / 2) - (((int) d * (i - dx) / scaleLevel) * (-1));
            if (ind < 0)
                ind = 0;
            if (ind >= NPOINTS)
                ind = (int) NPOINTS - 1;
            intensity += dataPoints[i].getIntensity() * W[ind];
        }
        intensity /= sqrtScaleLevel;
        // Eliminate the negative part of the wavelet map
        if (intensity < 0)
            intensity = 0;
        cwtDataPoints[dx] = new SimpleDataPoint(dataPoints[dx].getMZ(), (double) intensity);
    }
    return cwtDataPoints;
}
Also used : SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 83 with DataPoint

use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.

the class MergedDataPoint method getComment.

/**
 * @return a description of the merged peak
 */
public String getComment() {
    double smallest = Double.POSITIVE_INFINITY, largest = Double.NEGATIVE_INFINITY, average = 0d;
    int apex = 0;
    for (int k = 0; k < sources.length; ++k) {
        final DataPoint p = sources[k];
        smallest = Math.min(smallest, p.getMZ());
        largest = Math.max(largest, p.getMZ());
        average += Math.abs(p.getMZ() - mz);
        if (p.getIntensity() > sources[apex].getIntensity())
            apex = k;
    }
    average /= sources.length;
    // median
    final DataPoint[] copy = sources.clone();
    ScanUtils.sortDataPointsByMz(copy);
    double medianMz = copy[copy.length / 2].getMZ();
    if (copy.length > 1 && copy.length % 2 == 0)
        medianMz = (medianMz + copy[(copy.length) / 2 - 1].getMZ()) / 2d;
    return String.format(Locale.US, "%.5f ... %.5f  (median = %.5f, apex = %.5f). Standard deviation = %.5f. Peaks: %d", smallest, largest, medianMz, sources[apex].getMZ(), average, sources.length);
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 84 with DataPoint

use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.

the class GnpsFbmnExportTask method export.

private void export(PeakList peakList, FileWriter writer, File curFile) throws IOException {
    final String newLine = System.lineSeparator();
    for (PeakListRow row : peakList.getRows()) {
        String rowID = Integer.toString(row.getID());
        String retTimeInSeconds = Double.toString(Math.round(row.getAverageRT() * 60 * 100) / 100.);
        // Get the MS/MS scan number
        Feature bestPeak = row.getBestPeak();
        if (bestPeak == null)
            continue;
        int msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
        if (rowID != null) {
            PeakListRow copyRow = copyPeakRow(row);
            // Best peak always exists, because feature list row has at least one peak
            bestPeak = copyRow.getBestPeak();
            // Get the MS/MS scan number
            msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
            while (msmsScanNumber < 1) {
                copyRow.removePeak(bestPeak.getDataFile());
                if (copyRow.getPeaks().length == 0)
                    break;
                bestPeak = copyRow.getBestPeak();
                msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
            }
        }
        if (msmsScanNumber >= 1) {
            // MS/MS scan must exist, because msmsScanNumber was > 0
            Scan msmsScan = bestPeak.getDataFile().getScan(msmsScanNumber);
            MassList massList = msmsScan.getMassList(massListName);
            if (massList == null) {
                MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "There is no mass list called " + massListName + " for MS/MS scan #" + msmsScanNumber + " (" + bestPeak.getDataFile() + ")");
                return;
            }
            writer.write("BEGIN IONS" + newLine);
            if (rowID != null)
                writer.write("FEATURE_ID=" + rowID + newLine);
            String mass = Double.toString(Math.round(row.getAverageMZ() * 10000) / 10000.);
            if (mass != null)
                writer.write("PEPMASS=" + mass + newLine);
            if (rowID != null) {
                writer.write("SCANS=" + rowID + newLine);
                writer.write("RTINSECONDS=" + retTimeInSeconds + newLine);
            }
            int msmsCharge = msmsScan.getPrecursorCharge();
            String msmsPolarity = msmsScan.getPolarity().asSingleChar();
            if (msmsPolarity.equals("0"))
                msmsPolarity = "";
            if (msmsCharge == 0) {
                msmsCharge = 1;
                msmsPolarity = "";
            }
            writer.write("CHARGE=" + msmsCharge + msmsPolarity + newLine);
            writer.write("MSLEVEL=2" + newLine);
            DataPoint[] dataPoints = massList.getDataPoints();
            if (mergeParameters != null) {
                MsMsSpectraMergeModule merger = MZmineCore.getModuleInstance(MsMsSpectraMergeModule.class);
                MergedSpectrum spectrum = merger.getBestMergedSpectrum(mergeParameters, row, massListName);
                if (spectrum != null) {
                    dataPoints = spectrum.data;
                    writer.write("MERGED_STATS=");
                    writer.write(spectrum.getMergeStatsDescription());
                    writer.write(newLine);
                }
            }
            for (DataPoint peak : dataPoints) {
                writer.write(peak.getMZ() + " " + peak.getIntensity() + newLine);
            }
            writer.write("END IONS" + newLine);
            writer.write(newLine);
        }
    }
}
Also used : SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) DataPoint(net.sf.mzmine.datamodel.DataPoint) MsMsSpectraMergeModule(net.sf.mzmine.modules.tools.msmsspectramerge.MsMsSpectraMergeModule) MergedSpectrum(net.sf.mzmine.modules.tools.msmsspectramerge.MergedSpectrum) Scan(net.sf.mzmine.datamodel.Scan) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature) Feature(net.sf.mzmine.datamodel.Feature) DataPoint(net.sf.mzmine.datamodel.DataPoint) MassList(net.sf.mzmine.datamodel.MassList)

Example 85 with DataPoint

use of net.sf.mzmine.datamodel.DataPoint in project mzmine2 by mzmine.

the class RowsSpectralMatchTask method getDataPoints.

/**
 * Thresholded masslist
 *
 * @param row
 * @return
 * @throws MissingMassListException
 */
private DataPoint[] getDataPoints(Scan scan, boolean noiseFilter) throws MissingMassListException {
    if (scan == null || scan.getMassList(massListName) == null) {
        return new DataPoint[0];
    }
    MassList masses = scan.getMassList(massListName);
    DataPoint[] dps = masses.getDataPoints();
    return noiseFilter ? ScanUtils.getFiltered(dps, noiseLevel) : dps;
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) MassList(net.sf.mzmine.datamodel.MassList)

Aggregations

DataPoint (net.sf.mzmine.datamodel.DataPoint)214 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)98 Scan (net.sf.mzmine.datamodel.Scan)64 ArrayList (java.util.ArrayList)50 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)44 Feature (net.sf.mzmine.datamodel.Feature)27 MassList (net.sf.mzmine.datamodel.MassList)24 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)22 IOException (java.io.IOException)20 SimpleScan (net.sf.mzmine.datamodel.impl.SimpleScan)18 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)17 SimpleIsotopePattern (net.sf.mzmine.datamodel.impl.SimpleIsotopePattern)16 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)15 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)15 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)12 DataPointSorter (net.sf.mzmine.util.DataPointSorter)12 HashMap (java.util.HashMap)10 Vector (java.util.Vector)10 Range (com.google.common.collect.Range)8 TreeMap (java.util.TreeMap)8