Search in sources :

Example 1 with FeatureSelection

use of net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection in project mzmine2 by mzmine.

the class Fx3DStageController method addFeatures.

private void addFeatures() {
    for (FeatureSelection featureSelection : featureSelections) {
        Fx3DFeatureDataset featureDataset = new Fx3DFeatureDataset(featureSelection, rtResolution, mzResolution, rtRange, mzRange, maxOfAllBinnedIntensity, Color.rgb(255, 255, 0, 0.35));
        addDataset(featureDataset);
    }
}
Also used : FeatureSelection(net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection)

Example 2 with FeatureSelection

use of net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection 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 3 with FeatureSelection

use of net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection in project mzmine2 by mzmine.

the class Fx3DVisualizerModule method setupNew3DVisualizer.

public static void setupNew3DVisualizer(final RawDataFile dataFile, final Range<Double> mzRange, final Range<Double> rtRange, final Feature featureToShow) {
    final ParameterSet myParameters = MZmineCore.getConfiguration().getModuleParameters(Fx3DVisualizerModule.class);
    final Fx3DVisualizerModule myInstance = MZmineCore.getModuleInstance(Fx3DVisualizerModule.class);
    myParameters.getParameter(Fx3DVisualizerParameters.dataFiles).setValue(RawDataFilesSelectionType.SPECIFIC_FILES, new RawDataFile[] { dataFile });
    myParameters.getParameter(Fx3DVisualizerParameters.scanSelection).setValue(new ScanSelection(rtRange, 1));
    myParameters.getParameter(Fx3DVisualizerParameters.mzRange).setValue(mzRange);
    List<FeatureSelection> featuresList = Lists.newArrayList();
    if (featureToShow != null) {
        FeatureSelection selectedFeature = new FeatureSelection(null, featureToShow, null, null);
        featuresList.add(selectedFeature);
    }
    myParameters.getParameter(Fx3DVisualizerParameters.features).setValue(featuresList);
    if (myParameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true) == ExitCode.OK) {
        myInstance.runModule(MZmineCore.getProjectManager().getCurrentProject(), myParameters.cloneParameterSet(), new ArrayList<Task>());
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) Task(net.sf.mzmine.taskcontrol.Task) FeatureSelection(net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection)

Example 4 with FeatureSelection

use of net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection in project mzmine2 by mzmine.

the class Fx3DVisualizerModule method runModule.

@SuppressWarnings("null")
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    final RawDataFile[] currentDataFiles = parameters.getParameter(Fx3DVisualizerParameters.dataFiles).getValue().getMatchingRawDataFiles();
    final ScanSelection scanSel = parameters.getParameter(Fx3DVisualizerParameters.scanSelection).getValue();
    final List<FeatureSelection> featureSelList = parameters.getParameter(Fx3DVisualizerParameters.features).getValue();
    LOG.finest("Feature selection is:" + featureSelList.toString());
    for (FeatureSelection selection : featureSelList) {
        LOG.finest("Selected features are:" + selection.getFeature().toString());
    }
    Range<Double> rtRange = ScanUtils.findRtRange(scanSel.getMatchingScans(MZmineCore.getProjectManager().getCurrentProject().getDataFiles()[0]));
    ParameterSet myParameters = MZmineCore.getConfiguration().getModuleParameters(Fx3DVisualizerModule.class);
    Range<Double> mzRange = myParameters.getParameter(Fx3DVisualizerParameters.mzRange).getValue();
    int rtRes = myParameters.getParameter(Fx3DVisualizerParameters.rtResolution).getValue();
    int mzRes = myParameters.getParameter(Fx3DVisualizerParameters.mzResolution).getValue();
    Platform.runLater(() -> {
        if (!Platform.isSupported(ConditionalFeature.SCENE3D)) {
            JOptionPane.showMessageDialog(null, "The platform does not provide 3D support.");
            return;
        }
        FXMLLoader loader = new FXMLLoader((getClass().getResource("Fx3DStage.fxml")));
        Stage stage = null;
        try {
            stage = loader.load();
            LOG.finest("Stage has been successfully loaded from the FXML loader.");
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        String title = "";
        Fx3DStageController controller = loader.getController();
        controller.setScanSelection(scanSel);
        controller.setRtAndMzResolutions(rtRes, mzRes);
        controller.setRtAndMzValues(rtRange, mzRange);
        for (int i = 0; i < currentDataFiles.length; i++) {
            MZmineCore.getTaskController().addTask(new Fx3DSamplingTask(currentDataFiles[i], scanSel, mzRange, rtRes, mzRes, controller), TaskPriority.HIGH);
        }
        controller.addFeatureSelections(featureSelList);
        for (int i = 0; i < currentDataFiles.length; i++) {
            title = title + currentDataFiles[i].toString() + " ";
        }
        stage.show();
        stage.setMinWidth(stage.getWidth());
        stage.setMinHeight(stage.getHeight());
    });
    return ExitCode.OK;
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Stage(javafx.stage.Stage) FeatureSelection(net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection) Nonnull(javax.annotation.Nonnull)

Aggregations

FeatureSelection (net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection)4 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)2 ParameterSet (net.sf.mzmine.parameters.ParameterSet)2 ScanSelection (net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection)2 IOException (java.io.IOException)1 ActionEvent (javafx.event.ActionEvent)1 FXMLLoader (javafx.fxml.FXMLLoader)1 Menu (javafx.scene.control.Menu)1 MenuItem (javafx.scene.control.MenuItem)1 Stage (javafx.stage.Stage)1 Nonnull (javax.annotation.Nonnull)1 Feature (net.sf.mzmine.datamodel.Feature)1 PeakList (net.sf.mzmine.datamodel.PeakList)1 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)1 Task (net.sf.mzmine.taskcontrol.Task)1