Search in sources :

Example 86 with PeakList

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

the class MZmineProjectImpl method getPeakLists.

public PeakList[] getPeakLists(RawDataFile file) {
    PeakList[] currentPeakLists = getPeakLists();
    Vector<PeakList> result = new Vector<PeakList>();
    for (PeakList peakList : currentPeakLists) {
        if (peakList.hasRawDataFile(file))
            result.add(peakList);
    }
    return result.toArray(new PeakList[0]);
}
Also used : PeakList(net.sf.mzmine.datamodel.PeakList) Vector(java.util.Vector)

Example 87 with PeakList

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

the class FeaturesParameter method loadValueFromXML.

/*
   * @see net.sf.mzmine.parameters.Parameter#loadValueFromXML(org.w3c.dom.Element)
   */
@Override
public void loadValueFromXML(Element xmlElement) {
    PeakList[] allPeakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
    List<FeatureSelection> newValues = new ArrayList<FeatureSelection>();
    NodeList items = xmlElement.getElementsByTagName("feature");
    for (int i = 0; i < items.getLength(); i++) {
        Node doc = items.item(i);
        if (doc instanceof Element) {
            Element docElement = (Element) doc;
            for (PeakList peakList : allPeakLists) {
                PeakListRow[] rows = peakList.getRows();
                RawDataFile[] dataFiles = peakList.getRawDataFiles();
                if (peakList.getName().equals(docElement.getElementsByTagName("peaklist_name").item(0).getNodeValue())) {
                    int rownum = 0;
                    for (PeakListRow row : rows) {
                        if (row.toString().equals(docElement.getElementsByTagName("peaklist_row_id").item(0).getNodeValue())) {
                            for (RawDataFile dataFile : dataFiles) {
                                if (dataFile.getName().equals(docElement.getElementsByTagName("rawdatafile_name").item(0).getNodeValue())) {
                                    Feature feature = peakList.getPeak(rownum, dataFile);
                                    newValues.add(new FeatureSelection(peakList, feature, row, dataFile));
                                }
                            }
                        }
                        rownum++;
                    }
                }
            }
        }
    }
    this.value = new ArrayList<FeatureSelection>();
    this.value = newValues;
    LOG.finest("Values have been loaded from XML");
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Feature(net.sf.mzmine.datamodel.Feature) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) PeakList(net.sf.mzmine.datamodel.PeakList)

Example 88 with PeakList

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

the class PeakListsParameter method saveValueToXML.

@Override
public void saveValueToXML(Element xmlElement) {
    if (value == null)
        return;
    Document parentDocument = xmlElement.getOwnerDocument();
    xmlElement.setAttribute("type", value.getSelectionType().name());
    if (value.getSpecificPeakLists() != null) {
        for (PeakList item : value.getSpecificPeakLists()) {
            Element newElement = parentDocument.createElement("specific_peak_list");
            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 : Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) PeakList(net.sf.mzmine.datamodel.PeakList)

Example 89 with PeakList

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

the class PeakListsParameter method loadValueFromXML.

@Override
public void loadValueFromXML(Element xmlElement) {
    PeakList[] currentDataPeakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
    PeakListsSelectionType selectionType;
    final String attrValue = xmlElement.getAttribute("type");
    if (Strings.isNullOrEmpty(attrValue))
        selectionType = PeakListsSelectionType.GUI_SELECTED_PEAKLISTS;
    else
        selectionType = PeakListsSelectionType.valueOf(xmlElement.getAttribute("type"));
    ArrayList<Object> newValues = new ArrayList<Object>();
    NodeList items = xmlElement.getElementsByTagName("specific_peak_list");
    for (int i = 0; i < items.getLength(); i++) {
        String itemString = items.item(i).getTextContent();
        for (PeakList df : currentDataPeakLists) {
            if (df.getName().equals(itemString))
                newValues.add(df);
        }
    }
    PeakList[] specificPeakLists = newValues.toArray(new PeakList[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 PeakListsSelection();
    this.value.setSelectionType(selectionType);
    this.value.setSpecificPeakLists(specificPeakLists);
    this.value.setNamePattern(namePattern);
}
Also used : NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) PeakList(net.sf.mzmine.datamodel.PeakList)

Example 90 with PeakList

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

the class FeaturesComponent method actionPerformed.

/*
     * @see
     * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     */
@Override
public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == addButton) {
        currentValue.clear();
        LOG.finest("Add Button Clicked!");
        FeaturesSelectionDialog featuresSelectionDialog = new FeaturesSelectionDialog();
        featuresSelectionDialog.setModal(true);
        featuresSelectionDialog.setVisible(true);
        if (featuresSelectionDialog.getReturnState() == true) {
            jlist.setVisible(true);
            PeakList selectedPeakList = featuresSelectionDialog.getSelectedPeakList();
            RawDataFile selectedRawDataFile = featuresSelectionDialog.getSelectedRawDataFile();
            LOG.finest("Selected PeakList is:" + selectedPeakList.getName());
            LOG.finest("Selected RawDataFile is:" + selectedRawDataFile.getName());
            for (Feature feature : featuresSelectionDialog.getSelectedFeatures()) {
                PeakListRow selectedRow = selectedPeakList.getPeakRow(feature);
                FeatureSelection featureSelection = new FeatureSelection(selectedPeakList, feature, selectedRow, selectedRawDataFile);
                currentValue.add(featureSelection);
                model.addElement(feature.toString());
            }
        }
    }
    if (src == removeButton) {
        LOG.finest("Remove Button Clicked!");
        int[] indices = jlist.getSelectedIndices();
        int k = 0;
        for (int i : indices) {
            model.remove(i - k);
            currentValue.remove(i - k);
            k++;
        }
    }
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) PeakList(net.sf.mzmine.datamodel.PeakList) Feature(net.sf.mzmine.datamodel.Feature)

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