public class SpectrumFactory
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
addIdNameMapping(java.lang.String idName,
java.io.File spectrumFile)
Adds an id to spectrum name in the mapping.
|
void |
addSpectra(java.io.File spectrumFile)
Add spectra to the factory.
|
void |
addSpectra(java.io.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(java.lang.String fileName)
Returns a boolean indicating whether the spectrum file has been loaded.
|
int |
getCacheSize()
Returns the spectrum cache size.
|
MgfIndex |
getIndex(java.io.File mgfIndex)
Deserializes the index of an mgf file.
|
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.
|
java.lang.Integer |
getMaxCharge()
Returns the max precursor charge encountered among all loaded mgf files.
|
java.lang.Integer |
getMaxCharge(java.lang.String fileName)
Returns the max precursor charge encountered for the given mgf file.
|
java.lang.Double |
getMaxIntensity()
Returns the maximum precursor intensity for the whole project.
|
java.lang.Double |
getMaxIntensity(java.lang.String fileName)
Returns the maximum precursor intensity for the desired file.
|
java.lang.Double |
getMaxMz()
Returns the maximum m/z for the whole project.
|
java.lang.Double |
getMaxMz(java.lang.String fileName)
Returns the maximum m/z for the desired file.
|
java.lang.Double |
getMaxRT()
Returns the maximum RT for the whole project.
|
java.lang.Double |
getMaxRT(java.lang.String fileName)
Returns the maximum RT for the desired file.
|
java.util.ArrayList<java.lang.String> |
getMgfFileNames()
Returns a list of loaded mgf files.
|
java.lang.Double |
getMinRT()
Returns the minimum RT for the whole project.
|
java.lang.Double |
getMinRT(java.lang.String fileName)
Returns the minimum RT for the desired file.
|
java.util.ArrayList<java.lang.String> |
getMzMLFileNames()
Returns a list of loaded mzML files.
|
int |
getNSpectra()
Returns the total number of spectra in all files.
|
int |
getNSpectra(java.lang.String fileName)
Returns the number of spectra in the desired file.
|
Precursor |
getPrecursor(java.lang.String spectrumKey)
Returns the precursor of the desired spectrum.
|
Precursor |
getPrecursor(java.lang.String spectrumKey,
boolean save)
Returns the precursor of the desired spectrum.
|
Precursor |
getPrecursor(java.lang.String fileName,
java.lang.String spectrumTitle)
Returns the precursor of the desired spectrum.
|
Spectrum |
getSpectrum(java.lang.String spectrumKey)
Returns the desired spectrum.
|
Spectrum |
getSpectrum(java.lang.String spectrumFile,
java.lang.String spectrumTitle)
Returns the desired spectrum.
|
java.io.File |
getSpectrumFileFromIdName(java.lang.String idName)
Returns the spectrum file corresponding to the name of the file used for
identification
|
java.util.ArrayList<java.lang.String> |
getSpectrumTitles(java.lang.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(java.lang.String spectrumKey)
A boolean indicating whether the spectrum is loaded in the factory.
|
boolean |
spectrumLoaded(java.lang.String fileName,
java.lang.String spectrumTitle)
Returns a boolean indicating whether the spectrum is contained in the
given spectrum file.
|
void |
writeIndex(MgfIndex mgfIndex,
java.io.File directory)
Writes the given mgf file index in the given directory.
|
public static SpectrumFactory getInstance()
public static SpectrumFactory getInstance(int nCache)
nCache
- public void clearFactory()
public void emptyCache()
public void setCacheSize(int nCache)
nCache
- the new cache sizepublic int getCacheSize()
public void addSpectra(java.io.File spectrumFile) throws java.io.FileNotFoundException, java.io.IOException, java.lang.ClassNotFoundException
spectrumFile
- The spectrum file, can be mgf or mzMLjava.io.FileNotFoundException
- Exception thrown whenever the file was not
foundjava.io.IOException
- Exception thrown whenever an error occurred while
reading the filejava.lang.ClassNotFoundException
- Exception thrown whenever an error
occurred while deserializing the index .cui file.public void addSpectra(java.io.File spectrumFile, WaitingHandler waitingHandler) throws java.io.FileNotFoundException, java.io.IOException, java.lang.IllegalArgumentException
spectrumFile
- The spectrum file, can be mgf or mzMLwaitingHandler
- the waiting handlerjava.io.FileNotFoundException
- Exception thrown whenever the file was not
foundjava.io.IOException
- Exception thrown whenever an error occurred while
reading the filejava.lang.IllegalArgumentException
- Exception thrown if an unknown format
was detected.public Precursor getPrecursor(java.lang.String fileName, java.lang.String spectrumTitle) throws java.io.IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
fileName
- the name of the spectrum filespectrumTitle
- the title of the spectrumjava.io.IOException
- 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(java.lang.String spectrumKey) throws java.io.IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException, java.lang.IllegalArgumentException
spectrumKey
- the key of the spectrumjava.io.IOException
- exception thrown whenever the file was not parsed
correctlyuk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever the file was
not parsed correctlyjava.lang.IllegalArgumentException
- exception thrown whenever the file was
not parsed correctlypublic java.lang.Double getMaxMz(java.lang.String fileName)
fileName
- the file of interestpublic java.lang.Double getMaxMz()
public java.lang.Integer getMaxCharge(java.lang.String fileName)
fileName
- the name of the mgf filepublic java.lang.Integer getMaxCharge()
public java.lang.Double getMaxIntensity(java.lang.String fileName)
fileName
- the file of interestpublic java.lang.Double getMaxIntensity()
public java.lang.Double getMaxRT(java.lang.String fileName)
fileName
- the file of interestpublic java.lang.Double getMinRT(java.lang.String fileName)
fileName
- the file of interestpublic java.lang.Double getMaxRT()
public java.lang.Double getMinRT()
public int getNSpectra(java.lang.String fileName)
fileName
- the file of interestpublic int getNSpectra()
public Precursor getPrecursor(java.lang.String spectrumKey, boolean save) throws java.io.IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException, java.lang.IllegalArgumentException
spectrumKey
- the key of the spectrumsave
- boolean indicating whether the loaded precursor should be
stored in the factory. False by defaultjava.io.IOException
- exception thrown whenever the file was not parsed
correctlyuk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever the file was
not parsed correctlyjava.lang.IllegalArgumentException
- exception thrown whenever the file was
not parsed correctlypublic boolean fileLoaded(java.lang.String fileName)
fileName
- the file namepublic boolean spectrumLoaded(java.lang.String fileName, java.lang.String spectrumTitle)
fileName
- the name of the spectrum filespectrumTitle
- the title of the spectrumpublic boolean spectrumLoaded(java.lang.String spectrumKey)
spectrumKey
- the spectrum keypublic Spectrum getSpectrum(java.lang.String spectrumFile, java.lang.String spectrumTitle) throws java.io.IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
spectrumFile
- name of the spectrum filespectrumTitle
- title of the spectrumjava.io.IOException
- 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(java.lang.String spectrumKey) throws java.io.IOException, java.lang.IllegalArgumentException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
spectrumKey
- key of the spectrumjava.io.IOException
- exception thrown whenever an error occurred while
reading the filejava.lang.IllegalArgumentException
- 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, java.io.File directory) throws java.io.IOException
mgfIndex
- the mgf file indexdirectory
- the destination directoryjava.io.IOException
- exception thrown whenever an error is encountered
while writing the filepublic MgfIndex getIndex(java.io.File mgfIndex) throws java.io.FileNotFoundException, java.io.IOException, java.lang.ClassNotFoundException
mgfIndex
- the mgf index cui filejava.io.FileNotFoundException
- exception thrown whenever the file was not
foundjava.io.IOException
- exception thrown whenever an error was encountered
while reading the filejava.lang.ClassNotFoundException
- exception thrown whenever an error
occurred while deserializing the objectpublic void closeFiles() throws java.io.IOException
java.io.IOException
- exception thrown whenever an error occurred while
closing the filespublic java.util.ArrayList<java.lang.String> getMgfFileNames()
public java.util.ArrayList<java.lang.String> getMzMLFileNames()
public java.util.ArrayList<java.lang.String> getSpectrumTitles(java.lang.String mgfFile)
mgfFile
- the name of the mgf filepublic void addIdNameMapping(java.lang.String idName, java.io.File spectrumFile)
idName
- name according to the id filespectrumFile
- the spectrum filepublic java.io.File getSpectrumFileFromIdName(java.lang.String idName)
idName
- the name of the spectrum file according to the
identification fileCopyright © 2013. All Rights Reserved.