Search in sources :

Example 31 with PeakIdentity

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

the class PeakUtils method copyPeakListRowProperties.

/**
 * Copies properties such as identification results and comments from the source row to the target
 * row.
 */
public static void copyPeakListRowProperties(PeakListRow source, PeakListRow target) {
    // Combine the comments
    String targetComment = target.getComment();
    if ((targetComment == null) || (targetComment.trim().length() == 0)) {
        targetComment = source.getComment();
    } else {
        if ((source.getComment() != null) && (source.getComment().trim().length() > 0))
            targetComment += "; " + source.getComment();
    }
    target.setComment(targetComment);
    // Copy all peak identities, if these are not already present
    for (PeakIdentity identity : source.getPeakIdentities()) {
        if (!containsIdentity(target, identity))
            target.addPeakIdentity(identity, false);
    }
    // Set the preferred identity
    target.setPreferredPeakIdentity(source.getPreferredPeakIdentity());
}
Also used : PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity)

Example 32 with PeakIdentity

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

the class PeakUtils method compareIdentities.

/**
 * Compares identities of two feature list rows. 1) if preferred identities are available, they
 * must be same 2) if no identities are available on both rows, return true 3) otherwise all
 * identities on both rows must be same
 *
 * @return True if identities match between rows
 */
public static boolean compareIdentities(PeakListRow row1, PeakListRow row2) {
    if ((row1 == null) || (row2 == null))
        return false;
    // If both have preferred identity available, then compare only those
    PeakIdentity row1PreferredIdentity = row1.getPreferredPeakIdentity();
    PeakIdentity row2PreferredIdentity = row2.getPreferredPeakIdentity();
    if ((row1PreferredIdentity != null) && (row2PreferredIdentity != null)) {
        if (row1PreferredIdentity.getName().equals(row2PreferredIdentity.getName()))
            return true;
        else
            return false;
    }
    // If no identities at all for both rows, then return true
    PeakIdentity[] row1Identities = row1.getPeakIdentities();
    PeakIdentity[] row2Identities = row2.getPeakIdentities();
    if ((row1Identities.length == 0) && (row2Identities.length == 0))
        return true;
    // a matching identity on the other row
    if (row1Identities.length != row2Identities.length)
        return false;
    boolean sameID = false;
    for (PeakIdentity row1Identity : row1Identities) {
        sameID = false;
        for (PeakIdentity row2Identity : row2Identities) {
            if (row1Identity.getName().equals(row2Identity.getName())) {
                sameID = true;
                break;
            }
        }
        if (!sameID)
            break;
    }
    return sameID;
}
Also used : PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity)

Aggregations

PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)32 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)19 Feature (net.sf.mzmine.datamodel.Feature)14 ArrayList (java.util.ArrayList)9 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)9 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)9 PeakList (net.sf.mzmine.datamodel.PeakList)8 HashMap (java.util.HashMap)7 SimplePeakIdentity (net.sf.mzmine.datamodel.impl.SimplePeakIdentity)7 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)7 DataPoint (net.sf.mzmine.datamodel.DataPoint)6 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)6 IOException (java.io.IOException)5 List (java.util.List)5 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)5 File (java.io.File)4 HashSet (java.util.HashSet)4 Scan (net.sf.mzmine.datamodel.Scan)4 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)4 Range (com.google.common.collect.Range)3