bpp-seq3  3.0.0
AbstractOAlignment.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_ABSTRACTOALIGNMENT_H
6 #define BPP_SEQ_IO_ABSTRACTOALIGNMENT_H
7 
8 
9 #include "../Alphabet/Alphabet.h"
10 #include "../Container/VectorSequenceContainer.h"
11 #include "OSequence.h"
12 
13 // From the STL:
14 #include <string>
15 #include <fstream>
16 
17 namespace bpp
18 {
23  public virtual OAlignment
24 {
25 public:
27  virtual ~AbstractOAlignment() {}
28 
29 public:
35  void writeAlignment(std::ostream& output, const SiteContainerInterface& sc) const override = 0;
36 
37  void writeAlignment(const std::string& path, const SiteContainerInterface& sc, bool overwrite = true) const override
38  {
39  // Open file in specified mode
40  std::ofstream output(path.c_str(), overwrite ? (std::ios::out) : (std::ios::out | std::ios::app));
41  writeAlignment(output, sc);
42  output.close();
43  }
45 };
46 
51  public virtual OProbabilisticAlignment
52 {
53 public:
56 
57 public:
63  void writeAlignment(std::ostream& output, const ProbabilisticSiteContainerInterface& psc) const override = 0;
64 
65  void writeAlignment(const std::string& path, const ProbabilisticSiteContainerInterface& psc, bool overwrite = true) const override
66  {
67  // Open file in specified mode
68  std::ofstream output(path.c_str(), overwrite ? (std::ios::out) : (std::ios::out | std::ios::app));
69  writeAlignment(output, psc);
70  output.close();
71  }
72 
74 };
75 } // end of namespace bpp.
76 #endif // BPP_SEQ_IO_ABSTRACTOALIGNMENT_H
Partial implementation of the OAlignment interface.
void writeAlignment(const std::string &path, const SiteContainerInterface &sc, bool overwrite=true) const override
Write a container to a file.
void writeAlignment(std::ostream &output, const SiteContainerInterface &sc) const override=0
Write a container to a stream.
Partial implementation of the OProbabilisticAlignment interface.
void writeAlignment(const std::string &path, const ProbabilisticSiteContainerInterface &psc, bool overwrite=true) const override
Write a container to a file.
void writeAlignment(std::ostream &output, const ProbabilisticSiteContainerInterface &psc) const override=0
Write a container to a stream.
The OAlignment interface.
Definition: OSequence.h:58
The OProbabilisticAlignment interface.
Definition: OSequence.h:127
This alphabet is used to deal NumericAlphabet.