Last update: 2011-06-23

org.proteios.io
Class MgfFileReader

java.lang.Object
  extended by org.proteios.io.MgfFileReader
All Implemented Interfaces:
FileValidationInterface, PeakListFileInterface, SpectrumIdReaderInterface

public class MgfFileReader
extends Object
implements PeakListFileInterface, SpectrumIdReaderInterface, FileValidationInterface

This class contains methods to access spectra from an MGF peak list file.

Author:
olle

Constructor Summary
MgfFileReader()
          Default constructor.
MgfFileReader(InputStream inputStream)
          Constructor that takes an MGF input stream as parameter.
 
Method Summary
 InputStream getInputStream()
          Get MGF input stream.
 Iterator<SpectrumInterface> getSpectrum(List<String> spectrumIds)
          Get an iterator for spectra with specified spectrum id values.
 SpectrumInterface getSpectrum(String spectrumId)
          Get the spectrum data for specified spectrum id.
 List<String> getSpectrumIdList()
          Get spectrum id list.
 boolean importable()
          Validates first line of input stream.
 boolean isSpectrumIdObtainedFromSpectrumOrderNumber()
          Specifies if the spectrum id values were obtained from the spectrum order numbers.
 boolean isTitleUsedAsId()
          Get flag indicating if spectrum title is used as spectrum id value.
 void setInputStream(InputStream inputStream)
          Set MGF input stream.
 void setTitleUsedAsId(boolean titleUsedAsId)
          Set flag indicating if spectrum title is used as spectrum id value.
 boolean valid()
          Validates MGF input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MgfFileReader

public MgfFileReader()
Default constructor.


MgfFileReader

public MgfFileReader(InputStream inputStream)
Constructor that takes an MGF input stream as parameter.

Parameters:
inputStream - InputStream MGF input stream.
Method Detail

isTitleUsedAsId

public boolean isTitleUsedAsId()
Get flag indicating if spectrum title is used as spectrum id value.

Returns:
boolean Flag indicating if spectrum title is used as spectrum id value.

setTitleUsedAsId

public void setTitleUsedAsId(boolean titleUsedAsId)
Set flag indicating if spectrum title is used as spectrum id value.

Parameters:
titleUsedAsId - boolean Flag indicating if spectrum title is used as spectrum id value.

getInputStream

public InputStream getInputStream()
Get MGF input stream.

Returns:
InputStream MGF input stream.

setInputStream

public void setInputStream(InputStream inputStream)
Set MGF input stream.

Parameters:
inputStream - InputStream MGF input stream.

getSpectrum

public SpectrumInterface getSpectrum(String spectrumId)
Get the spectrum data for specified spectrum id.

Specified by:
getSpectrum in interface PeakListFileInterface
Parameters:
spectrumId - String spectrum id.
Returns:
spectrum with specified spectrum id.

getSpectrum

public Iterator<SpectrumInterface> getSpectrum(List<String> spectrumIds)
Get an iterator for spectra with specified spectrum id values.

Specified by:
getSpectrum in interface PeakListFileInterface
Parameters:
spectrumIds - List list with spectrum id values.
Returns:
iterator for spectra with specified spectrum id values.

getSpectrumIdList

public List<String> getSpectrumIdList()
Get spectrum id list. If spectra are containing titles, the spectrum id format will be 'spectrumIndex - TITLE'

Specified by:
getSpectrumIdList in interface SpectrumIdReaderInterface
Returns:
List List with spectrum id values.

isSpectrumIdObtainedFromSpectrumOrderNumber

public boolean isSpectrumIdObtainedFromSpectrumOrderNumber()
Specifies if the spectrum id values were obtained from the spectrum order numbers.

Specified by:
isSpectrumIdObtainedFromSpectrumOrderNumber in interface SpectrumIdReaderInterface
Returns:
boolean True if the spectrum id values were obtained from spectrum order numbers, else false.

valid

public boolean valid()
Validates MGF input stream.

Specified by:
valid in interface FileValidationInterface
Returns:
True if the MGF input stream is valid, else false
Throws:
BaseException - If there is an error

importable

public boolean importable()
Validates first line of input stream.

Specified by:
importable in interface FileValidationInterface
Returns:
True if the input stream is valid, else false

Last update: 2011-06-23