java.lang.Object
com.compomics.util.experiment.personalization.ExperimentObject
com.compomics.util.experiment.io.mass_spectrometry.mgf.MgfIndex
All Implemented Interfaces:
Serializable

public class MgfIndex extends ExperimentObject implements Serializable
This class contains the indexes of an mgf file after indexing mapped with the title of the spectrum.
Author:
Marc Vaudel, Harald Barsnes
See Also:
  • Constructor Details

    • MgfIndex

      public MgfIndex()
      Empty default constructor
    • MgfIndex

      public MgfIndex(ArrayList<String> spectrumTitles, HashMap<String,Long> indexMap, HashMap<String,Integer> spectrumNumberIndexMap, HashMap<Integer,Double> precursorMzMap, String fileName, double minRT, double maxRT, double maxMz, double maxIntensity, int maxCharge, int maxPeakCount, boolean peakPicked, boolean precursorChargesMissing, long lastModified)
      Constructor.
      Parameters:
      spectrumTitles - an ordered list of all spectrum titles
      indexMap - map of all indexes: spectrum title > index in the file
      spectrumNumberIndexMap - map of all spectrum index: spectrum title > spectrum index in the file
      precursorMzMap - map of the precursor mz values: spectrum index > precursor mz
      fileName - the mgf file name
      minRT - the minimum retention tome
      maxRT - the maximum retention time
      maxMz - the maximum m/z value
      maxIntensity - the maximum precursor intensity
      maxCharge - the maximum peak precursor charge
      maxPeakCount - the maximum peak count
      peakPicked - indicates if the spectra seem to be peak picked or not
      precursorChargesMissing - indicates if at least one spectrum is missing the precursor charge tag
      lastModified - a long indicating the last time the indexed file was modified
    • MgfIndex

      public MgfIndex(ArrayList<String> spectrumTitles, HashMap<String,Integer> duplicatedSpectrumTitles, HashMap<String,Long> indexMap, HashMap<String,Integer> spectrumNumberIndexMap, HashMap<Integer,Double> precursorMzMap, String fileName, double minRT, double maxRT, double maxMz, double maxIntensity, int maxCharge, int maxPeakCount, boolean peakPicked, boolean precursorChargesMissing, long lastModified, int spectrumCount)
      Constructor.
      Parameters:
      spectrumTitles - an ordered list of all spectrum titles
      duplicatedSpectrumTitles - a map of duplicated spectrum titles, and how often each title is duplicated
      indexMap - map of all indexes: spectrum title > index in the file
      spectrumNumberIndexMap - map of all spectrum index: spectrum title > spectrum index in the file
      precursorMzMap - map of the precursor mz values: spectrum index > precursor mz
      fileName - the mgf file name
      minRT - the minimum retention tome
      maxRT - the maximum retention time
      maxMz - the maximum m/z value
      maxIntensity - the maximum precursor intensity
      maxCharge - the maximum peak precursor charge
      maxPeakCount - the maximum peak count
      peakPicked - indicates if the spectra seem to be peak picked or not
      precursorChargesMissing - indicates if at least one spectrum is missing the precursor charge tag
      lastModified - a long indicating the last time the indexed file was modified
      spectrumCount - the number of spectra in the file counted by the number of begin ion tags
  • Method Details

    • getIndex

      public Long getIndex(String spectrumTitle)
      Returns the index corresponding to the desired spectrum.
      Parameters:
      spectrumTitle - the desired spectrum
      Returns:
      the corresponding index
    • getSpectrumIndex

      public Integer getSpectrumIndex(String spectrumTitle)
      Returns the spectrum index corresponding to the desired spectrum, i.e., returns 0 for the first spectrum in the file, 1 for the second, etc. Null map is not set, and -1 if not found.
      Parameters:
      spectrumTitle - the desired spectrum
      Returns:
      the corresponding spectrum index
    • getPrecursorMz

      public Double getPrecursorMz(int spectrumIndex)
      Returns the precursor mz for the spectrum at the given index. Returns null if the map is not set, or the value cannot be found.
      Parameters:
      spectrumIndex - the index of the spectrum, 0 for the first spectrum in the file, 1 for the second, etc
      Returns:
      the precursor mz
    • getSpectrumTitle

      public String getSpectrumTitle(int number)
      Returns the spectrum title corresponding to the given spectrum number. 0 is the first spectrum.
      Parameters:
      number - the number of the spectrum
      Returns:
      the title of the spectrum of interest
    • containsSpectrum

      public boolean containsSpectrum(String spectrumTitle)
      Returns a boolean indicating whether the spectrum title is implemented in this index.
      Parameters:
      spectrumTitle - the spectrum title
      Returns:
      a boolean indicating whether the spectrum title is implemented in this index
    • getSpectrumTitles

      public ArrayList<String> getSpectrumTitles()
      Returns an ordered list of all spectrum titles.
      Returns:
      an ordered list of all spectrum titles
    • getDuplicatedSpectrumTitles

      public HashMap<String,Integer> getDuplicatedSpectrumTitles()
      Returns a map of the duplicated spectrum titles, can be null.
      Returns:
      a map of the duplicated spectrum titles, can be null
    • getFileName

      public String getFileName()
      Returns the name of the indexed file.
      Returns:
      the name of the indexed file
    • getMaxRT

      public Double getMaxRT()
      Returns the maximal RT in this file.
      Returns:
      the maximal RT in this file
    • setMaxRT

      public void setMaxRT(Double maxRT)
      Sets the maximal RT in this file.
      Parameters:
      maxRT - the maximal RT in this file
    • getMaxMz

      public Double getMaxMz()
      Returns the maximum m/z in this file.
      Returns:
      the maximum m/z in this file
    • setMaxCharge

      public void setMaxCharge(Integer maxCharge)
      Sets the maximum charge in this file.
      Parameters:
      maxCharge - the maximum charge in this file
    • getMaxCharge

      public Integer getMaxCharge()
      Returns the maximal charge found in the mgf file.
      Returns:
      the maximal charge found in the mgf file
    • setMaxMz

      public void setMaxMz(Double maxMz)
      Sets the maximum m/z in this file.
      Parameters:
      maxMz - the maximum m/z in this file
    • getMaxIntensity

      public Double getMaxIntensity()
      Returns the maximum precursor intensity in this file.
      Returns:
      the maximum precursor intensity in this file
    • setMaxIntensity

      public void setMaxIntensity(Double maxIntensity)
      Sets the maximum precursor intensity in this file.
      Parameters:
      maxIntensity - the maximum precursor intensity in this file
    • getMinRT

      public Double getMinRT()
      Returns the minimum RT in this file.
      Returns:
      the minimum RT in this file
    • setMinRT

      public void setMinRT(Double minRT)
      Sets the minimum RT in this file.
      Parameters:
      minRT - the minimum RT in this file
    • getMaxPeakCount

      public Integer getMaxPeakCount()
      Returns the maximum peak count in this file.
      Returns:
      the maximum peak count in this file
    • setMaxPeakCount

      public void setMaxPeakCount(Integer maxPeakCount)
      Sets the maximum peak count in this file.
      Parameters:
      maxPeakCount - the maximum peak count in this file
    • getNSpectra

      public int getNSpectra()
      Returns the number of imported spectra.
      Returns:
      the number of imported spectra
    • getLastModified

      public Long getLastModified()
      Returns when the file was last modified. Null if not set or for utilities versions older than 3.11.30.
      Returns:
      a long indicating when the file was last modified
    • isPeakPicked

      public Boolean isPeakPicked()
      Returns true if the indexed file seems to contain only peak picked spectra.
      Returns:
      true if the indexed file seems to contain only peak picked spectra
    • setPeakPicked

      public void setPeakPicked(Boolean peakPicked)
      Set if the indexed file seems to contain only peak picked spectra or not.
      Parameters:
      peakPicked - the peakPicked to set
    • isPrecursorChargesMissing

      public Boolean isPrecursorChargesMissing()
      Returns true if the at least one spectrum is missing the precursor charge.
      Returns:
      true if the at least one spectrum is missing the precursor charge
    • setPrecursorChargesMissing

      public void setPrecursorChargesMissing(Boolean precursorChargesMissing)
      Set if at least one spectrum is missing the precursor charge.
      Parameters:
      precursorChargesMissing - the precursorChargesMissing to set
    • getSpectrum

      public static Spectrum getSpectrum(uk.ac.ebi.pride.tools.braf.BufferedRandomAccessFile bufferedRandomAccessFile, long index) throws IOException
      Returns the next spectrum starting from the given index.
      Parameters:
      bufferedRandomAccessFile - The random access file of the inspected mgf file
      index - The index where to start looking for the spectrum
      Returns:
      The next spectrum encountered
      Throws:
      IOException - Exception thrown whenever an error is encountered while reading the spectrum