|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.compomics.util.experiment.massspectrometry.SpectrumFactory
public class SpectrumFactory
This factory will provide the spectra when needed.
Method Summary | |
---|---|
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 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. |
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. |
Double |
getMaxRT()
Returns the maximum RT for the whole project. |
Double |
getMaxRT(String fileName)
Returns the maximum RT for the desired file. |
ArrayList<String> |
getMgfFileNames()
Returns a list of loaded mgf files. |
Double |
getMinRT()
Returns the minimum RT for the whole project. |
Double |
getMinRT(String fileName)
Returns the minimum RT 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. |
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 |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
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(File spectrumFile) throws FileNotFoundException, IOException, ClassNotFoundException
spectrumFile
- The spectrum file, can be mgf or mzML
FileNotFoundException
- Exception thrown whenever the file was not
found
IOException
- Exception thrown whenever an error occurred while
reading the file
ClassNotFoundException
- 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 handler
FileNotFoundException
- Exception thrown whenever the file was not
found
IOException
- Exception thrown whenever an error occurred while
reading the file
IllegalArgumentException
- Exception thrown if an unknown format
was detected.public 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 spectrum
IOException
- exception thrown whenever the file was not parsed
correctly
uk.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, IllegalArgumentException
spectrumKey
- the key of the spectrum
IOException
- exception thrown whenever the file was not parsed
correctly
uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever the file was
not parsed correctly
IllegalArgumentException
- exception thrown whenever the file was
not parsed correctlypublic Double getMaxMz(String fileName)
fileName
- the file of interest
public Double getMaxMz()
public Double getMaxIntensity(String fileName)
fileName
- the file of interest
public Double getMaxIntensity()
public Double getMaxRT(String fileName)
fileName
- the file of interest
public Double getMinRT(String fileName)
fileName
- the file of interest
public Double getMaxRT()
public Double getMinRT()
public int getNSpectra(String fileName)
fileName
- the file of interest
public 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 default
IOException
- exception thrown whenever the file was not parsed
correctly
uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever the file was
not parsed correctly
IllegalArgumentException
- exception thrown whenever the file was
not parsed correctlypublic boolean fileLoaded(String fileName)
fileName
- the file name
public boolean spectrumLoaded(String fileName, String spectrumTitle)
fileName
- the name of the spectrum filespectrumTitle
- the title of the spectrum
public boolean spectrumLoaded(String spectrumKey)
spectrumKey
- the spectrum key
public Spectrum getSpectrum(String spectrumFile, String spectrumTitle) throws IOException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
spectrumFile
- name of the spectrum filespectrumTitle
- title of the spectrum
IOException
- exception thrown whenever an error occurred while
reading the file
uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
- exception thrown whenever an error
occurred while parsing the mzML filepublic Spectrum getSpectrum(String spectrumKey) throws IOException, IllegalArgumentException, uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException
spectrumKey
- key of the spectrum
IOException
- exception thrown whenever an error occurred while
reading the file
IllegalArgumentException
- exception thrown whenever an error
occurred while parsing the file
uk.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 directory
IOException
- exception thrown whenever an error is encountered
while writing the filepublic MgfIndex getIndex(File mgfIndex) throws FileNotFoundException, IOException, ClassNotFoundException
mgfIndex
- the mgf index cui file
FileNotFoundException
- exception thrown whenever the file was not
found
IOException
- exception thrown whenever an error was encountered
while reading the file
ClassNotFoundException
- 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 file
public 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 file
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |