Search in sources :

Example 36 with RawDataFile

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

the class ManualPickerTask method run.

public void run() {
    setStatus(TaskStatus.PROCESSING);
    logger.finest("Starting manual peak picker, RT: " + rtRange + ", m/z: " + mzRange);
    // Calculate total number of scans to process
    for (RawDataFile dataFile : dataFiles) {
        int[] scanNumbers = dataFile.getScanNumbers(1, rtRange);
        totalScans += scanNumbers.length;
    }
    // Find peak in each data file
    for (RawDataFile dataFile : dataFiles) {
        ManualPeak newPeak = new ManualPeak(dataFile);
        boolean dataPointFound = false;
        int[] scanNumbers = dataFile.getScanNumbers(1, rtRange);
        for (int scanNumber : scanNumbers) {
            if (isCanceled())
                return;
            // Get next scan
            Scan scan = dataFile.getScan(scanNumber);
            // Find most intense m/z peak
            DataPoint basePeak = ScanUtils.findBasePeak(scan, mzRange);
            if (basePeak != null) {
                if (basePeak.getIntensity() > 0)
                    dataPointFound = true;
                newPeak.addDatapoint(scan.getScanNumber(), basePeak);
            } else {
                final double mzCenter = (mzRange.lowerEndpoint() + mzRange.upperEndpoint()) / 2.0;
                DataPoint fakeDataPoint = new SimpleDataPoint(mzCenter, 0);
                newPeak.addDatapoint(scan.getScanNumber(), fakeDataPoint);
            }
            processedScans++;
        }
        if (dataPointFound) {
            newPeak.finalizePeak();
            if (newPeak.getArea() > 0)
                peakListRow.addPeak(dataFile, newPeak);
        } else {
            peakListRow.removePeak(dataFile);
        }
    }
    // Notify the GUI that peaklist contents have changed
    if (peakList != null) {
        // Check if the feature list row has been added to the feature list, and
        // if it has not, add it
        List<PeakListRow> rows = Arrays.asList(peakList.getRows());
        if (!rows.contains(peakListRow)) {
            peakList.addRow(peakListRow);
        }
        // Add quality parameters to peaks
        QualityParameters.calculateQualityParameters(peakList);
        project.notifyObjectChanged(peakList, true);
    }
    if (table != null) {
        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
    }
    logger.finest("Finished manual peak picker, " + processedScans + " scans processed");
    setStatus(TaskStatus.FINISHED);
}
Also used : SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint) Scan(net.sf.mzmine.datamodel.Scan) AbstractTableModel(javax.swing.table.AbstractTableModel) DataPoint(net.sf.mzmine.datamodel.DataPoint) SimpleDataPoint(net.sf.mzmine.datamodel.impl.SimpleDataPoint)

Example 37 with RawDataFile

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

the class BaselineCorrectionModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    RawDataFile[] dataFiles = parameters.getParameter(BaselineCorrectionParameters.dataFiles).getValue().getMatchingRawDataFiles();
    for (final RawDataFile dataFile : dataFiles) {
        Task newTask = new BaselineCorrectionTask(project, dataFile, parameters);
        tasks.add(newTask);
    }
    return ExitCode.OK;
}
Also used : Task(net.sf.mzmine.taskcontrol.Task) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Nonnull(javax.annotation.Nonnull)

Example 38 with RawDataFile

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

the class UserParameterSaveHandler method fillParameterElement.

/**
 * Create the part of the XML document related to the scans
 *
 * @param scan
 * @param element
 */
private void fillParameterElement(UserParameter<?, ?> parameter, TransformerHandler hd) throws SAXException, IOException {
    AttributesImpl atts = new AttributesImpl();
    RawDataFile[] dataFiles = project.getDataFiles();
    if (parameter instanceof ComboParameter) {
        Object[] choices = ((ComboParameter<?>) parameter).getChoices();
        for (Object choice : choices) {
            hd.startElement("", "", UserParameterElementName.OPTION.getElementName(), atts);
            hd.characters(choice.toString().toCharArray(), 0, choice.toString().length());
            hd.endElement("", "", UserParameterElementName.OPTION.getElementName());
        }
    }
    for (RawDataFile dataFile : dataFiles) {
        Object value = project.getParameterValue(parameter, dataFile);
        if (value == null)
            continue;
        String valueString = String.valueOf(value);
        String dataFileID = dataFilesIDMap.get(dataFile);
        atts.addAttribute("", "", UserParameterElementName.DATA_FILE.getElementName(), "CDATA", dataFileID);
        hd.startElement("", "", UserParameterElementName.VALUE.getElementName(), atts);
        atts.clear();
        hd.characters(valueString.toCharArray(), 0, valueString.length());
        hd.endElement("", "", UserParameterElementName.VALUE.getElementName());
    }
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ComboParameter(net.sf.mzmine.parameters.parametertypes.ComboParameter)

Example 39 with RawDataFile

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

the class ADAP3DModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    RawDataFile[] dataFiles = parameters.getParameter(new RawDataFilesParameter()).getValue().getMatchingRawDataFiles();
    for (int i = 0; i < dataFiles.length; i++) {
        Task newTask = new ADAP3DTask(project, dataFiles[i], parameters.cloneParameterSet());
        tasks.add(newTask);
    }
    return ExitCode.OK;
}
Also used : Task(net.sf.mzmine.taskcontrol.Task) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter) Nonnull(javax.annotation.Nonnull)

Example 40 with RawDataFile

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

the class RawFileMergeModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    // merge all selected
    if (parameters.getParameter(RawFileMergeParameters.mode).getValue().equals(MODE.MERGE_SELECTED)) {
        RawDataFile[] raw = parameters.getParameter(RawFileMergeParameters.dataFiles).getValue().getMatchingRawDataFiles();
        RawFileMergeTask task = new RawFileMergeTask(project, parameters, raw);
        tasks.add(task);
    } else {
        // sort files into merge groups
        RawDataFile[] raw = parameters.getParameter(RawFileMergeParameters.dataFiles).getValue().getMatchingRawDataFiles();
        POSITION pos = parameters.getParameter(RawFileMergeParameters.position).getValue();
        String posMarker = parameters.getParameter(RawFileMergeParameters.posMarker).getValue();
        String groupingElement = "";
        List<RawDataFile> current = new ArrayList<>();
        do {
            current.clear();
            for (int i = 0; i < raw.length; i++) {
                if (raw[i] != null) {
                    String group = extractGroup(pos, posMarker, raw[i]);
                    if (current.isEmpty()) {
                        groupingElement = group;
                        current.add(raw[i]);
                        raw[i] = null;
                    } else if (group.equals(groupingElement)) {
                        current.add(raw[i]);
                        raw[i] = null;
                    }
                }
            }
            // run task
            if (current.size() > 1) {
                RawFileMergeTask task = new RawFileMergeTask(project, parameters, current.toArray(new RawDataFile[current.size()]));
                tasks.add(task);
            }
        } while (!current.isEmpty());
    }
    return ExitCode.OK;
}
Also used : POSITION(net.sf.mzmine.modules.rawdatamethods.merge.RawFileMergeParameters.POSITION) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

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