3
// Created by: Julien Dutheil
4
// Created on: Mon Oct 27 12:22:56 2003
8
Copyright or © or Copr. CNRS, (November 17, 2004)
10
This software is a computer program whose purpose is to provide classes
11
for sequences analysis.
13
This software is governed by the CeCILL license under French law and
14
abiding by the rules of distribution of free software. You can use,
15
modify and/ or redistribute the software under the terms of the CeCILL
16
license as circulated by CEA, CNRS and INRIA at the following URL
17
"http://www.cecill.info".
19
As a counterpart to the access to the source code and rights to copy,
20
modify and redistribute granted by the license, users are provided only
21
with a limited warranty and the software's author, the holder of the
22
economic rights, and the successive licensors have only limited
25
In this respect, the user's attention is drawn to the risks associated
26
with loading, using, modifying and/or developing or reproducing the
27
software by the user in light of its specific status of free software,
28
that may mean that it is complicated to manipulate, and that also
29
therefore means that it is reserved for developers and experienced
30
professionals having in-depth computer knowledge. Users are therefore
31
encouraged to load and test the software's suitability as regards their
32
requirements in conditions enabling the security of their systems and/or
33
data to be ensured and, more generally, to use and operate it in the
34
same conditions as regards security.
36
The fact that you are presently reading this means that you have had
37
knowledge of the CeCILL license and that you accept its terms.
43
#include "AbstractISequence2.h"
44
#include "AbstractOSequence.h"
45
#include "../Sequence.h"
46
#include "../Container/SequenceContainer.h"
47
#include "../Container/VectorSequenceContainer.h"
48
#include "../Container/AlignedSequenceContainer.h"
57
* @brief The Phylip & co format.
59
* An AlignedSequenceContainer is used instead of a VectorSequenceContainer.
61
* This format is described on the Phylip package documentation website:
62
* http://evolution.genetics.washington.edu/phylip/doc/sequence.html
65
public AbstractIAlignment,
66
public AbstractOAlignment
70
/* this class allows two kind of Phylip format:
71
* traditional, with names limited to 10 chars,
72
* and 'extended', defined by PAML, with names separated from sequences by at least 6 white spaces.
75
/* tells if sequences are in the seuqential or the interleave format/
80
* @brief The maximum number of chars to be written on a line.
82
unsigned int charsByLine_;
86
std::string namesSplit_;
90
* @brief Build a new Phylip file reader.
92
* @param extended If true, sequences with names longer than 10 characters are allowed.
93
* @param sequential If false, sequences are supposed to be interlaved.
94
* @param charsByLine The number of base to display in a row.
95
* @param 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).
96
* @param split The string to use to split sequence name from content (only for 'extended' format). This will typically be " " (two spaces) or "\t" (a tabulation).
98
Phylip(bool extended = true, bool sequential = true, unsigned int charsByLine = 100, bool checkSequenceNames = true, const std::string& split = " "):
99
extended_(extended), sequential_(sequential), charsByLine_(charsByLine), checkNames_(checkSequenceNames), namesSplit_(split) {}
106
* @name The AbstractISequence2 interface.
110
void appendFromStream(std::istream& input, SiteContainer& sc) const throw (Exception);
114
* @return The number of sequences contained in the specified file.
116
* This methods parses the firt line of the phylip file.
117
* @param path The path of the file to parse.
119
unsigned int getNumberOfSequences(const std::string& path) const throw (IOException);
122
* @name The OSequence interface.
126
void write(std::ostream& output, const SiteContainer& sc) const throw (Exception);
127
void write(const std::string& path, const SiteContainer& sc, bool overwrite) const throw (Exception)
129
AbstractOAlignment::write(path, sc, overwrite);
135
* @name The IOSequence interface.
139
const std::string getFormatName() const;
140
const std::string getFormatDescription() const;
144
* @return true if the names are to be checked when reading sequences from files.
146
bool checkNames() const { return checkNames_; }
149
* @brief Tell whether the sequence names should be checked when reading from files.
151
* @param yn whether the sequence names should be checked when reading from files.
153
void checkNames(bool yn) { checkNames_ = yn; }
156
* @return The string used to split sequence name from content.
158
const std::string& getSplit() const { return namesSplit_; }
161
* @param split The string to be used to split sequence name from content.
163
void setSplit(const std::string& split) { namesSplit_ = split; }
167
const std::vector<std::string> splitNameAndSequence(const std::string& s) const throw (Exception);
168
void readSequential (std::istream& in, SiteContainer& asc) const throw (Exception);
169
void readInterleaved(std::istream& in, SiteContainer& asc) const throw (Exception);
171
std::vector<std::string> getSizedNames(const std::vector<std::string>& names) const;
172
void writeSequential (std::ostream& out, const SequenceContainer& sc, int charsByLine) const;
173
void writeInterleaved(std::ostream& out, const SequenceContainer& sc, int charsByLine) const;
176
} //end of namespace bpp.