Class MgfIndex
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:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description MgfIndex()
Empty default constructorMgfIndex(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.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. -
Method Summary
Modifier and Type Method Description boolean
containsSpectrum(String spectrumTitle)
Returns a boolean indicating whether the spectrum title is implemented in this index.HashMap<String,Integer>
getDuplicatedSpectrumTitles()
Returns a map of the duplicated spectrum titles, can be null.String
getFileName()
Returns the name of the indexed file.Long
getIndex(String spectrumTitle)
Returns the index corresponding to the desired spectrum.Long
getLastModified()
Returns when the file was last modified.Integer
getMaxCharge()
Returns the maximal charge found in the mgf file.Double
getMaxIntensity()
Returns the maximum precursor intensity in this file.Double
getMaxMz()
Returns the maximum m/z in this file.Integer
getMaxPeakCount()
Returns the maximum peak count in this file.Double
getMaxRT()
Returns the maximal RT in this file.Double
getMinRT()
Returns the minimum RT in this file.int
getNSpectra()
Returns the number of imported spectra.Double
getPrecursorMz(int spectrumIndex)
Returns the precursor mz for the spectrum at the given index.static Spectrum
getSpectrum(uk.ac.ebi.pride.tools.braf.BufferedRandomAccessFile bufferedRandomAccessFile, long index)
Returns the next spectrum starting from the given index.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.String
getSpectrumTitle(int number)
Returns the spectrum title corresponding to the given spectrum number.ArrayList<String>
getSpectrumTitles()
Returns an ordered list of all spectrum titles.Boolean
isPeakPicked()
Returns true if the indexed file seems to contain only peak picked spectra.Boolean
isPrecursorChargesMissing()
Returns true if the at least one spectrum is missing the precursor charge.void
setMaxCharge(Integer maxCharge)
Sets the maximum charge in this file.void
setMaxIntensity(Double maxIntensity)
Sets the maximum precursor intensity in this file.void
setMaxMz(Double maxMz)
Sets the maximum m/z in this file.void
setMaxPeakCount(Integer maxPeakCount)
Sets the maximum peak count in this file.void
setMaxRT(Double maxRT)
Sets the maximal RT in this file.void
setMinRT(Double minRT)
Sets the minimum RT in this file.void
setPeakPicked(Boolean peakPicked)
Set if the indexed file seems to contain only peak picked spectra or not.void
setPrecursorChargesMissing(Boolean precursorChargesMissing)
Set if at least one spectrum is missing the precursor charge.Methods inherited from class com.compomics.util.experiment.personalization.ExperimentObject
addUrParam, asLong, clearParametersMap, getId, getUrParam, getUrParams, removeUrParam, setId, setUrParams
-
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 titlesindexMap
- map of all indexes: spectrum title > index in the filespectrumNumberIndexMap
- map of all spectrum index: spectrum title > spectrum index in the fileprecursorMzMap
- map of the precursor mz values: spectrum index > precursor mzfileName
- the mgf file namemaxRT
- the maximum retention timeminRT
- the minimum retention tomemaxMz
- the maximum m/z valuemaxIntensity
- the maximum precursor intensitymaxCharge
- the maximum peak precursor chargemaxPeakCount
- the maximum peak countpeakPicked
- indicates if the spectra seem to be peak picked or notprecursorChargesMissing
- indicates if at least one spectrum is missing the precursor charge taglastModified
- 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 titlesduplicatedSpectrumTitles
- a map of duplicated spectrum titles, and how often each title is duplicatedindexMap
- map of all indexes: spectrum title > index in the filespectrumNumberIndexMap
- map of all spectrum index: spectrum title > spectrum index in the fileprecursorMzMap
- map of the precursor mz values: spectrum index > precursor mzfileName
- the mgf file namemaxRT
- the maximum retention timeminRT
- the minimum retention tomemaxMz
- the maximum m/z valuemaxIntensity
- the maximum precursor intensitymaxCharge
- the maximum peak precursor chargemaxPeakCount
- the maximum peak countpeakPicked
- indicates if the spectra seem to be peak picked or notprecursorChargesMissing
- indicates if at least one spectrum is missing the precursor charge taglastModified
- a long indicating the last time the indexed file was modifiedspectrumCount
- the number of spectra in the file counted by the number of begin ion tags
-
-
Method Details
-
getIndex
Returns the index corresponding to the desired spectrum.- Parameters:
spectrumTitle
- the desired spectrum- Returns:
- the corresponding index
-
getSpectrumIndex
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
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
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
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
Returns an ordered list of all spectrum titles.- Returns:
- an ordered list of all spectrum titles
-
getDuplicatedSpectrumTitles
Returns a map of the duplicated spectrum titles, can be null.- Returns:
- a map of the duplicated spectrum titles, can be null
-
getFileName
Returns the name of the indexed file.- Returns:
- the name of the indexed file
-
getMaxRT
Returns the maximal RT in this file.- Returns:
- the maximal RT in this file
-
setMaxRT
Sets the maximal RT in this file.- Parameters:
maxRT
- the maximal RT in this file
-
getMaxMz
Returns the maximum m/z in this file.- Returns:
- the maximum m/z in this file
-
setMaxCharge
Sets the maximum charge in this file.- Parameters:
maxCharge
- the maximum charge in this file
-
getMaxCharge
Returns the maximal charge found in the mgf file.- Returns:
- the maximal charge found in the mgf file
-
setMaxMz
Sets the maximum m/z in this file.- Parameters:
maxMz
- the maximum m/z in this file
-
getMaxIntensity
Returns the maximum precursor intensity in this file.- Returns:
- the maximum precursor intensity in this file
-
setMaxIntensity
Sets the maximum precursor intensity in this file.- Parameters:
maxIntensity
- the maximum precursor intensity in this file
-
getMinRT
Returns the minimum RT in this file.- Returns:
- the minimum RT in this file
-
setMinRT
Sets the minimum RT in this file.- Parameters:
minRT
- the minimum RT in this file
-
getMaxPeakCount
Returns the maximum peak count in this file.- Returns:
- the maximum peak count in this file
-
setMaxPeakCount
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
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
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
Set if the indexed file seems to contain only peak picked spectra or not.- Parameters:
peakPicked
- the peakPicked to set
-
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
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 IOExceptionReturns the next spectrum starting from the given index.- Parameters:
bufferedRandomAccessFile
- The random access file of the inspected mgf fileindex
- 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
-