Search in sources :

Example 6 with Feature

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

the class MSMSExportModule method exportMSMS.

public static void exportMSMS(PeakListRow row) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(MSMSExportModule.class);
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK)
        return;
    File outputFile = parameters.getParameter(MSMSExportParameters.outputFile).getValue();
    String massListName = parameters.getParameter(MSMSExportParameters.massList).getValue();
    if ((outputFile == null) || (massListName == null))
        return;
    // Best peak always exists, because feature list row has at least one peak
    Feature bestPeak = row.getBestPeak();
    // Get the MS/MS scan number
    int msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
    if (msmsScanNumber < 1) {
        MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "There is no MS/MS scan for peak " + bestPeak);
        return;
    }
    // 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;
    }
    DataPoint[] peaks = massList.getDataPoints();
    try {
        FileWriter fileWriter = new FileWriter(outputFile);
        BufferedWriter writer = new BufferedWriter(fileWriter);
        for (DataPoint peak : peaks) {
            writer.write(peak.getMZ() + " " + peak.getIntensity());
            writer.newLine();
        }
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
        MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "Error writing to file " + outputFile + ": " + ExceptionUtils.exceptionToString(e));
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ExitCode(net.sf.mzmine.util.ExitCode) FileWriter(java.io.FileWriter) Feature(net.sf.mzmine.datamodel.Feature) DataPoint(net.sf.mzmine.datamodel.DataPoint) BufferedWriter(java.io.BufferedWriter) DataPoint(net.sf.mzmine.datamodel.DataPoint) Scan(net.sf.mzmine.datamodel.Scan) File(java.io.File) MassList(net.sf.mzmine.datamodel.MassList)

Example 7 with Feature

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

the class IntensityPlotTooltipGenerator method generateToolTip.

/**
 * @see org.jfree.chart.labels.CategoryToolTipGenerator#generateToolTip(org.jfree.data.category.CategoryDataset,
 *      int, int)
 */
public String generateToolTip(CategoryDataset dataset, int row, int column) {
    Format intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
    Feature[] peaks = ((IntensityPlotDataset) dataset).getPeaks(row, column);
    RawDataFile[] files = ((IntensityPlotDataset) dataset).getFiles(column);
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < files.length; i++) {
        sb.append(files[i].getName());
        sb.append(": ");
        if (peaks[i] != null) {
            sb.append(peaks[i].toString());
            sb.append(", height: ");
            sb.append(intensityFormat.format(peaks[i].getHeight()));
        } else {
            sb.append("N/A");
        }
        sb.append("\n");
    }
    return sb.toString();
}
Also used : Format(java.text.Format) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Feature(net.sf.mzmine.datamodel.Feature)

Example 8 with Feature

use of net.sf.mzmine.datamodel.Feature 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 9 with Feature

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

the class PeakListTableModel method getValueAt.

/**
 * This method returns the value at given coordinates of the dataset or null if it is a missing
 * value
 */
public Object getValueAt(int row, int col) {
    PeakListRow peakListRow = peakList.getRow(row);
    if (isCommonColumn(col)) {
        CommonColumnType commonColumn = getCommonColumn(col);
        switch(commonColumn) {
            case ROWID:
                return new Integer(peakListRow.getID());
            case AVERAGEMZ:
                return new Double(peakListRow.getAverageMZ());
            case AVERAGERT:
                if (peakListRow.getAverageRT() <= 0)
                    return null;
                return new Double(peakListRow.getAverageRT());
            case COMMENT:
                return peakListRow.getComment();
            case IDENTITY:
                return peakListRow.getPreferredPeakIdentity();
            case PEAKSHAPE:
                return peakListRow;
        }
    } else {
        DataFileColumnType dataFileColumn = getDataFileColumn(col);
        RawDataFile file = getColumnDataFile(col);
        Feature peak = peakListRow.getPeak(file);
        if (peak == null) {
            if (dataFileColumn == DataFileColumnType.STATUS)
                return FeatureStatus.UNKNOWN;
            else
                return null;
        }
        switch(dataFileColumn) {
            case STATUS:
                return peak.getFeatureStatus();
            case PEAKSHAPE:
                return peak;
            case MZ:
                return peak.getMZ();
            case RT:
                if (peak.getRT() <= 0)
                    return null;
                return peak.getRT();
            case HEIGHT:
                if (peak.getHeight() <= 0)
                    return null;
                return peak.getHeight();
            case AREA:
                return peak.getArea();
            case DURATION:
                double rtLen = peak.getRawDataPointsRTRange().upperEndpoint() - peak.getRawDataPointsRTRange().lowerEndpoint();
                return rtLen;
            case CHARGE:
                if (peak.getCharge() <= 0)
                    return null;
                return new Integer(peak.getCharge());
            case RT_START:
                return peak.getRawDataPointsRTRange().lowerEndpoint();
            case RT_END:
                return peak.getRawDataPointsRTRange().upperEndpoint();
            case DATAPOINTS:
                return peak.getScanNumbers().length;
            case FWHM:
                return peak.getFWHM();
            case TF:
                return peak.getTailingFactor();
            case AF:
                return peak.getAsymmetryFactor();
            case PARENT_ROW_ID:
                return peak.getParentChromatogramRowID();
        }
    }
    return null;
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Feature(net.sf.mzmine.datamodel.Feature)

Example 10 with Feature

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

the class HistogramPlotDataset method updateHistogramDataset.

public void updateHistogramDataset() {
    this.list.clear();
    Feature[] peaks;
    double[] values = null;
    for (RawDataFile dataFile : rawDataFiles) {
        peaks = peakList.getPeaks(dataFile);
        values = new double[peaks.length];
        for (int i = 0; i < peaks.length; i++) {
            switch(dataType) {
                case AREA:
                    values[i] = peaks[i].getArea();
                    break;
                case HEIGHT:
                    values[i] = peaks[i].getHeight();
                    break;
                case MASS:
                    values[i] = peaks[i].getMZ();
                    break;
                case RT:
                    values[i] = peaks[i].getRT();
                    break;
            }
        }
        addSeries(dataFile.getName(), values);
    }
}
Also used : RawDataFile(net.sf.mzmine.datamodel.RawDataFile) 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