Egglib 2.1.11
C++ library reference manual
Static Public Member Functions | Protected Member Functions | List of all members
Fasta Class Reference

Fasta parser/formatter. More...

#include <Fasta.hpp>

Static Public Member Functions

static Container parsef (const char *fname, bool importGroupLabels=false)
 Imports a fasta file. More...
 
static void parsef (const char *fname, Container &container, bool importGroupLabels=false)
 Imports a fasta file. More...
 
static Container parse (const std::string &str, bool importGroupLabels=false)
 Imports a fasta file. More...
 
static void parse (const std::string &str, Container &container, bool importGroupLabels=false)
 Imports a fasta file. More...
 
static Container parse (std::istream &stream, bool importGroupLabels=false)
 Imports a fasta file from an open stream. More...
 
static void parse (std::istream &stream, Container &container, bool importGroupLabels=false)
 Imports a fasta file from an open stream. More...
 
static void formatf (const char *fname, const Container &container, bool exportGroupLabels=false, unsigned int lineLength=50)
 Export sequences as fasta. More...
 
static void format (std::ostream &file, const Container &container, bool exportGroupLabels=false, unsigned int lineLength=50)
 Export sequences as fasta. More...
 
static std::string format (const Container &container, bool exportGroupLabels=false, unsigned int lineLength=50)
 Export sequences as fasta. More...
 

Protected Member Functions

 Fasta ()
 This class cannot be instantiated.
 
 Fasta (const Fasta &source)
 This class cannot be instantiated.
 
Fastaoperator= (const Fasta &source)
 This class cannot be or copied.
 
virtual ~Fasta ()
 This class cannot be instantiated.
 

Detailed Description

Fasta parser/formatter.

Reads a multifasta sequence file from a string, a stream or a file and returns a Container. See the description of the format below. Formats a fasta string from a sequence container object and places it in a string, a stream of a file. All methods are static and the class cannot be instantiated. The methods parsef and formatf will open the file for you while the others will read/write directly in a string.

Specifications of the fasta format:

Member Function Documentation

void format ( std::ostream &  file,
const Container container,
bool  exportGroupLabels = false,
unsigned int  lineLength = 50 
)
static

Export sequences as fasta.

Parameters
filean open stream.
containerContainer object to export.
exportGroupLabelsif set to true, exports group indices as a @x at the end of the sequence name, where x is the group index. Otherwise, this information is discarded.
lineLengththe number of characters to place on a single line. If zero, no newlines are inserted within sequences.
std::string format ( const Container container,
bool  exportGroupLabels = false,
unsigned int  lineLength = 50 
)
static

Export sequences as fasta.

This medod creates internally an ostringstream, calls the method format(ostream, container, bool) and returns the resulting string.

Parameters
containerContainer object to export.
exportGroupLabelsif set to true, exports group indices as a @x at the end of the sequence name, where x is the group index. Otherwise, this information is discarded.
lineLengththe number of characters to place on a single line. If zero, no newlines are inserted within sequences.
Returns
The formatted string.
void formatf ( const char *  fname,
const Container container,
bool  exportGroupLabels = false,
unsigned int  lineLength = 50 
)
static

Export sequences as fasta.

Parameters
fnamethe name of the file where to place the result.
containerContainer object to export.
exportGroupLabelsif set to true, exports group indices as a @x at the end of the sequence name, where x is the group index. Otherwise, this information is discarded.
lineLengththe number of characters to place on a single line. If zero, no newlines are inserted within sequences.
Container parse ( const std::string &  str,
bool  importGroupLabels = false 
)
static

Imports a fasta file.

Imports the content of the file as is. Calls the method pase(std::istream*, bool) by creating its own istream.

Parameters
stra string containing the data.
importGroupLabelsif set to true, scan automatically for groups. The format is @ followed by an integer, placed at the end of the header string(sequences without labels will be treated as @0).
Returns
A Container object containing the sequences.
void parse ( const std::string &  str,
Container container,
bool  importGroupLabels = false 
)
static

Imports a fasta file.

Imports the content of the file as is. Calls the method pase(std::istream*, bool) by creating its own istream. This method expects a reference to a Container to which the sequences will be appended.

Parameters
stra string containing the data.
containera Container instance, empty or not.
importGroupLabelsif set to true, scan automatically for groups. The format is @ followed by an integer, placed at the end of the header string(sequences without labels will be treated as @0).
Returns
Nothing: new sequences are appended to the Container passed as argument.
Container parse ( std::istream &  stream,
bool  importGroupLabels = false 
)
static

Imports a fasta file from an open stream.

Imports the content of the file as is.

Parameters
streaman open stream (file or string) containing the data.
importGroupLabelsif set to true, scan automatically for groups. The format is @ followed by an integer, placed at the end of the header string(sequences without labels will be treated as @0).
Returns
A Container object containing the sequences.
void parse ( std::istream &  stream,
Container container,
bool  importGroupLabels = false 
)
static

Imports a fasta file from an open stream.

Imports the content of the file as is. This method expects a reference to a Container to which the sequences will be appended.

Parameters
streaman open stream (file or string) containing the data.
containera Container instance, empty or not.
importGroupLabelsif set to true, scan automatically for groups. The format is @ followed by an integer, placed at the end of the header string(sequences without labels will be treated as @0).
Returns
Nothing: the new sequences are appended to the Container passed as argument.
Container parsef ( const char *  fname,
bool  importGroupLabels = false 
)
static

Imports a fasta file.

Imports the content of the file as is. Calls the method pase(std::istream*, bool) by creating its own istream.

Parameters
fnamethe name of a fasta file.
importGroupLabelsif set to true, scan automatically for groups. The format is @ followed by an integer, placed at the end of the header string(sequences without labels will be treated as @0).
Returns
A Container object containing the sequences.
void parsef ( const char *  fname,
Container container,
bool  importGroupLabels = false 
)
static

Imports a fasta file.

Imports the content of the file as is. Calls the method pase(std::istream*, bool) by creating its own istream. This method expects a reference to a Container to which the sequences will be appended.

Parameters
fnamethe name of a fasta file.
containera Container instance, empty or not.
importGroupLabelsif set to true, scan automatically for groups. The format is @ followed by an integer, placed at the end of the header string(sequences without labels will be treated as @0).
Returns
Nothings: the new sequences are appended to the Container passed as argument.

The documentation for this class was generated from the following files:

Hosted by 
Get EggLib at SourceForge.net. Fast, secure and Free Open Source software downloads