Class SpectrumAnnotator
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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SpectrumAnnotator.TiesResolution
Enum of the possibilities for ties resolution when multiple peaks can be annotated. -
Field Summary
Fields Modifier and Type Field Description protected HashSet<Integer>
defaultPrecursorCharges
The precursor charges to inspect by default.protected IonFactory
fragmentFactory
The Fragment factory which will generate the fragment ions.protected double
intensityLimit
The intensity limit to use.protected IonMatchKeysCache
ionMatchKeysCache
The cache to use for the ion match keys.protected boolean
isPpm
Boolean indicating whether the tolerance is in ppm (true) or in Dalton (false).protected double
massShift
m/z shift applied to all theoretic peaks.protected double
massShiftCTerm
C-terminal m/z shift applied to all reverse ions.protected double
massShiftNTerm
N-terminal m/z shift applied to all forward ions.protected static Integer
MAX_ISOTOPIC_CORRRECTION
The maximal isotope correction.protected static Integer
MIN_ISOTOPIC_CORRRECTION
The minimum isotope correction.protected double
mzTolerance
The m/z tolerance for peak matching.protected int
precursorCharge
The precursor charge as deduced by the search engine.protected SpecificAnnotationParameters
specificAnnotationSettings
If provided, the annotator will only look for the ions included in the specific annotation settings.protected String
spectrumFile
The file of the currently loaded spectrum.protected String
spectrumTitle
The title of the currently loaded spectrum.protected static boolean
SUBTRACT_ISOTOPE
Minimal isotopic correction when matching an ion.protected HashMap<Integer,HashMap<Integer,ArrayList<Ion>>>
theoreticalFragmentIons
The theoretic fragment ions.protected SpectrumAnnotator.TiesResolution
tiesResolution
The methods to use to select the best peak when multiple are possible. -
Constructor Summary
Constructors Constructor Description SpectrumAnnotator()
Empty default constructor -
Method Summary
Modifier and Type Method Description boolean
chargeValidated(Ion theoreticIon, int charge, int precursorCharge)
Returns a boolean indicating whether the given charge can be found on the given fragment ion.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.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.String
getCurrentlyLoadedSpectrumFile()
Returns the file of the spectrum currently inspected.String
getCurrentlyLoadedSpectrumTitle()
Returns the title of the spectrum currently inspected.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.protected HashMap<Integer,ArrayList<Ion>>
getExpectedIons(SpecificAnnotationParameters specificAnnotationSettings)
Returns the expected ions in a map indexed by the possible charges.double
getMassShift()
Returns the m/z shift applied to the fragment ions.double
getMassShiftCTerm()
Returns the C-terminal m/z shift applied to all reverse ions.double
getMassShiftNTerm()
Returns the N-terminal m/z shift applied to all forward ions.static Vector<SpectrumAnnotation>
getSpectrumAnnotation(IonMatch[] ionMatches)
Translates the list of ion matches into a vector of annotations which can be read by the SpectrumPanel.boolean
isAccounted(NeutralLossesMap neutralLosses, NeutralLoss neutralLoss, Ion ion)
Returns a boolean indicating whether the neutral loss should be accounted for.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.protected IonMatch
matchInSpectrum(double[] spectrumMz, double[] spectrumIntensity, Ion theoreticIon, Integer inspectedCharge)
Matches a theoretic ion in the spectrum.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.static ArrayList<IonMatch>
matchReporterIon(Ion theoreticIon, int charge, Spectrum spectrum, double massTolerance)
Convenience method to match a reporter ion in a spectrum.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.void
setMassShift(double massShift)
Sets an m/z shift on all ions.void
setMassShifts(double massShift, double massShiftNTerm, double massShiftCTerm)
Sets the m/z shifts.protected void
setMassTolerance(double mzTolerance, boolean isPpm, SpectrumAnnotator.TiesResolution tiesResolution)
Sets a new m/z tolerance for peak matching.protected void
setSpectrum(String spectrumFile, String spectrumTitle, Spectrum spectrum, double intensityLimit)
Sets a new spectrum to annotate.void
setTerminalMassShifts(double massShiftNTerm, double massShiftCTerm)
Sets the terminal m/z shifts.protected void
updateMassShifts()
Updates the mass shifts.
-
Field Details
-
precursorCharge
protected int precursorChargeThe precursor charge as deduced by the search engine. -
defaultPrecursorCharges
The precursor charges to inspect by default. -
theoreticalFragmentIons
The theoretic fragment ions. -
fragmentFactory
The Fragment factory which will generate the fragment ions. -
spectrumFile
The file of the currently loaded spectrum. -
spectrumTitle
The title of the currently loaded spectrum. -
intensityLimit
protected double intensityLimitThe intensity limit to use. -
mzTolerance
protected double mzToleranceThe m/z tolerance for peak matching. -
isPpm
protected boolean isPpmBoolean indicating whether the tolerance is in ppm (true) or in Dalton (false). -
SUBTRACT_ISOTOPE
protected static final boolean SUBTRACT_ISOTOPEMinimal isotopic correction when matching an ion.- See Also:
- Constant Field Values
-
MIN_ISOTOPIC_CORRRECTION
The minimum isotope correction. By default only the monoisotopic peak is annotated (min=0). -
MAX_ISOTOPIC_CORRRECTION
The maximal isotope correction. By default only the monoisotopic peak is annotated (max=0). -
massShift
protected double massShiftm/z shift applied to all theoretic peaks. -
massShiftNTerm
protected double massShiftNTermN-terminal m/z shift applied to all forward ions. -
massShiftCTerm
protected double massShiftCTermC-terminal m/z shift applied to all reverse ions. -
tiesResolution
The methods to use to select the best peak when multiple are possible. -
specificAnnotationSettings
If provided, the annotator will only look for the ions included in the specific annotation settings. -
ionMatchKeysCache
The cache to use for the ion match keys.
-
-
Constructor Details
-
SpectrumAnnotator
public SpectrumAnnotator()Empty default constructor
-
-
Method Details
-
getSpectrumAnnotation
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 spectrumspectrumIntensity
- the intensity array of the spectrumtheoreticIon
- the theoretic ioninspectedCharge
- 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 inspectintensityLimit
- 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 DatiesResolution
- the method used to resolve ties
-
isAccounted
Returns a boolean indicating whether the neutral loss should be accounted for.- Parameters:
neutralLosses
- map of expected neutral lossesneutralLoss
- the neutral loss of interestion
- the fragment ion of interest- Returns:
- boolean indicating whether the neutral loss should be considered
-
lossesValidated
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 losstheoreticIon
- 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
Returns a boolean indicating whether the given charge can be found on the given fragment ion.- Parameters:
theoreticIon
- the ion of interestcharge
- the candidate chargeprecursorCharge
- 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 annotatespectrumTitle
- the title of the spectrum to annotatespectrum
- the spectrum of interestannotationSettings
- the annotation settingsspecificAnnotationSettings
- the specific annotation settingsmodificationParameters
- the modification parameters the modification parameterssequenceProvider
- a protein sequence providermodificationsSequenceMatchingParameters
- 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 annotatespectrumTitle
- the title of the spectrum to annotatespectrum
- the spectrum to annotateannotationSettings
- the annotation settingsspecificAnnotationSettings
- the specific annotation settingsmodificationParameters
- the modification parameters the modification parameterssequenceProvider
- a protein sequence providermodificationsSequenceMatchingParameters
- the sequence matching parameters to use for modificationsuseIntensityFilter
- boolean indicating whether intensity filters should be used- Returns:
- the currently matched ions with the given settings
-
getCurrentlyLoadedSpectrumFile
Returns the file of the spectrum currently inspected.- Returns:
- the file of the spectrum currently inspected
-
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 applymassShiftNTerm
- the n-terminal mass shift to apply to all forward ionsmassShiftCTerm
- 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 ionsmassShiftCTerm
- 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 interestmodificationParameters
- the modification parameters the modification parameterssequenceProvider
- a protein sequence providermodificationsSequenceMatchingParameters
- the sequence matching parameters to use for modificationsspectrumAnnotator
- 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 forcharge
- the charge of the ionspectrum
- the spectrummassTolerance
- the mass tolerance to use- Returns:
- a list of all the ion matches
-