Search in sources :

Example 26 with Feature

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

the class SammonsDataset method run.

@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    if (selectedRows.length == 0) {
        this.status = TaskStatus.ERROR;
        errorMessage = "No peaks selected for Sammons plot";
        return;
    }
    if (selectedRawDataFiles.length == 0) {
        this.status = TaskStatus.ERROR;
        errorMessage = "No raw data files selected for Sammons plot";
        return;
    }
    logger.info("Computing projection plot");
    // Generate matrix of raw data (input to Sammon's projection)
    boolean useArea = false;
    if (parameters.getParameter(ProjectionPlotParameters.peakMeasurementType).getValue() == PeakMeasurementType.AREA)
        useArea = true;
    double[][] rawData = new double[selectedRawDataFiles.length][selectedRows.length];
    for (int rowIndex = 0; rowIndex < selectedRows.length; rowIndex++) {
        PeakListRow peakListRow = selectedRows[rowIndex];
        for (int fileIndex = 0; fileIndex < selectedRawDataFiles.length; fileIndex++) {
            RawDataFile rawDataFile = selectedRawDataFiles[fileIndex];
            Feature p = peakListRow.getPeak(rawDataFile);
            if (p != null) {
                if (useArea)
                    rawData[fileIndex][rowIndex] = p.getArea();
                else
                    rawData[fileIndex][rowIndex] = p.getHeight();
            }
        }
    }
    int numComponents = xAxisDimension;
    if (yAxisDimension > numComponents)
        numComponents = yAxisDimension;
    // Scale data and do Sammon's mapping
    Preprocess.scaleToUnityVariance(rawData);
    Sammons sammonsProj = new Sammons(rawData);
    projectionStatus = sammonsProj.getProjectionStatus();
    sammonsProj.iterate(100);
    if (status == TaskStatus.CANCELED)
        return;
    double[][] result = sammonsProj.getState();
    if (status == TaskStatus.CANCELED)
        return;
    component1Coords = result[xAxisDimension - 1];
    component2Coords = result[yAxisDimension - 1];
    ProjectionPlotWindow newFrame = new ProjectionPlotWindow(peakList, this, parameters);
    newFrame.setVisible(true);
    setStatus(TaskStatus.FINISHED);
    logger.info("Finished computing projection plot.");
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Sammons(jmprojection.Sammons) Feature(net.sf.mzmine.datamodel.Feature)

Example 27 with Feature

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

the class PeakLearnerTask method run.

/**
 * @see Runnable#run()
 */
@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    logger.info("Running learner task on " + peakList);
    // Create a new results peakList which is added at the end
    resultPeakList = new SimplePeakList(peakList + " " + suffix, peakList.getRawDataFiles());
    /**
     * - A PeakList is a list of Features (peak in retention time dimension with accurate m/z)<br>
     * ---- contains one or multiple RawDataFiles <br>
     * ---- access mean retention time, mean m/z, maximum intensity, ...<br>
     * - A RawDataFile holds a full chromatographic run with all ms scans<br>
     * ---- Each Scan and the underlying raw data can be accessed <br>
     * ---- Scans can be filtered by MS level, polarity, ...<br>
     */
    // is the data provided by peaklist enough for this task or
    // do you want to work on one raw data file or on all files?
    RawDataFile dataFile = peakList.getRawDataFile(0);
    // get all peaks of a raw data file
    // Sort peaks by ascending mz
    Feature[] sortedPeaks = peakList.getPeaks(dataFile);
    Arrays.sort(sortedPeaks, new PeakSorter(SortingProperty.MZ, SortingDirection.Ascending));
    // Loop through all peaks
    totalPeaks = sortedPeaks.length;
    for (int i = 0; i < totalPeaks; i++) {
        // check for cancelled state and stop
        if (isCanceled())
            return;
        // current peak
        Feature aPeak = sortedPeaks[i];
        // do stuff
        // ...
        // add row to result feature list
        PeakListRow row = peakList.getPeakRow(aPeak);
        row = copyPeakRow(row);
        resultPeakList.addRow(row);
        // Update completion rate
        processedPeaks++;
    }
    // add to project
    addResultToProject();
    logger.info("Finished on " + peakList);
    setStatus(TaskStatus.FINISHED);
}
Also used : SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) PeakSorter(net.sf.mzmine.util.PeakSorter) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature) Feature(net.sf.mzmine.datamodel.Feature)

Example 28 with Feature

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

the class StreamPeakListRowLearnerTask method copyPeakRow.

/**
 * Create a copy of a feature list row.
 *
 * @param row the row to copy.
 * @return the newly created copy.
 */
private static PeakListRow copyPeakRow(final PeakListRow row) {
    // Copy the feature list row.
    final PeakListRow newRow = new SimplePeakListRow(row.getID());
    PeakUtils.copyPeakListRowProperties(row, newRow);
    // Copy the peaks.
    for (final Feature peak : row.getPeaks()) {
        final Feature newPeak = new SimpleFeature(peak);
        PeakUtils.copyPeakProperties(peak, newPeak);
        newRow.addPeak(peak.getDataFile(), newPeak);
    }
    return newRow;
}
Also used : SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature) Feature(net.sf.mzmine.datamodel.Feature) SimpleFeature(net.sf.mzmine.datamodel.impl.SimpleFeature)

Example 29 with Feature

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

the class ManualPeakPickerModule method runManualDetection.

public static ExitCode runManualDetection(RawDataFile[] dataFiles, PeakListRow peakListRow, PeakList peakList, PeakListTable table) {
    Range<Double> mzRange = null, rtRange = null;
    // Check the peaks for selected data files
    for (RawDataFile dataFile : dataFiles) {
        Feature peak = peakListRow.getPeak(dataFile);
        if (peak == null)
            continue;
        if ((mzRange == null) || (rtRange == null)) {
            mzRange = peak.getRawDataPointsMZRange();
            rtRange = peak.getRawDataPointsRTRange();
        } else {
            mzRange = mzRange.span(peak.getRawDataPointsMZRange());
            rtRange = rtRange.span(peak.getRawDataPointsRTRange());
        }
    }
    // If none of the data files had a peak, check the whole row
    if (mzRange == null) {
        for (Feature peak : peakListRow.getPeaks()) {
            if (peak == null)
                continue;
            if ((mzRange == null) || (rtRange == null)) {
                mzRange = peak.getRawDataPointsMZRange();
                rtRange = peak.getRawDataPointsRTRange();
            } else {
                mzRange = mzRange.span(peak.getRawDataPointsMZRange());
                rtRange = rtRange.span(peak.getRawDataPointsRTRange());
            }
        }
    }
    ManualPickerParameters parameters = new ManualPickerParameters();
    if (mzRange != null) {
        parameters.getParameter(ManualPickerParameters.retentionTimeRange).setValue(rtRange);
        parameters.getParameter(ManualPickerParameters.mzRange).setValue(mzRange);
    }
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK)
        return exitCode;
    ManualPickerTask task = new ManualPickerTask(MZmineCore.getProjectManager().getCurrentProject(), peakListRow, dataFiles, parameters, peakList, table);
    MZmineCore.getTaskController().addTask(task);
    return exitCode;
}
Also used : RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ExitCode(net.sf.mzmine.util.ExitCode) Feature(net.sf.mzmine.datamodel.Feature)

Example 30 with Feature

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

the class XICManualPickerModule method runManualDetection.

// public static ExitCode runManualDetection(RawDataFile dataFile, PeakListRow peakListRow,
// PeakList peakList, PeakListTable table) {
// return runManualDetection(new RawDataFile[] {dataFile}, peakListRow, peakList, table);
// }
public static ExitCode runManualDetection(RawDataFile dataFile, PeakListRow peakListRow, PeakList peakList, PeakListTable table) {
    Range<Double> mzRange = null, rtRange = null;
    mzRange = Range.closed(peakListRow.getAverageMZ(), peakListRow.getAverageMZ());
    rtRange = Range.closed(peakListRow.getAverageRT(), peakListRow.getAverageRT());
    for (Feature peak : peakListRow.getPeaks()) {
        if (peak == null)
            continue;
        // if the peak exists in the file, then we just use that one as a base
        if (peak.getDataFile() == dataFile) {
            mzRange = peak.getRawDataPointsMZRange();
            rtRange = peak.getRawDataPointsRTRange();
            break;
        }
        // if it does not exist, we set up on basis of the other peaks
        if (peak != null) {
            mzRange = mzRange.span(peak.getRawDataPointsMZRange());
            rtRange = rtRange.span(peak.getRawDataPointsRTRange());
        }
    }
    XICManualPickerParameters parameters = new XICManualPickerParameters();
    if (mzRange != null) {
        parameters.getParameter(XICManualPickerParameters.rtRange).setValue(rtRange);
        parameters.getParameter(XICManualPickerParameters.mzRange).setValue(mzRange);
    }
    if (dataFile != null) {
        RawDataFilesSelection selection = new RawDataFilesSelection();
        selection.setSpecificFiles(new RawDataFile[] { dataFile });
        selection.setSelectionType(RawDataFilesSelectionType.SPECIFIC_FILES);
        parameters.getParameter(XICManualPickerParameters.rawDataFiles).setValue(selection);
    }
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK)
        return exitCode;
    ManualPickerParameters param = new ManualPickerParameters();
    param.getParameter(ManualPickerParameters.mzRange).setValue(parameters.getParameter(XICManualPickerParameters.mzRange).getValue());
    param.getParameter(ManualPickerParameters.retentionTimeRange).setValue(parameters.getParameter(XICManualPickerParameters.rtRange).getValue());
    ManualPickerTask task = new ManualPickerTask(MZmineCore.getProjectManager().getCurrentProject(), peakListRow, new RawDataFile[] { dataFile }, param, peakList, table);
    MZmineCore.getTaskController().addTask(task);
    return exitCode;
}
Also used : RawDataFilesSelection(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesSelection) ExitCode(net.sf.mzmine.util.ExitCode) Feature(net.sf.mzmine.datamodel.Feature)

Aggregations

Feature (net.sf.mzmine.datamodel.Feature)115 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)70 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)60 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)41 DataPoint (net.sf.mzmine.datamodel.DataPoint)35 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)35 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)25 Scan (net.sf.mzmine.datamodel.Scan)22 PeakList (net.sf.mzmine.datamodel.PeakList)20 ArrayList (java.util.ArrayList)17 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)16 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)15 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)15 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)13 PeakListAppliedMethod (net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod)10 MassList (net.sf.mzmine.datamodel.MassList)9 HashMap (java.util.HashMap)8 Vector (java.util.Vector)8 ScanSelection (net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection)7 TreeMap (java.util.TreeMap)6