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; }
public Path getReversed() { return new Path( getReversedEdges(), score, MassUtil.convertIonsType(beginMass + getMass(), spectrum.parentMass), spectrum, !reversed); }
public boolean isMonoTag() { if (isMonoTag != null) { return isMonoTag; } Edge[] edges = getEdges(); Edge[] reversedEdges = getReversedEdges(); isMonoTag = spectrumHasPeaks(beginMass, edges, 1.) || spectrumHasPeaks( MassUtil.convertIonsType(beginMass + getMass(), spectrum.parentMass), edges, -1.); isMonoTag |= spectrumHasPeaks(beginMass, reversedEdges, 1.) || spectrumHasPeaks( MassUtil.convertIonsType(beginMass + getMass(), spectrum.parentMass), reversedEdges, -1.); return isMonoTag; }
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; }