23 throw IOException (
"Clustal::read : fail to open file");
27 vector< unique_ptr<Sequence>> sequences;
36 string::size_type beginSeq = 0;
37 unsigned int count = 0;
38 for (
size_t i = lineRead.size(); i > 0; i--)
40 char c = lineRead[i - 1];
44 if (
count == nbSpacesBeforeSeq_)
46 beginSeq = i - 1 + nbSpacesBeforeSeq_;
54 throw IOException(
"Clustal::read. Bad input file.");
56 unsigned int countSequences = 0;
63 getline(input, lineRead,
'\n');
67 while (input && test);
74 for (
unsigned int i = 0; i < countSequences; ++i)
78 throw IOException(
"Clustal::read. Bad input file.");
79 sequences[i]->append(lineRead.substr(beginSeq));
80 getline(input, lineRead,
'\n');
86 for (
unsigned int i = 0; i < countSequences; ++i)
88 sc.
addSequence(sequences[i]->getName(), sequences[i]);
95 output <<
"CLUSTAL W (1.81) multiple sequence alignment" << endl;
105 if (seq.
getName().size() > length)
107 text.push_back(sc.
sequence(i).toString());
109 length += nbSpacesBeforeSeq_;
110 for (
unsigned int j = 0; j < text[0].size(); j += charsByLine_)
115 output << text[i].substr(j, charsByLine_) << endl;
const std::string & getName() const override
Get the name of this sequence.
void writeAlignment(std::ostream &output, const SiteContainerInterface &sc) const override
Write a container to a stream.
void appendAlignmentFromStream(std::istream &input, SequenceContainerInterface &sc) const override
Append sequences to a container from a stream.
A basic implementation of the Sequence interface.
The SequenceContainer interface.
virtual void addSequence(const HashType &sequenceKey, std::unique_ptr< SequenceType > &sequencePtr)=0
Add a sequence to the container.
virtual const SequenceType & sequence(const HashType &sequenceKey) const override=0
Retrieve a sequence object from the container.
virtual size_t getNumberOfSequences() const =0
Get the number of sequences in the container.
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
Get a pointer toward the container's alphabet.
std::string removeSurroundingWhiteSpaces(const std::string &s)
bool isEmpty(const std::string &s)
std::string resizeRight(const std::string &s, std::size_t newSize, char fill)
std::size_t count(const std::string &s, const std::string &pattern)
This alphabet is used to deal NumericAlphabet.
std::vector< std::string > Comments
Declaration of Comments type.