com.compomics.util.experiment.io.massspectrometry
Class MgfReader

java.lang.Object
  extended by com.compomics.util.experiment.io.massspectrometry.MgfReader

public class MgfReader
extends Object

This class will read an mgf file.

Author:
Marc Vaudel, Harald Barsnes

Constructor Summary
MgfReader()
          General constructor for an mgf reader.
 
Method Summary
static MgfIndex getIndexMap(File mgfFile)
          Returns the index of all spectra in the given mgf file
static MgfIndex getIndexMap(File mgfFile, JProgressBar progressBar)
          Returns the index of all spectra in the given mgf file
static Precursor getPrecursor(RandomAccessFile randomAccessFile, 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(RandomAccessFile randomAccessFile, long index, String fileName)
          Returns the next spectrum starting from the given index
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MgfReader

public MgfReader()
General constructor for an mgf reader.

Method Detail

getSpectra

public ArrayList<MSnSpectrum> getSpectra(File aFile)
                                  throws Exception
Reads an mgf file and retrieves a list of spectra.

Parameters:
aFile - the mgf file
Returns:
list of MSnSpectra imported from the file
Throws:
Exception - Exeption thrown if a problem is encountered reading the file

getIndexMap

public static MgfIndex getIndexMap(File mgfFile)
                            throws FileNotFoundException,
                                   IOException
Returns the index of all spectra in the given mgf file

Parameters:
mgfFile - the given mgf file
Returns:
the index of all spectra
Throws:
FileNotFoundException - Exception thrown whenever the file is not found
IOException - Exception thrown whenever an error occurs while reading the file

getIndexMap

public static MgfIndex getIndexMap(File mgfFile,
                                   JProgressBar progressBar)
                            throws FileNotFoundException,
                                   IOException
Returns the index of all spectra in the given mgf file

Parameters:
mgfFile - the given mgf file
progressBar - a progress bar showing the progress
Returns:
the index of all spectra
Throws:
FileNotFoundException - Exception thrown whenever the file is not found
IOException - Exception thrown whenever an error occurs while reading the file

getSpectrum

public static MSnSpectrum getSpectrum(RandomAccessFile randomAccessFile,
                                      long index,
                                      String fileName)
                               throws IOException,
                                      Exception
Returns the next spectrum starting from the given index

Parameters:
randomAccessFile - The random access file of the inspected mgf file
index - The index where to start looking for the spectrum
fileName - The name of the mgf file (@TODO get this from the random access file?)
Returns:
The next spectrum encountered
Throws:
IOException - Exception thrown whenever an error is encountered while reading the spectrum
Exception - Exception thrown whenever the file is not of a compatible format

getPrecursor

public static Precursor getPrecursor(RandomAccessFile randomAccessFile,
                                     long index,
                                     String fileName)
                              throws IOException,
                                     Exception
Returns the next precursor starting from the given index

Parameters:
randomAccessFile - The random access file of the inspected mgf file
index - The index where to start looking for the spectrum
fileName - The name of the mgf file (@TODO get this from the random access file?)
Returns:
The next spectrum encountered
Throws:
IOException - Exception thrown whenever an error is encountered while reading the spectrum
Exception - Exception thrown whenever the file is not of a compatible format


Copyright © 2011. All Rights Reserved.