Search in sources :

Example 21 with RawDataFile

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

the class RawDataFilesComponent method actionPerformed.

public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == detailsButton) {
        RawDataFilesSelectionType type = (RawDataFilesSelectionType) typeCombo.getSelectedItem();
        if (type == RawDataFilesSelectionType.SPECIFIC_FILES) {
            final MultiChoiceParameter<RawDataFile> filesParameter = new MultiChoiceParameter<RawDataFile>("Select files", "Select files", MZmineCore.getProjectManager().getCurrentProject().getDataFiles(), currentValue.getSpecificFiles());
            final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { filesParameter });
            final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
            final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
            if (exitCode == ExitCode.OK) {
                RawDataFile[] files = paramSet.getParameter(filesParameter).getValue();
                currentValue.setSpecificFiles(files);
            }
        }
        if (type == RawDataFilesSelectionType.NAME_PATTERN) {
            final StringParameter nameParameter = new StringParameter("Name pattern", "Set name pattern that may include wildcards (*), e.g. *mouse* matches any name that contains mouse", currentValue.getNamePattern());
            final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { nameParameter });
            final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
            final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
            if (exitCode == ExitCode.OK) {
                String namePattern = paramSet.getParameter(nameParameter).getValue();
                currentValue.setNamePattern(namePattern);
            }
        }
    }
    if (src == typeCombo) {
        RawDataFilesSelectionType type = (RawDataFilesSelectionType) typeCombo.getSelectedItem();
        currentValue.setSelectionType(type);
        detailsButton.setEnabled((type == RawDataFilesSelectionType.NAME_PATTERN) || (type == RawDataFilesSelectionType.SPECIFIC_FILES));
    }
    updateNumFiles();
}
Also used : Window(java.awt.Window) StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) ExitCode(net.sf.mzmine.util.ExitCode) MultiChoiceParameter(net.sf.mzmine.parameters.parametertypes.MultiChoiceParameter)

Example 22 with RawDataFile

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

the class RawDataFilesParameter method saveValueToXML.

@Override
public void saveValueToXML(Element xmlElement) {
    if (value == null)
        return;
    Document parentDocument = xmlElement.getOwnerDocument();
    xmlElement.setAttribute("type", value.getSelectionType().name());
    if (value.getSpecificFiles() != null) {
        for (RawDataFile item : value.getSpecificFiles()) {
            Element newElement = parentDocument.createElement("specific_file");
            newElement.setTextContent(item.getName());
            xmlElement.appendChild(newElement);
        }
    }
    if (value.getNamePattern() != null) {
        Element newElement = parentDocument.createElement("name_pattern");
        newElement.setTextContent(value.getNamePattern());
        xmlElement.appendChild(newElement);
    }
}
Also used : RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 23 with RawDataFile

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

the class RawDataFilesParameter method loadValueFromXML.

@Override
public void loadValueFromXML(Element xmlElement) {
    RawDataFile[] currentDataFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
    RawDataFilesSelectionType selectionType;
    final String attrValue = xmlElement.getAttribute("type");
    if (Strings.isNullOrEmpty(attrValue))
        selectionType = RawDataFilesSelectionType.GUI_SELECTED_FILES;
    else
        selectionType = RawDataFilesSelectionType.valueOf(xmlElement.getAttribute("type"));
    ArrayList<Object> newValues = new ArrayList<Object>();
    NodeList items = xmlElement.getElementsByTagName("specific_file");
    for (int i = 0; i < items.getLength(); i++) {
        String itemString = items.item(i).getTextContent();
        for (RawDataFile df : currentDataFiles) {
            if (df.getName().equals(itemString))
                newValues.add(df);
        }
    }
    RawDataFile[] specificFiles = newValues.toArray(new RawDataFile[0]);
    String namePattern = null;
    items = xmlElement.getElementsByTagName("name_pattern");
    for (int i = 0; i < items.getLength(); i++) {
        namePattern = items.item(i).getTextContent();
    }
    this.value = new RawDataFilesSelection();
    this.value.setSelectionType(selectionType);
    this.value.setSpecificFiles(specificFiles);
    this.value.setNamePattern(namePattern);
}
Also used : RawDataFile(net.sf.mzmine.datamodel.RawDataFile) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList)

Example 24 with RawDataFile

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

the class FeaturesSelectionDialog method actionPerformed.

/*
     *
     * 
     * @see
     * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     */
@Override
public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == btnOk) {
        returnState = true;
        this.dispose();
    }
    if (src == btnCancel) {
        returnState = false;
        this.dispose();
    }
    if (src == rawDataFileComboBox) {
        panel12.removeAll();
        RawDataFile dataFile = (RawDataFile) rawDataFileComboBox.getSelectedItem();
        Feature[] features = allPeakLists[selectedIndex].getPeaks(dataFile);
        featuresSelectionBox = new MultipleSelectionComponent<Feature>(features);
        featuresSelectionBox.setToolTipText("Features Selection Box");
        panel12.add(featuresSelectionBox, BorderLayout.CENTER);
        panel12.revalidate();
    }
    if (src == peakListComboBox) {
        PeakList peakList = (PeakList) peakListComboBox.getSelectedItem();
        panel11.removeAll();
        panel12.removeAll();
        for (int j = 0; j < allPeakLists.length; j++) {
            if (peakList.equals(allPeakLists[j])) {
                RawDataFile[] rawDataFiles = allPeakLists[j].getRawDataFiles();
                rawDataFileComboBox = new JComboBox<RawDataFile>(rawDataFiles);
                rawDataFileComboBox.setToolTipText("Raw data files Selection Box");
                rawDataFileComboBox.addActionListener(this);
                panel11.add(rawDataFileComboBox, BorderLayout.CENTER);
                this.setSize(670, 400);
                LOG.finest("PeakListRowComboBox is Added");
                selectedIndex = j;
                RawDataFile datafile = allPeakLists[j].getRawDataFile(0);
                Feature[] features = allPeakLists[j].getPeaks(datafile);
                featuresSelectionBox = new MultipleSelectionComponent<Feature>(features);
                featuresSelectionBox.setToolTipText("Features Selection Box");
                panel12.add(featuresSelectionBox, BorderLayout.CENTER);
            }
            panel11.revalidate();
            panel12.revalidate();
        }
    }
}
Also used : RawDataFile(net.sf.mzmine.datamodel.RawDataFile) PeakList(net.sf.mzmine.datamodel.PeakList) Feature(net.sf.mzmine.datamodel.Feature)

Example 25 with RawDataFile

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

the class MZRangeComponent method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == setAutoButton) {
        RawDataFile[] currentFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
        ScanSelection scanSelection = new ScanSelection();
        try {
            ParameterSetupDialog setupDialog = (ParameterSetupDialog) SwingUtilities.getWindowAncestor(this);
            RawDataFilesComponent rdc = (RawDataFilesComponent) setupDialog.getComponentForParameter(new RawDataFilesParameter());
            if (rdc != null) {
                RawDataFile[] matchingFiles = rdc.getValue().getMatchingRawDataFiles();
                if (matchingFiles.length > 0)
                    currentFiles = matchingFiles;
            }
            ScanSelectionComponent ssc = (ScanSelectionComponent) setupDialog.getComponentForParameter(new ScanSelectionParameter());
            if (ssc != null)
                scanSelection = ssc.getValue();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Range<Double> mzRange = null;
        for (RawDataFile file : currentFiles) {
            Scan[] scans = scanSelection.getMatchingScans(file);
            for (Scan s : scans) {
                Range<Double> scanRange = s.getDataPointMZRange();
                if (scanRange == null)
                    continue;
                if (mzRange == null)
                    mzRange = scanRange;
                else
                    mzRange = mzRange.span(scanRange);
            }
        }
        if (mzRange != null)
            setValue(mzRange);
    }
    if (src == fromMassButton) {
        Range<Double> mzRange = MzRangeMassCalculatorModule.showRangeCalculationDialog();
        if (mzRange != null)
            setValue(mzRange);
    }
    if (src == fromFormulaButton) {
        Range<Double> mzRange = MzRangeFormulaCalculatorModule.showRangeCalculationDialog();
        if (mzRange != null)
            setValue(mzRange);
    }
}
Also used : ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) ScanSelectionParameter(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionParameter) ParameterSetupDialog(net.sf.mzmine.parameters.dialogs.ParameterSetupDialog) RawDataFilesComponent(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesComponent) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Scan(net.sf.mzmine.datamodel.Scan) ScanSelectionComponent(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionComponent) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Aggregations

RawDataFile (net.sf.mzmine.datamodel.RawDataFile)185 Feature (net.sf.mzmine.datamodel.Feature)59 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)52 DataPoint (net.sf.mzmine.datamodel.DataPoint)51 Scan (net.sf.mzmine.datamodel.Scan)40 ArrayList (java.util.ArrayList)33 PeakList (net.sf.mzmine.datamodel.PeakList)33 Nonnull (javax.annotation.Nonnull)24 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)24 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)24 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)22 Task (net.sf.mzmine.taskcontrol.Task)20 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)19 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)17 IOException (java.io.IOException)14 ParameterSet (net.sf.mzmine.parameters.ParameterSet)14 File (java.io.File)13 MassList (net.sf.mzmine.datamodel.MassList)13 PeakListAppliedMethod (net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod)13 TreeMap (java.util.TreeMap)10