private boolean spectrumHasPeaks(double mass, Edge[] edges, double direction) { Envelope envelope = spectrum.getClosest(mass); if (MassUtil.compare(envelope.getMass(), mass, MassUtil.ERROR_THRESHOLD * 4) != 0) { return false; } for (Edge edge : edges) { mass += edge.getMass() * direction; envelope = spectrum.getClosest(mass); if (MassUtil.compare(mass, envelope.getMass(), MassUtil.ERROR_THRESHOLD * 4) != 0) { return false; } mass = envelope.getMass(); } return true; }
private boolean checkDirection(Spectrum spectrum, double mass, Edge[] edges, double direction) { for (Edge edge : edges) { double needMass = mass + edge.getMass() * direction; Envelope nextEnvelope = spectrum.getClosest(needMass); if (MassUtil.compare(needMass, nextEnvelope.getMass(), 40e-6 * needMass) != 0) { return false; } mass = nextEnvelope.getMass(); } return true; }