java.lang.Object
com.compomics.util.experiment.identification.spectrum_annotation.SpectrumAnnotator
Direct Known Subclasses:
PeptideSpectrumAnnotator, TagSpectrumAnnotator

public abstract class SpectrumAnnotator
extends Object
The spectrum annotator annotates peaks in a spectrum.
Author:
Marc Vaudel, Harald Barsnes
  • Field Details

  • Constructor Details

  • Method Details

    • getSpectrumAnnotation

      public static Vector<SpectrumAnnotation> getSpectrumAnnotation​(IonMatch[] ionMatches)
      Translates the list of ion matches into a vector of annotations which can be read by the SpectrumPanel.
      Parameters:
      ionMatches - list of ion matches
      Returns:
      vector of default spectrum annotations
    • matchInSpectrum

      protected IonMatch matchInSpectrum​(double[] spectrumMz, double[] spectrumIntensity, Ion theoreticIon, Integer inspectedCharge)
      Matches a theoretic ion in the spectrum. Returns an IonMatch containing the ion and the peak. Null if not found.
      Parameters:
      spectrumMz - the m/z array of the spectrum
      spectrumIntensity - the intensity array of the spectrum
      theoreticIon - the theoretic ion
      inspectedCharge - the expected charge
      Returns:
      the IonMatch between the ion and the peak
    • setBestPeak

      protected IonMatch setBestPeak​(double[] spectrumMz, double[] spectrumIntensity, int[] matchedPeaksIndexes, IonMatch ionMatch)
      Returns the peak to retain of the matched peaks according to the ties resolution setting.
      Parameters:
      spectrumMz - The m/z array of the spectrum.
      spectrumIntensity - The intensity array of the spectrum.
      matchedPeaksIndexes - The indexes of the peaks matched.
      ionMatch - The ion match with the ion to be matched.
      Returns:
      The ion match with the peak information filled.
    • setSpectrum

      protected void setSpectrum​(String spectrumFile, String spectrumTitle, Spectrum spectrum, double intensityLimit)
      Sets a new spectrum to annotate.
      Parameters:
      spectrumFile - the file of the spectrum to annotate.
      spectrumTitle - the title of the spectrum to annotate.
      spectrum - the spectrum to inspect
      intensityLimit - the minimal intensity to account for
    • setMassTolerance

      protected void setMassTolerance​(double mzTolerance, boolean isPpm, SpectrumAnnotator.TiesResolution tiesResolution)
      Sets a new m/z tolerance for peak matching.
      Parameters:
      mzTolerance - the new m/z tolerance (in m/z, Th)
      isPpm - a boolean indicating whether the mass tolerance is in ppm or in Da
      tiesResolution - the method used to resolve ties
    • isAccounted

      public boolean isAccounted​(NeutralLossesMap neutralLosses, NeutralLoss neutralLoss, Ion ion)
      Returns a boolean indicating whether the neutral loss should be accounted for.
      Parameters:
      neutralLosses - map of expected neutral losses
      neutralLoss - the neutral loss of interest
      ion - the fragment ion of interest
      Returns:
      boolean indicating whether the neutral loss should be considered
    • lossesValidated

      public boolean lossesValidated​(NeutralLossesMap neutralLosses, Ion theoreticIon)
      Returns a boolean indicating whether the neutral losses of the given fragment ion fit the requirement of the given neutral losses map.
      Parameters:
      neutralLosses - map of expected neutral losses: neutral loss
      theoreticIon - the ion of interest
      Returns:
      a boolean indicating whether the neutral losses of the given fragment ion are fit the requirement of the given neutral losses map
    • chargeValidated

      public boolean chargeValidated​(Ion theoreticIon, int charge, int precursorCharge)
      Returns a boolean indicating whether the given charge can be found on the given fragment ion.
      Parameters:
      theoreticIon - the ion of interest
      charge - the candidate charge
      precursorCharge - the precursor charge
      Returns:
      a boolean indicating whether the given charge can be found on the given fragment ion
    • getCurrentAnnotation

      public IonMatch[] getCurrentAnnotation​(String spectrumFile, String spectrumTitle, Spectrum spectrum, AnnotationParameters annotationSettings, SpecificAnnotationParameters specificAnnotationSettings, ModificationParameters modificationParameters, SequenceProvider sequenceProvider, SequenceMatchingParameters modificationsSequenceMatchingParameters)
      Returns the currently matched ions with the given settings using the intensity filter.
      Parameters:
      spectrumFile - the file of the spectrum to annotate
      spectrumTitle - the title of the spectrum to annotate
      spectrum - the spectrum of interest
      annotationSettings - the annotation settings
      specificAnnotationSettings - the specific annotation settings
      modificationParameters - the modification parameters the modification parameters
      sequenceProvider - a protein sequence provider
      modificationsSequenceMatchingParameters - the sequence matching parameters to use for modifications
      Returns:
      the currently matched ions with the given settings
    • getCurrentAnnotation

      public abstract IonMatch[] getCurrentAnnotation​(String spectrumFile, String spectrumTitle, Spectrum spectrum, AnnotationParameters annotationSettings, SpecificAnnotationParameters specificAnnotationSettings, ModificationParameters modificationParameters, SequenceProvider sequenceProvider, SequenceMatchingParameters modificationsSequenceMatchingParameters, boolean useIntensityFilter)
      Returns the currently matched ions with the given settings.
      Parameters:
      spectrumFile - the file of the spectrum to annotate
      spectrumTitle - the title of the spectrum to annotate
      spectrum - the spectrum to annotate
      annotationSettings - the annotation settings
      specificAnnotationSettings - the specific annotation settings
      modificationParameters - the modification parameters the modification parameters
      sequenceProvider - a protein sequence provider
      modificationsSequenceMatchingParameters - the sequence matching parameters to use for modifications
      useIntensityFilter - boolean indicating whether intensity filters should be used
      Returns:
      the currently matched ions with the given settings
    • getCurrentlyLoadedSpectrumFile

      public String getCurrentlyLoadedSpectrumFile()
      Returns the file of the spectrum currently inspected.
      Returns:
      the file of the spectrum currently inspected
    • getCurrentlyLoadedSpectrumTitle

      public String getCurrentlyLoadedSpectrumTitle()
      Returns the title of the spectrum currently inspected.
      Returns:
      the title of the spectrum currently inspected
    • getMassShift

      public double getMassShift()
      Returns the m/z shift applied to the fragment ions.
      Returns:
      the m/z shift applied to the fragment ions
    • getMassShiftNTerm

      public double getMassShiftNTerm()
      Returns the N-terminal m/z shift applied to all forward ions.
      Returns:
      the N-terminal m/z shift applied to all forward ions
    • getMassShiftCTerm

      public double getMassShiftCTerm()
      Returns the C-terminal m/z shift applied to all reverse ions.
      Returns:
      the C-terminal m/z shift applied to all reverse ions
    • setMassShift

      public void setMassShift​(double massShift)
      Sets an m/z shift on all ions. The previous mass main shift will be removed.
      Parameters:
      massShift - the m/z shift to apply
    • setMassShifts

      public void setMassShifts​(double massShift, double massShiftNTerm, double massShiftCTerm)
      Sets the m/z shifts. The previous mass shifts will be removed.
      Parameters:
      massShift - the m/z shift to apply
      massShiftNTerm - the n-terminal mass shift to apply to all forward ions
      massShiftCTerm - the c-terminal mass shift to apply to all reverse ions
    • setTerminalMassShifts

      public void setTerminalMassShifts​(double massShiftNTerm, double massShiftCTerm)
      Sets the terminal m/z shifts.
      Parameters:
      massShiftNTerm - the n-terminal mass shift to apply to all forward ions
      massShiftCTerm - the c-terminal mass shift to apply to all reverse ions
    • updateMassShifts

      protected void updateMassShifts()
      Updates the mass shifts.
    • getDefaultLosses

      public static NeutralLossesMap getDefaultLosses​(SpectrumIdentificationAssumption spectrumIdentificationAssumption, ModificationParameters modificationParameters, SequenceProvider sequenceProvider, SequenceMatchingParameters modificationsSequenceMatchingParameters, SpectrumAnnotator spectrumAnnotator)
      Returns the possible neutral losses expected by default for a given peptide. /!\ this method will work only if the PTM found in the peptide are in the PTMFactory.
      Parameters:
      spectrumIdentificationAssumption - the spectrumIdentificationAssumption of interest
      modificationParameters - the modification parameters the modification parameters
      sequenceProvider - a protein sequence provider
      modificationsSequenceMatchingParameters - the sequence matching parameters to use for modifications
      spectrumAnnotator - the spectrum annotator
      Returns:
      the expected possible neutral losses
    • matchPeak

      protected ArrayList<IonMatch> matchPeak​(SpecificAnnotationParameters specificAnnotationSettings, double peakMz, double peakIntensity)
      This method matches the potential fragment ions of a given peptide with a given peak. Note: fragment ions need to be initiated by the SpectrumAnnotator extending class.
      Parameters:
      specificAnnotationSettings - The specific annotation settings.
      peakMz - The m/z of the peak to match.
      peakIntensity - The intensity of the peak to match.
      Returns:
      A list of potential ion matches
    • getExpectedIons

      protected HashMap<Integer,​ArrayList<Ion>> getExpectedIons​(SpecificAnnotationParameters specificAnnotationSettings)
      Returns the expected ions in a map indexed by the possible charges. Note that, except for +1 precursors, fragments ions will be expected to have a charge strictly smaller than the precursor ion charge. Note: fragment ions need to be initiated by the SpectrumAnnotator extending class.
      Parameters:
      specificAnnotationSettings - the specific annotation settings
      Returns:
      an ArrayList of IonMatch containing the ion matches with the given settings
    • matchReporterIon

      public static ArrayList<IonMatch> matchReporterIon​(Ion theoreticIon, int charge, Spectrum spectrum, double massTolerance)
      Convenience method to match a reporter ion in a spectrum. The charge is assumed to be 1.
      Parameters:
      theoreticIon - the theoretic ion to look for
      charge - the charge of the ion
      spectrum - the spectrum
      massTolerance - the mass tolerance to use
      Returns:
      a list of all the ion matches