java.lang.Object
com.compomics.util.experiment.personalization.ExperimentObject
com.compomics.util.experiment.mass_spectrometry.spectra.Spectrum
All Implemented Interfaces:
Serializable

public class Spectrum
extends ExperimentObject
This class models a spectrum. Note: throughout the code, it is assumed that the m/z array is sorted by ascending m/z. Only minimal sanity check is conducted.
Author:
Marc Vaudel, Harald Barsnes
See Also:
Serialized Form
  • Field Details

    • precursor

      public Precursor precursor
      The precursor if any.
    • mz

      public double[] mz
      The array of the m/z of the peaks. Note: throughout the code, it is assumed that the m/z array is sorted by ascending m/z. Only minimal sanity check is conducted.
    • intensity

      public double[] intensity
      The array of the intensities of the peaks.
  • Constructor Details

    • Spectrum

      public Spectrum()
      Empty default constructor.
    • Spectrum

      public Spectrum​(Precursor precursor, double[] mz, double[] intensities)
      Constructor. Note: throughout the code, it is assumed that the m/z array is sorted by ascending m/z. Only minimal sanity check is conducted.
      Parameters:
      precursor - The precursor.
      mz - The array of mz of the peaks.
      intensities - The array of intensities of the peaks.
  • Method Details

    • getPeakListAsString

      public String getPeakListAsString()
      Returns the peak list as an array list formatted as text, e.g. [[303.17334 3181.14],[318.14542 37971.93], ... ].
      Returns:
      the peak list as an array list formatted as text
    • getTotalIntensity

      public double getTotalIntensity()
      Returns the total intensity of the spectrum.
      Returns:
      the total intensity. 0 if no peak.
    • getMaxIntensity

      public double getMaxIntensity()
      Returns the max intensity value.
      Returns:
      the max intensity value. 0 if no peak.
    • getMaxMz

      public double getMaxMz()
      Returns the max mz value.
      Returns:
      the max mz value
    • getMinMz

      public double getMinMz()
      Returns the min mz value.
      Returns:
      the min mz value
    • getPrecursor

      public Precursor getPrecursor()
      Returns the precursor. Null if none.
      Returns:
      The precursor.
    • getNPeaks

      public int getNPeaks()
      Returns the number of peaks.
      Returns:
      the number of peaks
    • isSameAs

      public boolean isSameAs​(Spectrum otherSpectrum)
      Returns a boolean indicating whether the spectrum is identical to the other spectrum. Precursors are compared using the isSameAs method. M/z and intensities must be in the same order with exact same double values.
      Parameters:
      otherSpectrum - The other spectrum.
      Returns:
      A boolean indicating whether the spectrum is identical to the other spectrum.
    • toString

      public String toString()
      Overrides:
      toString in class Object