bpp-seq3  3.0.0
Clustal.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_SEQ_IO_CLUSTAL_H
6 #define BPP_SEQ_IO_CLUSTAL_H
7 
8 
9 #include "../Container/SiteContainer.h"
10 #include "AbstractIAlignment.h"
11 #include "AbstractOAlignment.h"
12 
13 // From the STL:
14 #include <iostream>
15 
16 namespace bpp
17 {
23 class Clustal :
24  public AbstractIAlignment2,
25  public AbstractOAlignment
26 {
27 private:
29  unsigned int nbSpacesBeforeSeq_;
30  unsigned int charsByLine_;
31 
32 public:
40  Clustal(bool checkSequenceNames = true, unsigned int nbExtraSpacesBeforeSeq = 5, unsigned int charsByLine = 100) :
41  checkNames_(checkSequenceNames),
42  nbSpacesBeforeSeq_(nbExtraSpacesBeforeSeq + 1),
43  charsByLine_(charsByLine)
44  {}
45 
46  virtual ~Clustal() {}
47 
48 public:
54  void appendAlignmentFromStream(std::istream& input, SequenceContainerInterface& sc) const override;
65  std::unique_ptr<SequenceContainerInterface> readSequences(std::istream& input, std::shared_ptr<const Alphabet> alpha) const override
66  {
67  return readAlignment(input, alpha);
68  }
69 
70  std::unique_ptr<SequenceContainerInterface> readSequences(const std::string& path, std::shared_ptr<const Alphabet> alpha) const override
71  {
72  return readAlignment(path, alpha);
73  }
81  void writeAlignment(std::ostream& output, const SiteContainerInterface& sc) const override;
82 
83  void writeAlignment(const std::string& path, const SiteContainerInterface& sc, bool overwrite = true) const override
84  {
85  AbstractOAlignment::writeAlignment(path, sc, overwrite);
86  }
94  const std::string getFormatName() const override { return "Clustal"; }
95 
96  const std::string getFormatDescription() const override { return "The Clustal alignment tool output format."; }
97 
103  bool checkNames() const { return checkNames_; }
104 
110  void checkNames(bool yn) { checkNames_ = yn; }
111 };
112 } // end of namespace bpp.
113 #endif // BPP_SEQ_IO_CLUSTAL_H
Partial implementation of the IAlignment and ISequence interface, dedicated to alignment readers.
virtual void readAlignment(std::istream &input, SequenceContainerInterface &sc) const override
Add sequences to a container from a stream.
Partial implementation of the OAlignment interface.
void writeAlignment(std::ostream &output, const SiteContainerInterface &sc) const override=0
Write a container to a stream.
The clustal sequence file format.
Definition: Clustal.h:26
virtual ~Clustal()
Definition: Clustal.h:46
void writeAlignment(std::ostream &output, const SiteContainerInterface &sc) const override
Write a container to a stream.
Definition: Clustal.cpp:93
unsigned int nbSpacesBeforeSeq_
Definition: Clustal.h:29
void checkNames(bool yn)
Tell whether the sequence names should be checked when reading from files.
Definition: Clustal.h:110
unsigned int charsByLine_
Definition: Clustal.h:30
std::unique_ptr< SequenceContainerInterface > readSequences(const std::string &path, std::shared_ptr< const Alphabet > alpha) const override
Create a new container from a file.
Definition: Clustal.h:70
void writeAlignment(const std::string &path, const SiteContainerInterface &sc, bool overwrite=true) const override
Write a container to a file.
Definition: Clustal.h:83
const std::string getFormatDescription() const override
Definition: Clustal.h:96
std::unique_ptr< SequenceContainerInterface > readSequences(std::istream &input, std::shared_ptr< const Alphabet > alpha) const override
Create a new container from a stream.
Definition: Clustal.h:65
void appendAlignmentFromStream(std::istream &input, SequenceContainerInterface &sc) const override
Append sequences to a container from a stream.
Definition: Clustal.cpp:18
bool checkNames_
Definition: Clustal.h:28
const std::string getFormatName() const override
Definition: Clustal.h:94
bool checkNames() const
Definition: Clustal.h:103
Clustal(bool checkSequenceNames=true, unsigned int nbExtraSpacesBeforeSeq=5, unsigned int charsByLine=100)
Build a new Clustal object.
Definition: Clustal.h:40
The SequenceContainer interface.
This alphabet is used to deal NumericAlphabet.