bpp-seq3
3.0.0
|
The Nexus format reader for sequences. More...
#include <Bpp/Seq/Io/NexusIoSequence.h>
Public Member Functions | |
NexusIOSequence (unsigned int charsByLine=100, bool checkSequenceNames=true) | |
Build a new Nexus file reader. More... | |
virtual | ~NexusIOSequence () |
bool | checkNames () const |
void | checkNames (bool yn) |
Tell whether the sequence names should be checked when reading from files. More... | |
const std::string | getDataType () const |
The AbstractIAlignment interface. | |
void | appendAlignmentFromStream (std::istream &input, SequenceContainerInterface &sc) const override |
Append sequences to a container from a stream. More... | |
The IOSequence interface. | |
const std::string | getFormatName () const override |
const std::string | getFormatDescription () const override |
The ISequence interface. | |
As a SiteContainer is a subclass of SequenceContainer, we hereby implement the ISequence interface by downcasting the interface. | |
void | readSequences (std::istream &input, SequenceContainerInterface &sc) const override |
Create a new container from a stream. More... | |
void | readSequences (const std::string &path, SequenceContainerInterface &sc) const override |
Create a new container from a file. More... | |
std::unique_ptr< SequenceContainerInterface > | readSequences (std::istream &input, std::shared_ptr< const Alphabet > alpha) const override |
Create a new container from a stream. More... | |
std::unique_ptr< SequenceContainerInterface > | readSequences (const std::string &path, std::shared_ptr< const Alphabet > alpha) const override |
Create a new container from a file. More... | |
IAlignment methods: | |
virtual void | readAlignment (std::istream &input, SequenceContainerInterface &sc) const override |
Add sequences to a container from a stream. More... | |
virtual void | readAlignment (const std::string &path, SequenceContainerInterface &sc) const override |
Add sequences to a container from a file. More... | |
std::unique_ptr< SiteContainerInterface > | readAlignment (const std::string &path, std::shared_ptr< const Alphabet > alpha) const override |
Create a new container from a file. More... | |
std::unique_ptr< SiteContainerInterface > | readAlignment (std::istream &input, std::shared_ptr< const Alphabet > alpha) const override |
Create a new container from a stream. More... | |
Protected Member Functions | |
virtual void | appendAlignmentFromFile (const std::string &path, SequenceContainerInterface &sc) const |
Append sequences to a container from a file. More... | |
virtual std::unique_ptr< SiteContainerInterface > | readAlignmentFromStream (std::istream &input, std::shared_ptr< const Alphabet > alpha) const |
Read sequences from a stream. More... | |
virtual std::unique_ptr< SiteContainerInterface > | readAlignmentFromFile (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 | checkNames_ |
Private Member Functions | |
const std::vector< std::string > | splitNameAndSequence_ (const std::string &s) const |
The Nexus format reader for sequences.
An AlignedSequenceContainer is used instead of a VectorSequenceContainer.
This reader is not supposed to be a full parser of the Nexus files, but only extract the sequence data. Only a basic subset of the options are and will be supported.
This format is described in the following paper: Maddison D, Swofford D, and Maddison W (1997), Syst Biol 46(4):590-621
Definition at line 34 of file NexusIoSequence.h.
|
inline |
Build a new Nexus file reader.
charsByLine | The number of base to display in a row (ignored for now, no writing support). |
checkSequenceNames | Tell if the names in the file should be checked for unicity (slower, in o(n*n) where n is the number of sequences). |
Definition at line 53 of file NexusIoSequence.h.
|
inlinevirtual |
Definition at line 56 of file NexusIoSequence.h.
|
inlineprotectedvirtualinherited |
Append sequences to a container from a file.
path | The path to the file to read. |
sc | The sequence container to update. |
Exception | If the file is not in the specified format. |
Definition at line 93 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
Referenced by bpp::AbstractIAlignment::readAlignment(), bpp::AbstractIAlignment::readAlignmentFromFile(), and bpp::AbstractIAlignment2::readSequences().
|
overridevirtual |
Append sequences to a container from a stream.
This is the unique method to implement!
input | The input stream to read. |
sc | The sequence container to update. |
Exception | If the file is not in the specified format. |
Implements bpp::AbstractIAlignment.
Definition at line 37 of file NexusIoSequence.cpp.
References bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::addSequence(), bpp::AlphabetTools::DEFAULT_ALPHABET, bpp::TextTools::endsWith(), bpp::NexusTools::getNextCommand(), bpp::FileTools::getNextLine(), bpp::TextTools::hasSubstring(), bpp::KeyvalTools::multipleKeyvals(), bpp::TextTools::removeSurroundingWhiteSpaces(), bpp::SiteContainerTools::resolveDottedAlignment(), bpp::TextTools::startsWith(), and bpp::TextTools::toUpper().
|
inline |
Definition at line 80 of file NexusIoSequence.h.
References checkNames_.
|
inline |
Tell whether the sequence names should be checked when reading from files.
yn | whether the sequence names should be checked when reading from files. |
Definition at line 87 of file NexusIoSequence.h.
References checkNames_.
|
inlinevirtualinherited |
|
overridevirtual |
Implements bpp::IOFormat.
Definition at line 180 of file NexusIoSequence.cpp.
|
overridevirtual |
Implements bpp::IOFormat.
Definition at line 176 of file NexusIoSequence.cpp.
|
inlineoverridevirtualinherited |
Add sequences to a container from a file.
path | The path to the file to read. |
sc | The sequence container to update. |
Exception | If the file is not in the specified format. |
Implements bpp::IAlignment.
Definition at line 57 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromFile().
|
inlineoverridevirtualinherited |
Create a new container from a file.
path | The path to the file to read. |
alpha | The alphabet to be associated to the container. |
Exception | If the file is not in the specified format. |
Implements bpp::IAlignment.
Definition at line 62 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::readAlignmentFromFile().
|
inlineoverridevirtualinherited |
Add sequences to a container from a stream.
input | The input stream to read. |
sc | The sequence container to update. |
Exception | If the file is not in the specified format. |
Implements bpp::IAlignment.
Definition at line 45 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
Referenced by bpp::AbstractIAlignment2::readSequences(), bpp::Clustal::readSequences(), bpp::DCSE::readSequences(), and bpp::Phylip::readSequences().
|
inlineoverridevirtualinherited |
Create a new container from a stream.
input | The input stream to read. |
alpha | The alphabet to be associated to the container. |
Exception | If the file is not in the specified format. |
Implements bpp::IAlignment.
Definition at line 67 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::readAlignmentFromStream().
|
inlineprotectedvirtualinherited |
Read sequences from a file.
path | The path to the file to read. |
alpha | The alphabet to use. |
Exception | If the file is not in the specified format. |
Definition at line 125 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromFile().
Referenced by bpp::AbstractIAlignment::readAlignment().
|
inlineprotectedvirtualinherited |
Read sequences from a stream.
input | The input stream to read. |
alpha | The alphabet to use. |
Exception | If the file is not in the specified format. |
Definition at line 110 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
Referenced by bpp::AbstractIAlignment::readAlignment().
|
inlineoverridevirtualinherited |
Create a new container from a file.
path | The path to the file to read. |
container | The container where to add data. |
Exception | If the file is not in the specified format. |
Implements bpp::ISequence.
Definition at line 162 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromFile().
|
inlineoverridevirtualinherited |
Create a new container from a file.
path | The path to the file to read. |
alpha | The alphabet to be associated to the container. |
Exception | If the file is not in the specified format. |
Implements bpp::ISequence.
Reimplemented in bpp::Phylip, bpp::DCSE, and bpp::Clustal.
Definition at line 174 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::readAlignment().
|
inlineoverridevirtualinherited |
Create a new container from a stream.
input | The input stream to read. |
container | The container where to add data. |
Exception | If the file is not in the specified format. |
Implements bpp::ISequence.
Definition at line 157 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::appendAlignmentFromStream().
|
inlineoverridevirtualinherited |
Create a new container from a stream.
input | The input stream to read. |
alpha | The alphabet to be associated to the container. |
Exception | If the file is not in the specified format. |
Implements bpp::ISequence.
Reimplemented in bpp::Phylip, bpp::DCSE, and bpp::Clustal.
Definition at line 167 of file AbstractIAlignment.h.
References bpp::AbstractIAlignment::readAlignment().
|
private |
Definition at line 23 of file NexusIoSequence.cpp.
References bpp::TextTools::removeFirstWhiteSpaces(), and bpp::TextTools::removeSurroundingWhiteSpaces().
|
protected |
The maximum number of chars to be written on a line.
Definition at line 42 of file NexusIoSequence.h.
|
protected |
Definition at line 44 of file NexusIoSequence.h.
Referenced by checkNames().