RbDe rbde-349 (20120127151154)

edu.mssm.crover.imports
Interface SequenceReaderFactory

All Known Implementing Classes:
SequenceReaderFactoryImpl

public interface SequenceReaderFactory

Gives access to specialized Sequence readers. This interface allows to read sequences from an InputStream.


Method Summary
 void addReader(SequenceReader reader)
          Adds the SequenceReader to the set of Readers supported by this Factory.
 ReaderType[] getSupportedTypes()
          Returns the ReaderTypes supported by this factory implementation.
 ReaderType guessReaderType(String filename)
          Return a ReaderType supported by this factory that is guessed to be able to handle a file named filename.
 AnnotatedBioSequence[] readSequences(InputStream seqstream, ReaderType type)
          Extract sequences by reading and parsing a given an input stream.
 

Method Detail

getSupportedTypes

ReaderType[] getSupportedTypes()
Returns the ReaderTypes supported by this factory implementation. The calls to readSequences should use one of the type returned by this method or the UnregisteredReaderTypeException is likely to be raised.

Returns:
an array of types supported by this factory

addReader

void addReader(SequenceReader reader)
Adds the SequenceReader to the set of Readers supported by this Factory. A SequenceReader that supports the same ReaderType (same shortname, see ReaderType) that a SequenceReader already present in the Factory replaces the previous one.

Parameters:
reader - the reader to add

readSequences

AnnotatedBioSequence[] readSequences(InputStream seqstream,
                                     ReaderType type)
                                     throws IOException
Extract sequences by reading and parsing a given an input stream.

Parameters:
seqstream - A stream containing the sequence to read
type - The type of reader to use when reading the sequence
Returns:
An array of sequences found in the input stream
Throws:
IOException - if there is a problem reading from the stream

guessReaderType

ReaderType guessReaderType(String filename)
Return a ReaderType supported by this factory that is guessed to be able to handle a file named filename. Only the filename is used to guess: we are relying on the common pratice to name files with an extension that is indicative of the file format. There is no garantee of course that the guess will be correct, ie that the SequenceReader associated with the ReaderType will correctly parse the InputStream sent to it latter. Also, the application can override the guess (to leave to the user the final word) and provide readSequences() with another supported ReaderType.
The default readerType returned (when no sensible match can be determined) is left to the discretion of the implementation.

Parameters:
filename - The filename used to guess the reader type from
Returns:
The most appropriate reader type for the given filename

RbDe rbde-349 (20120127151154)

Copyright © 2003-2012 Institute for Computational Biomedicine, All Rights Reserved.