public class MgfReader extends Object
Constructor and Description |
---|
MgfReader()
General constructor for an mgf reader.
|
Modifier and Type | Method and Description |
---|---|
static void |
addMissingPrecursorCharges(File mgfFile,
WaitingHandler waitingHandler)
Add missing precursor charges.
|
static void |
addMissingSpectrumTitles(File mgfFile,
WaitingHandler waitingHandler)
Adds missing spectrum titles.
|
static MgfIndex |
getIndexMap(File mgfFile)
Returns the index of all spectra in the given mgf file.
|
static MgfIndex |
getIndexMap(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,
Long index,
String fileName)
Returns the next precursor starting from the given index.
|
ArrayList<MSnSpectrum> |
getSpectra(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,
String fileName)
Returns the next spectrum starting from the given index.
|
static MSnSpectrum |
getSpectrum(BufferedReader br,
String fileName)
Returns the next spectrum found in the mgf file.
|
static void |
removeDuplicateSpectrumTitles(File mgfFile,
WaitingHandler waitingHandler)
Removes duplicate spectrum titles (the first occurrence is kept).
|
static void |
removeZeroes(File mgfFile,
WaitingHandler waitingHandler)
Removes zero intensity peaks.
|
static void |
renameDuplicateSpectrumTitles(File mgfFile,
WaitingHandler waitingHandler)
Renames duplicate spectrum titles.
|
ArrayList<MgfIndex> |
splitFile(File mgfFile,
int nSpectra,
WaitingHandler waitingHandler)
Splits an mgf file into smaller ones and returns the indexes of the
generated files.
|
static void |
writeAplFile(File mgfFile,
File aplFile,
String fragmentation)
Writes an apl file from an MGF file.
|
public static MSnSpectrum getSpectrum(BufferedReader br, String fileName) throws IOException
br
- a buffered readerfileName
- the name of the mgf fileIOException
- if an IOException occurspublic ArrayList<MSnSpectrum> getSpectra(File aFile) throws FileNotFoundException, IOException, IllegalArgumentException
aFile
- the mgf fileFileNotFoundException
- Exception thrown if a problem is
encountered reading the fileIOException
- Exception thrown if a problem is encountered reading
the fileIllegalArgumentException
- thrown when a parameter in the file
cannot be parsed correctlypublic static MgfIndex getIndexMap(File mgfFile) throws FileNotFoundException, IOException
mgfFile
- the given mgf fileFileNotFoundException
- Exception thrown whenever the file is not
foundIOException
- Exception thrown whenever an error occurs while
reading the filepublic static MgfIndex getIndexMap(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException
mgfFile
- the given MGF filewaitingHandler
- a waitingHandler showing the progressFileNotFoundException
- Exception thrown whenever the file is not
foundIOException
- Exception thrown whenever an error occurs while
reading the filepublic static void removeDuplicateSpectrumTitles(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, UnsupportedEncodingException
mgfFile
- the MGF file to validatewaitingHandler
- a waitingHandler showing the progress, can be nullFileNotFoundException
- Exception thrown whenever the file is not
foundIOException
- Exception thrown whenever an error occurs while
reading the fileUnsupportedEncodingException
- if the decoding of a spectrum title
failspublic static void addMissingSpectrumTitles(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, UnsupportedEncodingException
mgfFile
- the MGF file to fixwaitingHandler
- a waitingHandler showing the progress, can be nullFileNotFoundException
- Exception thrown whenever the file is not
foundIOException
- Exception thrown whenever an error occurs while
reading the fileUnsupportedEncodingException
- if the decoding of a spectrum title
failspublic static void addMissingPrecursorCharges(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, UnsupportedEncodingException
mgfFile
- the MGF file to fixwaitingHandler
- a waitingHandler showing the progress, can be nullFileNotFoundException
- Exception thrown whenever the file is not
foundIOException
- Exception thrown whenever an error occurs while
reading the fileUnsupportedEncodingException
- if the decoding of a spectrum title
failspublic static void removeZeroes(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, UnsupportedEncodingException
mgfFile
- the MGF file to fixwaitingHandler
- a waitingHandler showing the progress, can be nullFileNotFoundException
- Exception thrown whenever the file is not
foundIOException
- Exception thrown whenever an error occurs while
reading the fileUnsupportedEncodingException
- if the decoding of a spectrum title
failspublic static void renameDuplicateSpectrumTitles(File mgfFile, WaitingHandler waitingHandler) throws FileNotFoundException, IOException, UnsupportedEncodingException
mgfFile
- the MGF file to validatewaitingHandler
- a waitingHandler showing the progressFileNotFoundException
- Exception thrown whenever the file is not
foundIOException
- Exception thrown whenever an error occurs while
reading the fileUnsupportedEncodingException
- if the decoding of a spectrum title
failspublic ArrayList<MgfIndex> splitFile(File mgfFile, int nSpectra, WaitingHandler waitingHandler) throws FileNotFoundException, IOException
mgfFile
- the mgf file to splitnSpectra
- the number of spectra allowed in the smaller fileswaitingHandler
- the waitingHandler showing the progressFileNotFoundException
- exception thrown whenever a file was not
foundIOException
- exception thrown whenever a problem occurred while
reading/writing a filepublic static MSnSpectrum getSpectrum(uk.ac.ebi.pride.tools.braf.BufferedRandomAccessFile bufferedRandomAccessFile, long index, String fileName) throws IOException, 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 fileIOException
- Exception thrown whenever an error is encountered
while reading the spectrumIllegalArgumentException
- Exception thrown whenever the file is
not of a compatible formatpublic static Precursor getPrecursor(uk.ac.ebi.pride.tools.braf.BufferedRandomAccessFile bufferedRandomAccessFile, Long index, String fileName) throws IOException, 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 fileIOException
- Exception thrown whenever an error is encountered
while reading the spectrumIllegalArgumentException
- Exception thrown whenever the file is
not of a compatible formatpublic static void writeAplFile(File mgfFile, File aplFile, String fragmentation) throws FileNotFoundException, IOException, IllegalArgumentException
mgfFile
- the mgf fileaplFile
- the target apl filefragmentation
- the fragmentation method usedFileNotFoundException
- exception thrown whenever a file was not
foundIOException
- exception thrown whenever an error occurred while
reading/writing a fileIllegalArgumentException
- exception thrown whenever the mgf file
is truncated in the middle of a spectrumCopyright © 2016. All rights reserved.