public class MgfReader
extends java.lang.Object
Constructor and Description |
---|
MgfReader()
General constructor for an mgf reader.
|
Modifier and Type | Method and Description |
---|---|
static void |
fixDuplicateSpectrumTitles(java.io.File mgfFile,
WaitingHandler waitingHandler)
Fix duplicate spectrum titles.
|
static MgfIndex |
getIndexMap(java.io.File mgfFile)
Returns the index of all spectra in the given mgf file.
|
static MgfIndex |
getIndexMap(java.io.File mgfFile,
WaitingHandler waitingHandler)
Returns the index of all spectra in the given MGF file.
|
static Precursor |
getPrecursor(uk.ac.ebi.pride.tools.braf.BufferedRandomAccessFile bufferedRandomAccessFile,
java.lang.Long index,
java.lang.String fileName)
Returns the next precursor starting from the given index.
|
java.util.ArrayList<MSnSpectrum> |
getSpectra(java.io.File aFile)
Reads an MGF file and retrieves a list of spectra.
|
static MSnSpectrum |
getSpectrum(uk.ac.ebi.pride.tools.braf.BufferedRandomAccessFile bufferedRandomAccessFile,
long index,
java.lang.String fileName)
Returns the next spectrum starting from the given index.
|
java.util.ArrayList<MgfIndex> |
splitFile(java.io.File mgfFile,
int nSpectra,
WaitingHandler waitingHandler)
Splits an mgf file into smaller ones and returns the indexes of the
generated files.
|
static java.lang.String |
validateSpectrumTitles(java.io.File mgfFile,
WaitingHandler waitingHandler)
Validates the spectrum titles, i.e., check for duplicate titles.
|
static void |
writeAplFile(java.io.File mgfFile,
java.io.File aplFile,
java.lang.String fragmentation)
Writes an apl file from an MGF file.
|
public java.util.ArrayList<MSnSpectrum> getSpectra(java.io.File aFile) throws java.io.FileNotFoundException, java.io.IOException, java.lang.IllegalArgumentException
aFile
- the mgf filejava.io.FileNotFoundException
- Exception thrown if a problem is
encountered reading the filejava.io.IOException
- Exception thrown if a problem is encountered reading
the filejava.lang.IllegalArgumentException
- thrown when a parameter in the file
cannot be parsed correctlypublic static MgfIndex getIndexMap(java.io.File mgfFile) throws java.io.FileNotFoundException, java.io.IOException
mgfFile
- the given mgf filejava.io.FileNotFoundException
- Exception thrown whenever the file is not
foundjava.io.IOException
- Exception thrown whenever an error occurs while
reading the filepublic static MgfIndex getIndexMap(java.io.File mgfFile, WaitingHandler waitingHandler) throws java.io.FileNotFoundException, java.io.IOException
mgfFile
- the given MGF filewaitingHandler
- a waitingHandler showing the progressjava.io.FileNotFoundException
- Exception thrown whenever the file is not
foundjava.io.IOException
- Exception thrown whenever an error occurs while
reading the filepublic static java.lang.String validateSpectrumTitles(java.io.File mgfFile, WaitingHandler waitingHandler) throws java.io.FileNotFoundException, java.io.IOException
mgfFile
- the MGF file to validatewaitingHandler
- a waitingHandler showing the progressjava.io.FileNotFoundException
- Exception thrown whenever the file is not
foundjava.io.IOException
- Exception thrown whenever an error occurs while
reading the filepublic static void fixDuplicateSpectrumTitles(java.io.File mgfFile, WaitingHandler waitingHandler) throws java.io.FileNotFoundException, java.io.IOException, java.io.UnsupportedEncodingException
mgfFile
- the MGF file to validatewaitingHandler
- a waitingHandler showing the progressjava.io.FileNotFoundException
- Exception thrown whenever the file is not
foundjava.io.IOException
- Exception thrown whenever an error occurs while
reading the filejava.io.UnsupportedEncodingException
- if the decoding of a spectrum title
failspublic java.util.ArrayList<MgfIndex> splitFile(java.io.File mgfFile, int nSpectra, WaitingHandler waitingHandler) throws java.io.FileNotFoundException, java.io.IOException
mgfFile
- the mgf file to splitnSpectra
- the number of spectra allowed in the smaller fileswaitingHandler
- the waitingHandler showing the progressjava.io.FileNotFoundException
- exception thrown whenever a file was not
foundjava.io.IOException
- exception thrown whenever a problem occurred while
reading/writing a filepublic static MSnSpectrum getSpectrum(uk.ac.ebi.pride.tools.braf.BufferedRandomAccessFile bufferedRandomAccessFile, long index, java.lang.String fileName) throws java.io.IOException, java.lang.IllegalArgumentException
bufferedRandomAccessFile
- The random access file of the inspected
mgf fileindex
- The index where to start looking for the spectrumfileName
- The name of the MGF file (java.io.IOException
- Exception thrown whenever an error is encountered
while reading the spectrumjava.lang.IllegalArgumentException
- Exception thrown whenever the file is
not of a compatible formatpublic static Precursor getPrecursor(uk.ac.ebi.pride.tools.braf.BufferedRandomAccessFile bufferedRandomAccessFile, java.lang.Long index, java.lang.String fileName) throws java.io.IOException, java.lang.IllegalArgumentException
bufferedRandomAccessFile
- The random access file of the inspected
mgf fileindex
- The index where to start looking for the spectrumfileName
- The name of the mgf file (java.io.IOException
- Exception thrown whenever an error is encountered
while reading the spectrumjava.lang.IllegalArgumentException
- Exception thrown whenever the file is
not of a compatible formatpublic static void writeAplFile(java.io.File mgfFile, java.io.File aplFile, java.lang.String fragmentation) throws java.io.FileNotFoundException, java.io.IOException, java.lang.IllegalArgumentException
mgfFile
- the mgf fileaplFile
- the target apl filefragmentation
- the fragmentation method usedjava.io.FileNotFoundException
- exception thrown whenever a file was not
foundjava.io.IOException
- exception thrown whenever an error occurred while
reading/writing a filejava.lang.IllegalArgumentException
- exception thrown whenever the mgf file
is truncated in the middle of a spectrumCopyright © 2013. All Rights Reserved.