bpp-seq3  3.0.0
bpp::Pasta Class Reference

The Pasta sequence file format. More...

#include <Bpp/Seq/Io/Pasta.h>

+ Inheritance diagram for bpp::Pasta:
+ Collaboration diagram for bpp::Pasta:

Public Types

typedef Table< double > DataTable
 

Public Member Functions

 Pasta (unsigned int charsByLine=100, bool extended=false, bool strictSequenceNames=false)
 Build a new Pasta object. More...
 
virtual ~Pasta ()
 
const std::string getFormatName () const override
 Get the format name. More...
 
const std::string getFormatDescription () const override
 
void writeSequence (std::ostream &output, const ProbabilisticSequence &seq, bool header) const
 
void writeSequence (std::ostream &output, const Sequence &seq, bool header) const
 
const std::string getDataType () const override
 
void writeAlignment (std::ostream &output, const SiteContainerInterface &sc) const override
 
void writeAlignment (const std::string &path, const SiteContainerInterface &sc, bool overwrite=true) const override
 
The "ISequenceStream interface"
bool nextSequence (std::istream &input, ProbabilisticSequence &seq, bool hasLabels, const std::vector< size_t > &permutationMap) const
 
The OSequence interface"
void writeSequences (std::ostream &output, const SequenceContainerInterface &sc) const override
 Write a container to a stream. More...
 
void writeSequences (std::ostream &output, const SequenceContainerInterface &sc) const override=0
 
void writeSequences (const std::string &path, const SequenceContainerInterface &sc, bool overwrite=true) const override
 
The "I/OProbabilisticSequence interface"
void appendAlignmentFromStream (std::istream &input, ProbabilisticSequenceContainerInterface &psc) const override
 Append sequences to a container from a stream. More...
 
void writeAlignment (std::ostream &output, const ProbabilisticSiteContainerInterface &psc) const override
 Write a container to a stream. More...
 
IProbabilisticAlignment methods:
void readAlignment (std::istream &input, ProbabilisticSequenceContainerInterface &sc) const override
 Add sequences to a container from a stream. More...
 
void readAlignment (const std::string &path, ProbabilisticSequenceContainerInterface &sc) const override
 Add sequences to a container from a file. More...
 
std::unique_ptr< ProbabilisticSiteContainerInterfacereadAlignment (const std::string &path, std::shared_ptr< const Alphabet > alpha) const override
 Create a new container from a file. More...
 
std::unique_ptr< ProbabilisticSiteContainerInterfacereadAlignment (std::istream &input, std::shared_ptr< const Alphabet > alpha) const override
 Create a new container from a stream. More...
 
OProbabilisticAlignment methods:
void writeAlignment (const std::string &path, const ProbabilisticSiteContainerInterface &psc, bool overwrite=true) const override
 Write a container to a file. More...
 
OAlignment methods:

As a SiteContainer is a specialization of SequenceContainer, it is assumed that a OSequence object can write aligned sequence just like a OAlignment object. Therefore it implements the OAlignment interface by down-casting the SiteContainer to a SequenceContainer.

void writeAlignment (std::ostream &output, const SiteContainerInterface &sc) const override
 Write a container to a stream. More...
 
void writeAlignment (const std::string &path, const SiteContainerInterface &sc, bool overwrite=true) const override
 Write a container to a file. More...
 
OSequence methods:
void writeSequences (const std::string &path, const SequenceContainerInterface &sc, bool overwrite=true) const override
 Write a container to a file. More...
 

Protected Member Functions

virtual void appendAlignmentFromFile (const std::string &path, ProbabilisticSequenceContainerInterface &sc) const
 Append sequences to a container from a file. More...
 
virtual std::unique_ptr< ProbabilisticSiteContainerInterfacereadAlignmentFromStream (std::istream &input, std::shared_ptr< const Alphabet > &alpha) const
 Read sequences from a stream. More...
 
virtual std::unique_ptr< ProbabilisticSiteContainerInterfacereadAlignmentFromFile (const std::string &path, std::shared_ptr< const Alphabet > &alpha) const
 Read sequences from a file. More...
 

Protected Attributes

unsigned int charsByLine_
 The maximum number of chars to be written on a line. More...
 
bool extended_
 
bool strictNames_
 

Detailed Description

The Pasta sequence file format.

Read and write from/to Pasta files – a format that is more general than the Fasta format : while the Fasta format contains sequence information in the form of character states at each site of the sequence, the Pasta format contains sequence information in the form of probability of presence of each character state at each site. See implementation of methods below for more details

Definition at line 30 of file Pasta.h.

Member Typedef Documentation

◆ DataTable

typedef Table<double> bpp::Pasta::DataTable

Definition at line 45 of file Pasta.h.

Constructor & Destructor Documentation

◆ Pasta()

bpp::Pasta::Pasta ( unsigned int  charsByLine = 100,
bool  extended = false,
bool  strictSequenceNames = false 
)
inline

Build a new Pasta object.

Parameters
charsByLineNumber of characters per line when writing files.
extendedTell if we should read general comments and sequence comments in HUPO-PSI format.
strictSequenceNamesTells if the sequence names should be restricted to the characters between '>' and the first blank one.

Definition at line 54 of file Pasta.h.

◆ ~Pasta()

virtual bpp::Pasta::~Pasta ( )
inlinevirtual

Definition at line 57 of file Pasta.h.

Member Function Documentation

◆ appendAlignmentFromFile()

virtual void bpp::AbstractIProbabilisticAlignment::appendAlignmentFromFile ( const std::string &  path,
ProbabilisticSequenceContainerInterface sc 
) const
inlineprotectedvirtualinherited

Append sequences to a container from a file.

Parameters
pathThe path to the file to read.
scThe sequence container to update.
Exceptions
ExceptionIf the file is not in the specified format.

Definition at line 250 of file AbstractIAlignment.h.

References bpp::AbstractIProbabilisticAlignment::appendAlignmentFromStream().

Referenced by bpp::AbstractIProbabilisticAlignment::readAlignment(), bpp::AbstractIProbabilisticAlignment::readAlignmentFromFile(), and bpp::AbstractIProbabilisticAlignment2::readSequences().

◆ appendAlignmentFromStream()

void Pasta::appendAlignmentFromStream ( std::istream &  input,
ProbabilisticSequenceContainerInterface sc 
) const
overridevirtual

Append sequences to a container from a stream.

This is the unique method to implement!

Parameters
inputThe input stream to read.
scThe sequence container to update.

Implements bpp::AbstractIProbabilisticAlignment.

Definition at line 156 of file Pasta.cpp.

References bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::addSequence(), bpp::TemplateSequenceDataInterface< HashType >::getAlphabet(), bpp::StringTokenizer::hasMoreToken(), bpp::StringTokenizer::nextToken(), and bpp::Commentable::setComments().

◆ getDataType()

const std::string bpp::Pasta::getDataType ( ) const
inlineoverridevirtual

Reimplemented from bpp::IOSequence.

Definition at line 131 of file Pasta.h.

◆ getFormatDescription()

const std::string bpp::Pasta::getFormatDescription ( ) const
inlineoverridevirtual

Implements bpp::IOFormat.

Definition at line 66 of file Pasta.h.

◆ getFormatName()

const std::string bpp::Pasta::getFormatName ( ) const
inlineoverridevirtual

Get the format name.

Returns
format name

Implements bpp::IOFormat.

Definition at line 65 of file Pasta.h.

◆ nextSequence()

◆ readAlignment() [1/4]

void bpp::AbstractIProbabilisticAlignment::readAlignment ( const std::string &  path,
ProbabilisticSequenceContainerInterface sc 
) const
inlineoverridevirtualinherited

Add sequences to a container from a file.

Parameters
pathThe path to the file to read.
scThe sequence container to update.

Implements bpp::IProbabilisticAlignment.

Definition at line 215 of file AbstractIAlignment.h.

References bpp::AbstractIProbabilisticAlignment::appendAlignmentFromFile().

◆ readAlignment() [2/4]

std::unique_ptr<ProbabilisticSiteContainerInterface> bpp::AbstractIProbabilisticAlignment::readAlignment ( const std::string &  path,
std::shared_ptr< const Alphabet alpha 
) const
inlineoverridevirtualinherited

Create a new container from a file.

Parameters
pathThe path to the file to read.
alphaThe alphabet to be associated to the container.
Returns
A new ProbabilisticSiteContainer object.

Implements bpp::IProbabilisticAlignment.

Definition at line 220 of file AbstractIAlignment.h.

References bpp::AbstractIProbabilisticAlignment::readAlignmentFromFile().

◆ readAlignment() [3/4]

void bpp::AbstractIProbabilisticAlignment::readAlignment ( std::istream &  input,
ProbabilisticSequenceContainerInterface sc 
) const
inlineoverridevirtualinherited

Add sequences to a container from a stream.

Parameters
inputThe input stream to read.
scThe sequence container to update.

Implements bpp::IProbabilisticAlignment.

Definition at line 204 of file AbstractIAlignment.h.

References bpp::AbstractIProbabilisticAlignment::appendAlignmentFromStream().

Referenced by bpp::AbstractIProbabilisticAlignment2::readSequences().

◆ readAlignment() [4/4]

std::unique_ptr<ProbabilisticSiteContainerInterface> bpp::AbstractIProbabilisticAlignment::readAlignment ( std::istream &  input,
std::shared_ptr< const Alphabet alpha 
) const
inlineoverridevirtualinherited

Create a new container from a stream.

Parameters
inputThe input stream to read.
alphaThe alphabet to be associated to the container.
Returns
A new ProbabilisticSiteContainer object.

Implements bpp::IProbabilisticAlignment.

Definition at line 225 of file AbstractIAlignment.h.

References bpp::AbstractIProbabilisticAlignment::readAlignmentFromStream().

◆ readAlignmentFromFile()

virtual std::unique_ptr<ProbabilisticSiteContainerInterface> bpp::AbstractIProbabilisticAlignment::readAlignmentFromFile ( const std::string &  path,
std::shared_ptr< const Alphabet > &  alpha 
) const
inlineprotectedvirtualinherited

Read sequences from a file.

Parameters
pathThe path to the file to read.
alphaThe alphabet to use.
Returns
A sequence container.

Definition at line 280 of file AbstractIAlignment.h.

References bpp::AbstractIProbabilisticAlignment::appendAlignmentFromFile().

Referenced by bpp::AbstractIProbabilisticAlignment::readAlignment().

◆ readAlignmentFromStream()

virtual std::unique_ptr<ProbabilisticSiteContainerInterface> bpp::AbstractIProbabilisticAlignment::readAlignmentFromStream ( std::istream &  input,
std::shared_ptr< const Alphabet > &  alpha 
) const
inlineprotectedvirtualinherited

Read sequences from a stream.

Parameters
inputThe input stream to read.
alphaThe alphabet to use.
Returns
A sequence container.

Definition at line 266 of file AbstractIAlignment.h.

References bpp::AbstractIProbabilisticAlignment::appendAlignmentFromStream().

Referenced by bpp::AbstractIProbabilisticAlignment::readAlignment().

◆ writeAlignment() [1/6]

void bpp::AbstractOProbabilisticAlignment::writeAlignment ( const std::string &  path,
const ProbabilisticSiteContainerInterface sc,
bool  overwrite = true 
) const
inlineoverridevirtualinherited

Write a container to a file.

Parameters
pathThe path to the file to write.
scThe container to write.
overwriteIf true the sequences are written at the beginning of the file instead of being appended. Any previous content will be lost.

Implements bpp::OProbabilisticAlignment.

Definition at line 65 of file AbstractOAlignment.h.

References bpp::AbstractOProbabilisticAlignment::writeAlignment().

◆ writeAlignment() [2/6]

void bpp::AbstractOSequence2::writeAlignment ( const std::string &  path,
const SiteContainerInterface sc,
bool  overwrite = true 
) const
inlineoverridevirtualinherited

Write a container to a file.

Parameters
pathThe path to the file to write.
scThe container to write.
overwriteIf true the sequences are written at the beginning of the file instead of being appended. Any previous content will be lost.
Exceptions
ExceptionIf the file is not in the specified format.

Implements bpp::OAlignment.

Definition at line 78 of file AbstractOSequence.h.

References bpp::AbstractOSequence::writeSequences().

◆ writeAlignment() [3/6]

void bpp::AbstractOSequence2::writeAlignment
inlineoverride

Definition at line 78 of file AbstractOSequence.h.

◆ writeAlignment() [4/6]

void bpp::Pasta::writeAlignment ( std::ostream &  output,
const ProbabilisticSiteContainerInterface sc 
) const
inlineoverridevirtual

Write a container to a stream.

Parameters
outputThe output stream where to write.
scThe container to write.

Implements bpp::AbstractOProbabilisticAlignment.

Definition at line 112 of file Pasta.h.

References bpp::TemplateSequenceDataInterface< HashType >::getNumberOfSequences(), bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::sequence(), and writeSequence().

◆ writeAlignment() [5/6]

void bpp::AbstractOSequence2::writeAlignment ( std::ostream &  output,
const SiteContainerInterface sc 
) const
inlineoverridevirtualinherited

Write a container to a stream.

Parameters
outputThe output stream where to write.
scThe container to write.
Exceptions
ExceptionIf the file is not in the specified format.

Implements bpp::OAlignment.

Definition at line 73 of file AbstractOSequence.h.

References bpp::AbstractOSequence::writeSequences().

◆ writeAlignment() [6/6]

void bpp::AbstractOSequence2::writeAlignment
inlineoverride

Definition at line 73 of file AbstractOSequence.h.

◆ writeSequence() [1/2]

void Pasta::writeSequence ( std::ostream &  output,
const ProbabilisticSequence seq,
bool  header 
) const

◆ writeSequence() [2/2]

void Pasta::writeSequence ( std::ostream &  output,
const Sequence seq,
bool  header 
) const

◆ writeSequences() [1/4]

void bpp::AbstractOSequence::writeSequences ( const std::string &  path,
const SequenceContainerInterface sc,
bool  overwrite = true 
) const
inlineoverridevirtualinherited

Write a container to a file.

Parameters
pathThe path to the file to write.
scThe container to write.
overwriteIf true the sequences are written at the beginning of the file instead of being appended. Any previous content will be lost.
Exceptions
ExceptionIf the file is not in the specified format.

Implements bpp::OSequence.

Reimplemented in bpp::Mase, and bpp::Fasta.

Definition at line 38 of file AbstractOSequence.h.

References bpp::AbstractOSequence::writeSequences().

◆ writeSequences() [2/4]

void bpp::AbstractOSequence::writeSequences
inlineoverride

Definition at line 38 of file AbstractOSequence.h.

◆ writeSequences() [3/4]

void bpp::Pasta::writeSequences ( std::ostream &  output,
const SequenceContainerInterface sc 
) const
inlineoverridevirtual

Write a container to a stream.

Parameters
outputThe output stream where to write.
scThe container to write.
Exceptions
ExceptionIf the file is not in the specified format.

Implements bpp::AbstractOSequence.

Definition at line 91 of file Pasta.h.

References bpp::TemplateSequenceDataInterface< HashType >::getNumberOfSequences(), bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::sequence(), and writeSequence().

◆ writeSequences() [4/4]

void bpp::AbstractOSequence::writeSequences
override

Member Data Documentation

◆ charsByLine_

unsigned int bpp::Pasta::charsByLine_
protected

The maximum number of chars to be written on a line.

Definition at line 39 of file Pasta.h.

◆ extended_

bool bpp::Pasta::extended_
protected

Definition at line 41 of file Pasta.h.

◆ strictNames_

bool bpp::Pasta::strictNames_
protected

Definition at line 42 of file Pasta.h.


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