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());
}
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;
}
Aggregations