5 #ifndef BPP_SEQ_IO_MASE_H
6 #define BPP_SEQ_IO_MASE_H
11 #include "../Container/SequenceContainer.h"
12 #include "../Container/VectorSequenceContainer.h"
13 #include "../Sequence.h"
28 mutable std::map<std::string, std::string>
trees_;
45 const std::string&
getTree(
const std::string& name)
const
53 throw Exception(
"MaseHeader::getTree. No tree with name " + name);
64 throw Exception(
"MaseHeader::getSiteSelection. No site selection with name " + name);
75 throw Exception(
"MaseHeader::getSequenceSelection. No sequence selection with name " + name);
79 void setTree(
const std::string& name,
const std::string& tree)
133 std::unique_ptr<SequenceContainerInterface>
readMeta(std::istream& input, std::shared_ptr<const Alphabet>& alpha,
MaseHeader& header)
const
139 std::unique_ptr<SequenceContainerInterface>
readMeta(std::string& path, std::shared_ptr<const Alphabet>& alpha,
MaseHeader& header)
const
141 std::ifstream input(path.c_str(), std::ios::in);
142 auto sc =
readMeta(input, alpha, header);
194 std::ofstream output(path.c_str(), overwrite ? (std::ios::out) : (std::ios::out | std::ios::app));
210 return "Optional file comments (preceded by ;;), sequence comments (preceded by ;), sequence name, sequence";
Partial implementation of the IAlignment interface, dedicated to alignment readers.
Partial implementation of the ISequence interface.
void readSequences(std::istream &input, SequenceContainerInterface &sc) const override
Add sequences to a container from a stream.
Partial implementation of the OAlignment interface.
void writeSequences(std::ostream &output, const SequenceContainerInterface &sc) const override=0
Write a container to a stream.
The mase sequence file format.
void appendSequencesFromStream(std::istream &input, SequenceContainerInterface &sc) const override
Append sequences to a container from a stream.
void writeMeta(std::ostream &output, const SequenceContainerInterface &sc, const MaseHeader &header) const
Mase(unsigned int charsByLine=100, bool checkSequenceNames=true)
Build a new Mase object.
void checkNames(bool yn)
Tell whether the sequence names should be checked when reading from files.
void writeSequences(std::ostream &output, const SequenceContainerInterface &sc) const override
Write a container to a stream.
void writeHeader_(std::ostream &output, const MaseHeader &header) const
unsigned int charsByLine_
The maximum number of chars to be written on a line.
const std::string getFormatName() const override
void appendAlignmentFromStream(std::istream &input, SequenceContainerInterface &sc) const override
Append sequences to a container from a stream.
void writeSequences(const std::string &path, const SequenceContainerInterface &sc, bool overwrite=true) const override
Write a container to a file.
const std::string getFormatDescription() const override
std::unique_ptr< SequenceContainerInterface > readMeta(std::string &path, std::shared_ptr< const Alphabet > &alpha, MaseHeader &header) const
std::unique_ptr< SequenceContainerInterface > readMeta(std::istream &input, std::shared_ptr< const Alphabet > &alpha, MaseHeader &header) const
void writeMeta(const std::string &path, const SequenceContainerInterface &sc, const MaseHeader &header, bool overwrite=true) const
void readHeader_(std::istream &input, MaseHeader &header) const
The SequenceContainer interface.
This alphabet is used to deal NumericAlphabet.