Search in sources :

Example 6 with PeakList

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

the class XMLExportTask method run.

/**
 * @see java.lang.Runnable#run()
 */
public void run() {
    setStatus(TaskStatus.PROCESSING);
    // Shall export several files?
    boolean substitute = fileName.getPath().contains(plNamePattern);
    // Process feature lists
    for (int i = 0; i < peakLists.length; i++) {
        PeakList peakList = peakLists[i];
        File curFile = fileName;
        try {
            // Filename
            if (substitute) {
                // Cleanup from illegal filename characters
                String cleanPlName = peakList.getName().replaceAll("[^a-zA-Z0-9.-]", "_");
                // Substitute
                String newFilename = fileName.getPath().replaceAll(Pattern.quote(plNamePattern), cleanPlName);
                curFile = new File(newFilename);
            }
            // Open file
            FileWriter writer;
            try {
                writer = new FileWriter(curFile);
            } catch (Exception e) {
                setStatus(TaskStatus.ERROR);
                setErrorMessage("Could not open file " + curFile + " for writing.");
                return;
            }
            logger.info("Started saving feature list " + peakList.getName());
            // write the saving file
            FileOutputStream fos = new FileOutputStream(curFile);
            OutputStream finalStream = fos;
            if (compression) {
                @SuppressWarnings("resource") ZipOutputStream zos = new ZipOutputStream(fos);
                zos.setLevel(9);
                zos.putNextEntry(new ZipEntry(fileName.getName()));
                finalStream = zos;
            }
            Hashtable<RawDataFile, String> dataFilesIDMap = new Hashtable<RawDataFile, String>();
            for (RawDataFile file : peakList.getRawDataFiles()) {
                dataFilesIDMap.put(file, file.getName());
            }
            PeakListSaveHandler peakListSaveHandler = new PeakListSaveHandler(finalStream, dataFilesIDMap);
            peakListSaveHandlers[i] = peakListSaveHandler;
            peakListSaveHandler.savePeakList(peakList);
            finalStream.close();
        } catch (Exception e) {
            /* we may already have set the status to CANCELED */
            if (getStatus() == TaskStatus.PROCESSING) {
                setStatus(TaskStatus.ERROR);
            }
            setErrorMessage(e.toString());
            e.printStackTrace();
            return;
        }
        logger.info("Finished saving " + peakList.getName());
        setStatus(TaskStatus.FINISHED);
    }
}
Also used : Hashtable(java.util.Hashtable) FileWriter(java.io.FileWriter) OutputStream(java.io.OutputStream) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) ZipEntry(java.util.zip.ZipEntry) PeakListSaveHandler(net.sf.mzmine.modules.projectmethods.projectsave.PeakListSaveHandler) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) PeakList(net.sf.mzmine.datamodel.PeakList) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) File(java.io.File)

Example 7 with PeakList

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

the class IsotopeGrouperModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    PeakList[] peakLists = parameters.getParameter(IsotopeGrouperParameters.peakLists).getValue().getMatchingPeakLists();
    for (final PeakList peakList : peakLists) {
        Task newTask = new IsotopeGrouperTask(project, peakList, parameters);
        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 8 with PeakList

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

the class ADAP3DecompositionV2SetupDialog method shapeCluster.

/**
 * Cluster list of PeakInfo based on the chromatographic shapes
 */
private void shapeCluster() {
    ChromatogramPeakPair chromatogramPeakPair = cboPeakLists.getItemAt(cboPeakLists.getSelectedIndex());
    if (chromatogramPeakPair == null)
        return;
    PeakList chromatogramList = chromatogramPeakPair.chromatograms;
    PeakList peakList = chromatogramPeakPair.peaks;
    if (chromatogramList == null || peakList == null)
        return;
    final RetTimeClusterer.Cluster cluster = cboClusters.getItemAt(cboClusters.getSelectedIndex());
    if (cluster == null)
        return;
    Double retTimeTolerance = parameterSet.getParameter(ADAP3DecompositionV2Parameters.RET_TIME_TOLERANCE).getValue();
    Boolean adjustApexRetTime = parameterSet.getParameter(ADAP3DecompositionV2Parameters.ADJUST_APEX_RET_TIME).getValue();
    Integer minClusterSize = parameterSet.getParameter(ADAP3DecompositionV2Parameters.MIN_CLUSTER_SIZE).getValue();
    if (retTimeTolerance == null || retTimeTolerance <= 0.0 || adjustApexRetTime == null || minClusterSize == null || minClusterSize <= 0)
        return;
    List<BetterPeak> chromatograms = new ADAP3DecompositionV2Utils().getPeaks(chromatogramList);
    List<BetterComponent> components = null;
    try {
        components = new ComponentSelector().execute(chromatograms, cluster, retTimeTolerance, adjustApexRetTime, minClusterSize);
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (components != null)
        // chromatograms
        retTimeIntensityPlot.updateData(chromatograms, components);
}
Also used : BetterPeak(dulab.adap.datamodel.BetterPeak) ComponentSelector(dulab.adap.workflow.decomposition.ComponentSelector) BetterComponent(dulab.adap.datamodel.BetterComponent) RetTimeClusterer(dulab.adap.workflow.decomposition.RetTimeClusterer) PeakList(net.sf.mzmine.datamodel.PeakList)

Example 9 with PeakList

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

the class PeakListsComponent method actionPerformed.

public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == detailsButton) {
        PeakListsSelectionType type = (PeakListsSelectionType) typeCombo.getSelectedItem();
        if (type == PeakListsSelectionType.SPECIFIC_PEAKLISTS) {
            final MultiChoiceParameter<PeakList> plsParameter = new MultiChoiceParameter<PeakList>("Select feature lists", "Select feature lists", MZmineCore.getProjectManager().getCurrentProject().getPeakLists(), currentValue.getSpecificPeakLists());
            final SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { plsParameter });
            final Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
            final ExitCode exitCode = paramSet.showSetupDialog(parent, true);
            if (exitCode == ExitCode.OK) {
                PeakList[] pls = paramSet.getParameter(plsParameter).getValue();
                currentValue.setSpecificPeakLists(pls);
            }
        }
        if (type == PeakListsSelectionType.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) {
        PeakListsSelectionType type = (PeakListsSelectionType) typeCombo.getSelectedItem();
        currentValue.setSelectionType(type);
        detailsButton.setEnabled((type == PeakListsSelectionType.NAME_PATTERN) || (type == PeakListsSelectionType.SPECIFIC_PEAKLISTS));
    }
    updateNumPeakLists();
}
Also used : Window(java.awt.Window) StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) ExitCode(net.sf.mzmine.util.ExitCode) PeakList(net.sf.mzmine.datamodel.PeakList) MultiChoiceParameter(net.sf.mzmine.parameters.parametertypes.MultiChoiceParameter)

Example 10 with PeakList

use of net.sf.mzmine.datamodel.PeakList 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)

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