added recalc method to candidate
@@ -186,6 +186,42 @@ public class Candidate {
return false;
}
+ public double recalcRatingWithAvgIntensities(ArrayList<PeakListRow> pL, int parentindex, int candindex, IsotopePattern pattern, int peakNum, double[] avgIntensity)
+ {
+ double parentMZ = pL.get(parentindex).getAverageMZ();
+ double candMZ = pL.get(candindex).getAverageMZ();
+ DataPoint[] points = pattern.getDataPoints();
+ double mzDiff = points[peakNum].getMZ() - points[0].getMZ();
+
+ double tempRating = candMZ / (parentMZ + mzDiff);
+ double intensAcc = 0;
+
+ if(tempRating > 1.0) // 0.99 and 1.01 should be comparable
+ tempRating = 1 / tempRating;
+
+ intensAcc = calcIntensityAccuracy_Avg(avgIntensity[0], avgIntensity[peakNum], points[0], points[peakNum]);
+
+ if(intensAcc > 1.0) // 0.99 and 1.01 should be comparable
+ intensAcc = 1 / intensAcc;
+
+ if(intensAcc > 1.0 || intensAcc < 0.0 || tempRating > 1.0 || tempRating < 0.0)
+ {
+ Logger.debug("ERROR: tempRating or deviation > 1 or < 0.\ttempRating: " + tempRating + "\tintensAcc: " + intensAcc); // TODO: can you do this without creating a new logger?
+ return 0;
+ }
+
+ tempRating = intensAcc * tempRating;
+
+ rating = tempRating;
+ return rating;
+ }
+
+ private double calcIntensityAccuracy_Avg(double iParent, double iChild, DataPoint pParent, DataPoint pChild)
+ {
+ double idealIntensity = pChild.getIntensity() / pParent.getIntensity();
+ return idealIntensity * iParent / iChild ;
+ }
+
public double getRating()
{
return rating;
