Search in sources :

Example 31 with SimplePeakList

use of net.sf.mzmine.datamodel.impl.SimplePeakList in project mzmine2 by mzmine.

the class MultiThreadPeakFinderMainTask method createResultsPeakList.

private PeakList createResultsPeakList() {
    SimplePeakList processedPeakList = new SimplePeakList(peakList + " " + suffix, peakList.getRawDataFiles());
    // Fill new feature list with empty rows
    for (int row = 0; row < peakList.getNumberOfRows(); row++) {
        PeakListRow sourceRow = peakList.getRow(row);
        PeakListRow newRow = new SimplePeakListRow(sourceRow.getID());
        newRow.setComment(sourceRow.getComment());
        for (PeakIdentity ident : sourceRow.getPeakIdentities()) {
            newRow.addPeakIdentity(ident, false);
        }
        if (sourceRow.getPreferredPeakIdentity() != null) {
            newRow.setPreferredPeakIdentity(sourceRow.getPreferredPeakIdentity());
        }
        processedPeakList.addRow(newRow);
    }
    return processedPeakList;
}
Also used : PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow)

Example 32 with SimplePeakList

use of net.sf.mzmine.datamodel.impl.SimplePeakList in project mzmine2 by mzmine.

the class PeakListBlankSubtractionMasterTask method run.

@Override
public void run() {
    if (!checkBlankSelection(alignedFeatureList, blankRaws)) {
        setErrorMessage("Peak list " + alignedFeatureList.getName() + " does no contain all selected blank raw data files.");
        setStatus(TaskStatus.ERROR);
        return;
    }
    setStatus(TaskStatus.PROCESSING);
    // PeakListRow[] rowsInBlanks =
    // getFeatureRowsContainedBlanks(alignedFeatureList, blankRaws, minBlankDetections);
    PeakListRow[] rows = PeakUtils.copyPeakRows(alignedFeatureList.getRows());
    rows = PeakUtils.sortRowsMzAsc(rows);
    for (RawDataFile raw : alignedFeatureList.getRawDataFiles()) {
        // only create a task for every file that is not a blank
        if (Arrays.asList(blankRaws).contains(raw))
            continue;
        // these tasks will access the passed array and remove the features that appear in their raw
        // data file and the blanks from these rows
        AbstractTask task = new PeakListBlankSubtractionSingleTask(parameters, raw, rows);
        MZmineCore.getTaskController().addTask(task);
        subTasks.add(task);
        if (getStatus() == TaskStatus.CANCELED)
            return;
    }
    // wait for tasks to finish
    boolean allTasksFinished = false;
    while (!allTasksFinished) {
        allTasksFinished = true;
        for (AbstractTask task : subTasks) {
            if (task.getStatus() != TaskStatus.FINISHED)
                allTasksFinished = false;
        }
        try {
            TimeUnit.MILLISECONDS.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
            setErrorMessage(e.getMessage());
            setStatus(TaskStatus.ERROR);
            return;
        }
        if (getStatus() == TaskStatus.CANCELED)
            return;
    }
    // remove rows that only contain blankRaws
    List<RawDataFile> blankRawsList = Arrays.asList(blankRaws);
    int onlyBlankRows = 0;
    for (int i = 0; i < rows.length; i++) {
        PeakListRow row = rows[i];
        if (blankRawsList.containsAll(Arrays.asList(row.getRawDataFiles()))) {
            onlyBlankRows++;
            rows[i] = null;
        }
        if (getStatus() == TaskStatus.CANCELED)
            return;
    }
    logger.finest("Removed " + onlyBlankRows + " rows that only existed in blankfiles.");
    PeakList result = new SimplePeakList(alignedFeatureList.getName() + " sbtrctd", alignedFeatureList.getRawDataFiles());
    for (PeakListRow row : rows) {
        if (row != null) {
            result.addRow(row);
        }
    }
    PeakListUtils.copyPeakListAppliedMethods(alignedFeatureList, result);
    result.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod(PeakListBlankSubtractionModule.MODULE_NAME, parameters));
    project.addPeakList(result);
    setStatus(TaskStatus.FINISHED);
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) AbstractTask(net.sf.mzmine.taskcontrol.AbstractTask) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) PeakList(net.sf.mzmine.datamodel.PeakList) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)

Example 33 with SimplePeakList

use of net.sf.mzmine.datamodel.impl.SimplePeakList in project mzmine2 by mzmine.

the class GNPSResultsImportTask method run.

/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    logger.info("Importing GNPS results for " + peakList);
    // remove zero ids from edges to prevent exception
    removeZeroIDFromEdge(file);
    Graph graph = new DefaultGraph("GNPS");
    if (importGraphData(graph, file)) {
        // import library matches from nodes
        importLibraryMatches(graph);
        // Add task description to peakList
        ((SimplePeakList) peakList).addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Identification of complexes", parameters));
        // Repaint the window to reflect the change in the feature list
        Desktop desktop = MZmineCore.getDesktop();
        if (!(desktop instanceof HeadLessDesktop))
            desktop.getMainWindow().repaint();
        setStatus(TaskStatus.FINISHED);
        logger.info("Finished import of GNPS results for " + peakList);
    }
}
Also used : DefaultGraph(org.graphstream.graph.implementations.DefaultGraph) Graph(org.graphstream.graph.Graph) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop) Desktop(net.sf.mzmine.desktop.Desktop) DefaultGraph(org.graphstream.graph.implementations.DefaultGraph) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop)

Example 34 with SimplePeakList

use of net.sf.mzmine.datamodel.impl.SimplePeakList in project mzmine2 by mzmine.

the class LipidSearchTask method run.

/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    logger.info("Starting lipid search in " + peakList);
    PeakListRow[] rows = peakList.getRows();
    // Check if lipids should be modified
    if (searchForModifications == true) {
        lipidModificationMasses = getLipidModificationMasses(lipidModification);
    }
    // Calculate how many possible lipids we will try
    totalSteps = ((maxChainLength - minChainLength + 1) * (maxDoubleBonds - minDoubleBonds + 1)) * selectedLipids.length;
    // Try all combinations of fatty acid lengths and double bonds
    for (int i = 0; i < selectedLipids.length; i++) {
        int numberOfAcylChains = selectedLipids[i].getNumberOfAcylChains();
        int numberOfAlkylChains = selectedLipids[i].getNumberofAlkyChains();
        for (int chainLength = minChainLength; chainLength <= maxChainLength; chainLength++) {
            for (int chainDoubleBonds = minDoubleBonds; chainDoubleBonds <= maxDoubleBonds; chainDoubleBonds++) {
                // Task canceled?
                if (isCanceled())
                    return;
                // than minimal length, skip this lipid
                if (((chainLength > 0) && (chainLength < minChainLength))) {
                    finishedSteps++;
                    continue;
                }
                // doesn't make sense, so let's skip such lipids
                if (((chainDoubleBonds > 0) && (chainDoubleBonds > chainLength - 1))) {
                    finishedSteps++;
                    continue;
                }
                // Prepare a lipid instance
                LipidIdentity lipidChain = new LipidIdentity(selectedLipids[i], chainLength, chainDoubleBonds, numberOfAcylChains, numberOfAlkylChains);
                // Find all rows that match this lipid
                findPossibleLipid(lipidChain, rows);
                finishedSteps++;
            }
        }
    }
    // Add task description to peakList
    ((SimplePeakList) peakList).addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Lipid search", parameters));
    // Repaint the window to reflect the change in the peak list
    Desktop desktop = MZmineCore.getDesktop();
    if (!(desktop instanceof HeadLessDesktop))
        desktop.getMainWindow().repaint();
    setStatus(TaskStatus.FINISHED);
    logger.info("Finished lipid search task in " + peakList);
}
Also used : LipidIdentity(net.sf.mzmine.modules.peaklistmethods.identification.lipididentification.lipidutils.LipidIdentity) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop) Desktop(net.sf.mzmine.desktop.Desktop) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) DataPoint(net.sf.mzmine.datamodel.DataPoint) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop)

Example 35 with SimplePeakList

use of net.sf.mzmine.datamodel.impl.SimplePeakList in project mzmine2 by mzmine.

the class MzTabImportTask method run.

@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    try {
        // Prevent MZTabFileParser from writing to console
        OutputStream logStream = ByteStreams.nullOutputStream();
        // Load mzTab file
        MZTabFileParser mzTabFileParser = new MZTabFileParser(inputFile, logStream);
        if (!mzTabFileParser.getErrorList().getErrorList().isEmpty()) {
            setStatus(TaskStatus.ERROR);
            setErrorMessage("Error processing " + inputFile + ":\n" + mzTabFileParser.getErrorList().toString());
            return;
        }
        MZTabFile mzTabFile = mzTabFileParser.getMZTabFile();
        // Let's say the initial parsing took 10% of the time
        finishedPercentage = 0.1;
        // Import raw data files
        SortedMap<Integer, RawDataFile> rawDataFiles = importRawDataFiles(mzTabFile);
        // Check if not canceled
        if (isCanceled())
            return;
        // Create a new feature list
        String peakListName = inputFile.getName().replace(".mzTab", "");
        RawDataFile[] rawDataArray = rawDataFiles.values().toArray(new RawDataFile[0]);
        PeakList newPeakList = new SimplePeakList(peakListName, rawDataArray);
        // Check if not canceled
        if (isCanceled())
            return;
        // Import variables
        importVariables(mzTabFile, rawDataFiles);
        // Check if not canceled
        if (isCanceled())
            return;
        // import small molecules (=feature list rows)
        importSmallMolecules(newPeakList, mzTabFile, rawDataFiles);
        // Check if not canceled
        if (isCanceled())
            return;
        // Add the new feature list to the project
        project.addPeakList(newPeakList);
        // Finish
        setStatus(TaskStatus.FINISHED);
        finishedPercentage = 1.0;
    } catch (Exception e) {
        e.printStackTrace();
        setStatus(TaskStatus.ERROR);
        setErrorMessage("Could not import data from " + inputFile + ": " + e.getMessage());
        return;
    }
}
Also used : MZTabFile(uk.ac.ebi.pride.jmztab.model.MZTabFile) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) OutputStream(java.io.OutputStream) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) SimplePeakList(net.sf.mzmine.datamodel.impl.SimplePeakList) PeakList(net.sf.mzmine.datamodel.PeakList) MZTabFileParser(uk.ac.ebi.pride.jmztab.utils.MZTabFileParser)

Aggregations

SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)47 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)39 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)29 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)29 Feature (net.sf.mzmine.datamodel.Feature)25 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)25 DataPoint (net.sf.mzmine.datamodel.DataPoint)19 PeakList (net.sf.mzmine.datamodel.PeakList)18 PeakListAppliedMethod (net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod)14 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)14 ArrayList (java.util.ArrayList)11 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)10 PeakListRowSorter (net.sf.mzmine.util.PeakListRowSorter)10 Scan (net.sf.mzmine.datamodel.Scan)8 Vector (java.util.Vector)7 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)7 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)5 Desktop (net.sf.mzmine.desktop.Desktop)5 HeadLessDesktop (net.sf.mzmine.desktop.impl.HeadLessDesktop)5 SimpleIsotopePattern (net.sf.mzmine.datamodel.impl.SimpleIsotopePattern)4