Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
FASTAFile Class Reference

This class serves for reading in and writing FASTA files. More...

#include <OpenMS/FORMAT/FASTAFile.h>

Classes

struct  FASTAEntry
 FASTA entry type (identifier, description and sequence) More...
 

Public Member Functions

 FASTAFile ()
 Default constructor. More...
 
virtual ~FASTAFile ()
 Destructor. More...
 
void readStart (const String &filename)
 Prepares a FASTA file given by 'filename' for streamed reading using readNext(). More...
 
bool readNext (FASTAEntry &protein)
 Prepares a FASTA file given by 'filename' for streamed reading using readNext(). More...
 
void writeStart (const String &filename)
 Prepares a FASTA file given by 'filename' for streamed writing using writeNext(). More...
 
void writeNext (const FASTAEntry &protein)
 Stores the data given by protein. Call writeStart() once before calling writeNext(). More...
 
void writeEnd ()
 Closes the file (flush). Called implicitly when FASTAFile object does out of scope. More...
 

Static Public Member Functions

static void load (const String &filename, std::vector< FASTAEntry > &data)
 loads a FASTA file given by 'filename' and stores the information in 'data' More...
 
static void store (const String &filename, const std::vector< FASTAEntry > &data)
 stores the data given by 'data' at the file 'filename' More...
 

Protected Attributes

std::fstream infile_
 
std::ofstream outfile_
 
std::unique_ptr< void, std::function< void(void *) > > reader_
 
Size entries_read_
 

Detailed Description

This class serves for reading in and writing FASTA files.

You can use aggregate methods load() and store() to read/write a set of protein sequences at the cost of memory.

Or use single read/write of protein sequences using readStart(), readNext() and writeStart(), writeNext(), writeEnd() for more memory efficiency. Reading from one and writing to another FASTA file can be handled by one single FASTAFile instance.

Constructor & Destructor Documentation

◆ FASTAFile()

FASTAFile ( )

Default constructor.

◆ ~FASTAFile()

virtual ~FASTAFile ( )
virtual

Destructor.

Member Function Documentation

◆ load()

static void load ( const String filename,
std::vector< FASTAEntry > &  data 
)
static

loads a FASTA file given by 'filename' and stores the information in 'data'

This uses more RAM than readStart() and readNext().

Exceptions
Exception::FileNotFoundis thrown if the file does not exists.
Exception::ParseErroris thrown if the file does not suit to the standard.

Referenced by TOPPOpenPepXLLF::main_(), SimpleSearchEngine::main_(), TOPPOpenPepXL::main_(), RNPxlSearch::main_(), and TOPPMetaProSIP::main_().

◆ readNext()

bool readNext ( FASTAEntry protein)

Prepares a FASTA file given by 'filename' for streamed reading using readNext().

If you want to read all entries in one go, use load().

Returns
true if entry was read; false if eof was reached
Exceptions
Exception::FileNotFoundis thrown if the file does not exists.
Exception::ParseErroris thrown if the file does not suit to the standard.

◆ readStart()

void readStart ( const String filename)

Prepares a FASTA file given by 'filename' for streamed reading using readNext().

Exceptions
Exception::FileNotFoundis thrown if the file does not exists.
Exception::ParseErroris thrown if the file does not suit to the standard.

◆ store()

static void store ( const String filename,
const std::vector< FASTAEntry > &  data 
)
static

stores the data given by 'data' at the file 'filename'

This uses more RAM than writeStart() and writeNext().

Exceptions
Exception::UnableToCreateFileis thrown if the process is not able to write the file.

◆ writeEnd()

void writeEnd ( )

Closes the file (flush). Called implicitly when FASTAFile object does out of scope.

◆ writeNext()

void writeNext ( const FASTAEntry protein)

Stores the data given by protein. Call writeStart() once before calling writeNext().

Call writeEnd() when done to close the file!

Exceptions
Exception::UnableToCreateFileis thrown if the process is not able to write the file.

◆ writeStart()

void writeStart ( const String filename)

Prepares a FASTA file given by 'filename' for streamed writing using writeNext().

Exceptions
Exception::UnableToCreateFileis thrown if the process is not able to write to the file (disk full?).

Member Data Documentation

◆ entries_read_

Size entries_read_
protected

◆ infile_

std::fstream infile_
protected

◆ outfile_

std::ofstream outfile_
protected

◆ reader_

std::unique_ptr<void, std::function<void(void*) > > reader_
protected

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:08 using doxygen 1.8.13