Search in sources :

Example 36 with PeakList

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

the class TwoDBottomPanel method getPeaksInThreshold.

/**
 * Returns a feature list different peaks depending on the selected option of the "peak Threshold"
 * combo box
 */
PeakList getPeaksInThreshold() {
    PeakList selectedPeakList = (PeakList) peakListSelector.getSelectedItem();
    PeakThresholdMode mode = (PeakThresholdMode) thresholdCombo.getSelectedItem();
    switch(mode) {
        case ABOVE_INTENSITY_PEAKS:
            double threshold = thresholdSettings.getIntensityThreshold();
            return getIntensityThresholdPeakList(threshold);
        case ALL_PEAKS:
            return selectedPeakList;
        case TOP_PEAKS:
        case TOP_PEAKS_AREA:
            int topPeaks = thresholdSettings.getTopPeaksThreshold();
            return getTopThresholdPeakList(topPeaks);
    }
    return null;
}
Also used : SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) PeakList(net.sf.mzmine.datamodel.PeakList)

Example 37 with PeakList

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

the class GNPSResultsImportModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    // max 1
    PeakList peakList = parameters.getParameter(GNPSResultsImportParameters.PEAK_LIST).getValue().getMatchingPeakLists()[0];
    Task newTask = new GNPSResultsImportTask(parameters, peakList);
    tasks.add(newTask);
    return ExitCode.OK;
}
Also used : Task(net.sf.mzmine.taskcontrol.Task) PeakList(net.sf.mzmine.datamodel.PeakList) Nonnull(javax.annotation.Nonnull)

Example 38 with PeakList

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

the class OnlineDBSearchModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    final PeakList[] peakLists = parameters.getParameter(PeakListIdentificationParameters.peakLists).getValue().getMatchingPeakLists();
    for (final PeakList peakList : peakLists) {
        Task newTask = new PeakListIdentificationTask(parameters, peakList);
        tasks.add(newTask);
    }
    return ExitCode.OK;
}
Also used : Task(net.sf.mzmine.taskcontrol.Task) PeakList(net.sf.mzmine.datamodel.PeakList) Nonnull(javax.annotation.Nonnull)

Example 39 with PeakList

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

the class Fx3DStageController method addMenuItems.

private void addMenuItems() {
    removeMenu.getItems().clear();
    for (Fx3DAbstractDataset dataset : visualizedMeshPlots) {
        MenuItem menuItem = new MenuItem(dataset.getFileName());
        removeMenu.getItems().add(menuItem);
        menuItem.setOnAction(new EventHandler<ActionEvent>() {

            public void handle(ActionEvent e) {
                LOG.finest("Context menu invoked. Remove Data file button clicked. Removing dataset " + dataset.getFileName() + " from the plot.");
                visualizedFiles.remove(dataset.getFile());
                visualizedMeshPlots.remove(dataset);
                updateGraph();
                addMenuItems();
            }
        });
    }
    addDatafileMenu.getItems().clear();
    for (RawDataFile file : allDataFiles) {
        if (!visualizedFiles.contains(file)) {
            MenuItem menuItem = new MenuItem(file.getName());
            addDatafileMenu.getItems().add(menuItem);
            final Fx3DStageController controller = this;
            menuItem.setOnAction(new EventHandler<ActionEvent>() {

                public void handle(ActionEvent e) {
                    LOG.finest("Context menu invoked. Add Data file button clicked. Adding dataset " + file.getName() + " to the plot.");
                    MZmineCore.getTaskController().addTask(new Fx3DSamplingTask(file, scanSel, mzRange, rtResolution, mzResolution, controller), TaskPriority.HIGH);
                    addMenuItems();
                }
            });
        }
    }
    addFeatureMenu.getItems().clear();
    for (PeakList peakList : allPeakLists) {
        Menu peakListMenu = new Menu(peakList.getName());
        addFeatureMenu.getItems().add(peakListMenu);
        RawDataFile[] dataFiles = peakList.getRawDataFiles();
        for (RawDataFile dataFile : dataFiles) {
            Menu dataFileMenu = new Menu(dataFile.getName());
            peakListMenu.getItems().add(dataFileMenu);
            Feature[] features = peakList.getPeaks(dataFile);
            for (Feature feature : features) {
                if (feature.getRawDataPointsRTRange().lowerEndpoint() >= rtRange.lowerEndpoint() && feature.getRawDataPointsRTRange().upperEndpoint() <= mzRange.upperEndpoint() && feature.getRawDataPointsMZRange().lowerEndpoint() >= mzRange.lowerEndpoint() && feature.getRawDataPointsMZRange().upperEndpoint() <= mzRange.upperEndpoint()) {
                    if (!visualizedFiles.contains(feature)) {
                        MenuItem menuItem = new MenuItem(feature.toString());
                        dataFileMenu.getItems().add(menuItem);
                        menuItem.setOnAction(new EventHandler<ActionEvent>() {

                            public void handle(ActionEvent e) {
                                LOG.finest("Context menu invoked. Add Feature button clicked. Adding dataset " + feature.toString() + " to the plot.");
                                PeakListRow row = peakList.getPeakRow(feature);
                                FeatureSelection featureSelection = new FeatureSelection(peakList, feature, row, dataFile);
                                Fx3DFeatureDataset featureDataset = new Fx3DFeatureDataset(featureSelection, rtResolution, mzResolution, rtRange, mzRange, maxOfAllBinnedIntensity, Color.rgb(165, 42, 42, 0.9));
                                addDataset(featureDataset);
                                addMenuItems();
                            }
                        });
                    }
                }
            }
        }
    }
}
Also used : ActionEvent(javafx.event.ActionEvent) MenuItem(javafx.scene.control.MenuItem) Feature(net.sf.mzmine.datamodel.Feature) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Menu(javafx.scene.control.Menu) PeakList(net.sf.mzmine.datamodel.PeakList) FeatureSelection(net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection)

Example 40 with PeakList

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

the class ADAP3AlignerTask method alignPeaks.

private PeakList alignPeaks() {
    // Collect all data files
    List<RawDataFile> allDataFiles = new ArrayList<>(peakLists.length);
    for (final PeakList peakList : peakLists) {
        RawDataFile[] dataFiles = peakList.getRawDataFiles();
        if (dataFiles.length != 1)
            throw new IllegalArgumentException("Found more then one data " + "file in some of the peaks lists");
        allDataFiles.add(dataFiles[0]);
    }
    for (int i = 0; i < peakLists.length; ++i) {
        PeakList peakList = peakLists[i];
        Sample sample = new Sample(i);
        for (final PeakListRow row : peakList.getRows()) {
            Component component = getComponent(row);
            if (component != null)
                sample.addComponent(component);
        }
        alignment.addSample(sample);
    }
    process();
    // Create new feature list
    final PeakList alignedPeakList = new SimplePeakList(peakListName, allDataFiles.toArray(new RawDataFile[0]));
    int rowID = 0;
    List<ReferenceComponent> alignedComponents = alignment.getComponents();
    Collections.sort(alignedComponents);
    for (final ReferenceComponent referenceComponent : alignedComponents) {
        SimplePeakListRow newRow = new SimplePeakListRow(++rowID);
        for (int i = 0; i < referenceComponent.size(); ++i) {
            Component component = referenceComponent.getComponent(i);
            Peak peak = component.getBestPeak();
            peak.getInfo().mzValue(component.getMZ());
            PeakListRow row = findPeakListRow(referenceComponent.getSampleID(i), peak.getInfo().peakID);
            if (row == null)
                throw new IllegalStateException(String.format("Cannot find a feature list row for fileId = %d and peakId = %d", referenceComponent.getSampleID(), peak.getInfo().peakID));
            RawDataFile file = row.getRawDataFiles()[0];
            // Create a new MZmine feature
            Feature feature = ADAPInterface.peakToFeature(file, peak);
            // Add spectrum as an isotopic pattern
            DataPoint[] spectrum = component.getSpectrum().entrySet().stream().map(e -> new SimpleDataPoint(e.getKey(), e.getValue())).toArray(DataPoint[]::new);
            feature.setIsotopePattern(new SimpleIsotopePattern(spectrum, IsotopePattern.IsotopePatternStatus.PREDICTED, "Spectrum"));
            newRow.addPeak(file, feature);
        }
        // Save alignment score
        SimplePeakInformation peakInformation = (SimplePeakInformation) newRow.getPeakInformation();
        if (peakInformation == null)
            peakInformation = new SimplePeakInformation();
        peakInformation.addProperty("Alignment score", Double.toString(referenceComponent.getScore()));
        newRow.setPeakInformation(peakInformation);
        alignedPeakList.addRow(newRow);
    }
    return alignedPeakList;
}
Also used : Peak(dulab.adap.datamodel.Peak) Project(dulab.adap.datamodel.Project) TaskStatus(net.sf.mzmine.taskcontrol.TaskStatus) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) net.sf.mzmine.datamodel.impl(net.sf.mzmine.datamodel.impl) IsotopePattern(net.sf.mzmine.datamodel.IsotopePattern) DataPoint(net.sf.mzmine.datamodel.DataPoint) PeakList(net.sf.mzmine.datamodel.PeakList) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) Feature(net.sf.mzmine.datamodel.Feature) ParameterSet(net.sf.mzmine.parameters.ParameterSet) QualityParameters(net.sf.mzmine.modules.peaklistmethods.qualityparameters.QualityParameters) ADAPInterface(net.sf.mzmine.util.adap.ADAPInterface) PeakInfo(dulab.adap.datamodel.PeakInfo) Component(dulab.adap.datamodel.Component) ReferenceComponent(dulab.adap.datamodel.ReferenceComponent) AlignmentParameters(dulab.adap.workflow.AlignmentParameters) Nullable(javax.annotation.Nullable) OptimizationParameters(dulab.adap.common.algorithms.machineleanring.OptimizationParameters) NavigableMap(java.util.NavigableMap) Logger(java.util.logging.Logger) List(java.util.List) AbstractTask(net.sf.mzmine.taskcontrol.AbstractTask) Sample(dulab.adap.datamodel.Sample) TreeMap(java.util.TreeMap) MZmineProject(net.sf.mzmine.datamodel.MZmineProject) PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity) Collections(java.util.Collections) Sample(dulab.adap.datamodel.Sample) ArrayList(java.util.ArrayList) Feature(net.sf.mzmine.datamodel.Feature) DataPoint(net.sf.mzmine.datamodel.DataPoint) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) DataPoint(net.sf.mzmine.datamodel.DataPoint) ReferenceComponent(dulab.adap.datamodel.ReferenceComponent) Peak(dulab.adap.datamodel.Peak) PeakList(net.sf.mzmine.datamodel.PeakList) Component(dulab.adap.datamodel.Component) ReferenceComponent(dulab.adap.datamodel.ReferenceComponent)

Aggregations

PeakList (net.sf.mzmine.datamodel.PeakList)120 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)41 Nonnull (javax.annotation.Nonnull)40 Task (net.sf.mzmine.taskcontrol.Task)37 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)36 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)26 Feature (net.sf.mzmine.datamodel.Feature)19 ArrayList (java.util.ArrayList)15 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)11 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)11 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)10 File (java.io.File)9 FileWriter (java.io.FileWriter)8 ParameterSet (net.sf.mzmine.parameters.ParameterSet)8 IOException (java.io.IOException)7 DataPoint (net.sf.mzmine.datamodel.DataPoint)7 Vector (java.util.Vector)6 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)6 MZmineProject (net.sf.mzmine.datamodel.MZmineProject)6 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)6