public class SpectrumFactory extends Object
Modifier and Type | Field and Description |
---|---|
static long |
timeOut
The time out in milliseconds when querying the file.
|
Modifier and Type | Method and Description |
---|---|
void |
addIdNameMapping(String idName,
File spectrumFile)
Adds an id to spectrum name in the mapping.
|
void |
addSpectra(File spectrumFile)
Add spectra to the factory.
|
void |
addSpectra(File spectrumFile,
WaitingHandler waitingHandler)
Add spectra to the factory.
|
void |
clearFactory()
Clears the factory getInstance() needs to be called afterwards.
|
void |
closeFiles()
Closes all opened files.
|
void |
emptyCache()
Empties the cache.
|
boolean |
fileLoaded(String fileName)
Returns a boolean indicating whether the spectrum file has been loaded.
|
int |
getCacheSize()
Returns the spectrum cache size.
|
MgfIndex |
getIndex(File mgfIndex)
Deserializes the index of an mgf file.
|
static String |
getIndexName(String spectrumFileName)
Returns the name of an index file based on the given spectrum file name.
|
static SpectrumFactory |
getInstance()
Static method returning the instance of the factory.
|
static SpectrumFactory |
getInstance(int nCache)
Static method returning the instance of the factory with a new cache
size.
|
Integer |
getMaxCharge()
Returns the max precursor charge encountered among all loaded mgf files.
|
Integer |
getMaxCharge(String fileName)
Returns the max precursor charge encountered for the given mgf file.
|
Double |
getMaxIntensity()
Returns the maximum precursor intensity for the whole project.
|
Double |
getMaxIntensity(String fileName)
Returns the maximum precursor intensity for the desired file.
|
Double |
getMaxMz()
Returns the maximum m/z for the whole project.
|
Double |
getMaxMz(String fileName)
Returns the maximum m/z for the desired file.
|
Integer |
getMaxPeakCount()
Returns the max peak count encountered among all loaded mgf files.
|
Integer |
getMaxPeakCount(String fileName)
Returns the max peak count encountered for the given mgf file.
|
Double |
getMaxRT()
Returns the maximum retention time in seconds for the whole project.
|
Double |
getMaxRT(String fileName)
Returns the maximum retention time in seconds for the desired file.
|
File |
getMgfFileFromName(String fileName)
Returns the file associated to the given name.
|
ArrayList<String> |
getMgfFileNames()
Returns a list of loaded mgf files.
|
Double |
getMinRT()
Returns the minimum retention time in seconds for the whole project.
|
Double |
getMinRT(String fileName)
Returns the minimum retention time in seconds for the desired file.
|
ArrayList<String> |
getMzMLFileNames()
Returns a list of loaded mzML files.
|
int |
getNSpectra()
Returns the total number of spectra in all files.
|
int |
getNSpectra(String fileName)
Returns the number of spectra in the desired file.
|
Precursor |
getPrecursor(String spectrumKey)
Returns the precursor of the desired spectrum.
|
Precursor |
getPrecursor(String spectrumKey,
boolean save)
Returns the precursor of the desired spectrum.
|
Precursor |
getPrecursor(String fileName,
String spectrumTitle)
Returns the precursor of the desired spectrum.
|
Precursor |
getPrecursor(String fileName,
String spectrumTitle,
boolean save)
Returns the precursor of the desired spectrum.
|
double |
getPrecursorMz(String spectrumKey)
Returns the precursor mz of the desired spectrum.
|
Spectrum |
getSpectrum(String spectrumKey)
Returns the desired spectrum.
|
Spectrum |
getSpectrum(String spectrumFile,
String spectrumTitle)
Returns the desired spectrum.
|
File |
getSpectrumFileFromIdName(String idName)
Returns the spectrum file corresponding to the name of the file used for
identification
|
Integer |
getSpectrumIndex(String spectrumTitle,
String mgfFile)
Returns the spectrum index of the given spectrum in the given file.
|
String |
getSpectrumTitle(String mgfFile,
int spectrumNumber)
Returns the spectrum title of the spectrum of the given number in the
given file.
|
ArrayList<String> |
getSpectrumTitles(String mgfFile)
Returns a list of titles from indexed spectra in the given file.
|
void |
setCacheSize(int nCache)
Sets the spectrum cache size.
|
boolean |
spectrumLoaded(String spectrumKey)
A boolean indicating whether the spectrum is loaded in the factory.
|
boolean |
spectrumLoaded(String fileName,
String spectrumTitle)
Returns a boolean indicating whether the spectrum is contained in the
given spectrum file.
|
void |
writeIndex(MgfIndex mgfIndex,
File directory)
Writes the given mgf file index in the given directory.
|
public static final long timeOut
public static SpectrumFactory getInstance()
public static SpectrumFactory getInstance(int nCache)
nCache
- the cache sizepublic void clearFactory()
public void emptyCache()
public void setCacheSize(int nCache)
nCache
- the new cache sizepublic int getCacheSize()
public void addSpectra(File spectrumFile) throws FileNotFoundException, IOException, ClassNotFoundException
spectrumFile
- The spectrum file, can be mgf or mzMLFileNotFoundException
- Exception thrown whenever the file was not
foundIOException
- Exception thrown whenever an error occurred while
reading the fileClassNotFoundException
- Exception thrown whenever an error
occurred while deserializing the index .cui file.public void addSpectra(File spectrumFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, IllegalArgumentException
spectrumFile
- The spectrum file, can be mgf or mzMLwaitingHandler
- the waiting handlerFileNotFoundException
- Exception thrown whenever the file was not
foundIOException
- Exception thrown whenever an error occurred while
reading the fileIllegalArgumentException
- Exception thrown if an unknown format
was detected.public static String getIndexName(String spectrumFileName)
spectrumFileName
- the name of the spectrum filepublic Precursor getPrecursor(String fileName, String spectrumTitle) throws IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
fileName
- the name of the spectrum filespectrumTitle
- the title of the spectrumIOException
- exception thrown whenever the file was not parsed
correctlyuk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever the file was
not parsed correctlypublic Precursor getPrecursor(String fileName, String spectrumTitle, boolean save) throws IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
fileName
- the name of the spectrum filespectrumTitle
- the title of the spectrumsave
- if true the precursor will be saved in cacheIOException
- exception thrown whenever the file was not parsed
correctlyuk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever the file was
not parsed correctlypublic Precursor getPrecursor(String spectrumKey) throws IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
spectrumKey
- the key of the spectrumIOException
- exception thrown whenever the file was not parsed
correctlyuk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever the file was
not parsed correctlypublic double getPrecursorMz(String spectrumKey) throws IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
spectrumKey
- the key of the spectrumIOException
- exception thrown whenever the file was not parsed
correctlyuk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever the file was
not parsed correctlypublic Double getMaxMz(String fileName)
fileName
- the file of interestpublic Double getMaxMz()
public Integer getMaxCharge(String fileName)
fileName
- the name of the mgf filepublic Integer getMaxCharge()
public Integer getMaxPeakCount(String fileName)
fileName
- the name of the mgf filepublic Integer getMaxPeakCount()
public Double getMaxIntensity(String fileName)
fileName
- the file of interestpublic Double getMaxIntensity()
public Double getMaxRT(String fileName)
fileName
- the file of interestpublic Double getMinRT(String fileName)
fileName
- the file of interestpublic Double getMaxRT()
public Double getMinRT()
public int getNSpectra(String fileName)
fileName
- the file of interestpublic int getNSpectra()
public Precursor getPrecursor(String spectrumKey, boolean save) throws IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException, IllegalArgumentException
spectrumKey
- the key of the spectrumsave
- boolean indicating whether the loaded precursor should be
stored in the factory. False by defaultIOException
- exception thrown whenever the file was not parsed
correctlyuk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever the file was
not parsed correctlyIllegalArgumentException
- exception thrown whenever the file was
not parsed correctlypublic boolean fileLoaded(String fileName)
fileName
- the file namepublic boolean spectrumLoaded(String fileName, String spectrumTitle)
fileName
- the name of the spectrum filespectrumTitle
- the title of the spectrumpublic boolean spectrumLoaded(String spectrumKey)
spectrumKey
- the spectrum keypublic Spectrum getSpectrum(String spectrumFile, String spectrumTitle) throws IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
spectrumFile
- name of the spectrum filespectrumTitle
- title of the spectrumIOException
- exception thrown whenever an error occurred while
reading the fileuk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever an error
occurred while parsing the mzML filepublic Spectrum getSpectrum(String spectrumKey) throws IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
spectrumKey
- key of the spectrumIOException
- exception thrown whenever an error occurred while
reading the fileIllegalArgumentException
- exception thrown whenever an error
occurred while parsing the fileuk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever an error
occurred while parsing the filepublic void writeIndex(MgfIndex mgfIndex, File directory) throws IOException
mgfIndex
- the mgf file indexdirectory
- the destination directoryIOException
- exception thrown whenever an error is encountered
while writing the filepublic MgfIndex getIndex(File mgfIndex) throws FileNotFoundException, IOException, ClassNotFoundException
mgfIndex
- the mgf index cui fileFileNotFoundException
- exception thrown whenever the file was not
foundIOException
- exception thrown whenever an error was encountered
while reading the fileClassNotFoundException
- exception thrown whenever an error
occurred while deserializing the objectpublic void closeFiles() throws IOException
IOException
- exception thrown whenever an error occurred while
closing the filespublic ArrayList<String> getMgfFileNames()
public ArrayList<String> getMzMLFileNames()
public ArrayList<String> getSpectrumTitles(String mgfFile)
mgfFile
- the name of the mgf filepublic Integer getSpectrumIndex(String spectrumTitle, String mgfFile)
spectrumTitle
- the spectrum titlemgfFile
- the name of the mgf filepublic String getSpectrumTitle(String mgfFile, int spectrumNumber)
mgfFile
- the name of the mgf file of interestspectrumNumber
- the number of the spectrum in the filepublic void addIdNameMapping(String idName, File spectrumFile)
idName
- name according to the id filespectrumFile
- the spectrum filepublic File getSpectrumFileFromIdName(String idName)
idName
- the name of the spectrum file according to the
identification fileCopyright © 2016. All rights reserved.