private static void validateMass(ISpectrumPeak pSp, double pPeak, Set<Integer> goodMasses) { final double mass = pSp.getMassChargeRatio(); final int imass = asInt(mass); if (!goodMasses.contains(imass)) { // try one off if (goodMasses.contains(imass - 1)) { goodMasses.remove(imass - 1); return; } if (goodMasses.contains(imass + 1)) { goodMasses.remove(imass + 1); return; } } if (!goodMasses.contains(imass)) System.out.println("Missing mass " + imass); goodMasses.remove(imass); }
@Test public void testConditioning() { XTandemMain main = new XTandemMain( XTandemUtilities.getResourceStream("smallSample/tandem.params"), "smallSample/tandem.params"); main.loadScoringTest(); main.loadSpectra(); Scorer sa = main.getScoreRunner(); IScoredScan[] conditionedScans = sa.getScans(); final IScoredScan conditionedScan = conditionedScans[0]; SpectrumCondition sc = sa.getSpectrumCondition(); final IScoringAlgorithm alg = sa.getAlgorithm(); IMeasuredSpectrum scan = alg.conditionSpectrum(conditionedScan, sc); Set<Integer> goodMasses = buildMassSet(); final ISpectrumPeak[] sps = scan.getPeaks(); for (int i = 0; i < sps.length; i++) { ISpectrumPeak sp = sps[i]; validateMass(sp, peaks[2 * i], goodMasses); // validatePeak(sp,peaks[2 * i],peaks[2 * i + 1]); } Assert.assertEquals(goodMasses.size(), 0); XTandemUtilities.breakHere(); }
/** * these are the masses XTandem has * * @return */ public static Set<Integer> buildMassSet() { Set<Integer> holder = new HashSet<Integer>(); for (int i = 0; i < peaks.length; i += 2) { holder.add(asInt(peaks[i])); } return holder; }