bpp-seq3  3.0.0
DNAToRNA.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_DNATORNA_H
6 #define BPP_SEQ_DNATORNA_H
7 
8 
10 #include "Alphabet/DNA.h"
11 #include "Alphabet/RNA.h"
12 #include "Transliterator.h"
13 
14 namespace bpp
15 {
23 class DNAToRNA :
25 {
26 private:
27  std::shared_ptr<const Alphabet> dna_, rna_;
28 
29 public:
32  dna_(AlphabetTools::DNA_ALPHABET),
33  rna_(AlphabetTools::RNA_ALPHABET)
34  {}
35 
36  DNAToRNA(const DNAToRNA& d2r) : AbstractReverseTransliterator(d2r), dna_(d2r.dna_), rna_(d2r.rna_) {}
37 
39  {
40  AbstractReverseTransliterator::operator=(d2r);
41  dna_ = d2r.dna_;
42  rna_ = d2r.rna_;
43  return *this;
44  }
45 
46  virtual ~DNAToRNA() {}
47 
48 public:
49  std::shared_ptr<const Alphabet> getSourceAlphabet() const override { return dna_; }
50 
51  const Alphabet& sourceAlphabet() const override { return *dna_; }
52 
53  std::shared_ptr<const Alphabet> getTargetAlphabet() const override { return rna_; }
54 
55  const Alphabet& targetAlphabet() const override { return *rna_; }
56 
57  int translate(int state) const override;
58 
59  std::string translate(const std::string& state) const override;
60 
61  std::unique_ptr<Sequence> translate(const SequenceInterface& sequence) const override
62  {
64  }
65 
66  int reverse(int state) const override;
67 
68  std::string reverse(const std::string& state) const override;
69 
70  std::unique_ptr<Sequence> reverse(const SequenceInterface& sequence) const override
71  {
73  }
74 };
75 } // end of namespace bpp.
76 #endif // BPP_SEQ_DNATORNA_H
Partial implementation of the ReverseTransliterator interface.
int reverse(int state) const override=0
Translate a given state coded as a int from target alphabet to source alphabet.
int translate(int state) const override=0
Translate a given state coded as a int from source alphabet to target alphabet.
Utilitary functions dealing with alphabets.
Definition: AlphabetTools.h:32
The Alphabet interface.
Definition: Alphabet.h:99
Reverse iterator to convert RNA to DNA.
Definition: DNAToRNA.h:25
std::unique_ptr< Sequence > reverse(const SequenceInterface &sequence) const override
Translate a whole sequence from target alphabet to source alphabet.
Definition: DNAToRNA.h:70
virtual ~DNAToRNA()
Definition: DNAToRNA.h:46
std::shared_ptr< const Alphabet > getSourceAlphabet() const override
Get the source alphabet.
Definition: DNAToRNA.h:49
int reverse(int state) const override
Translate a given state coded as a int from target alphabet to source alphabet.
Definition: DNAToRNA.cpp:28
std::shared_ptr< const Alphabet > getTargetAlphabet() const override
Get the target alphabet.
Definition: DNAToRNA.h:53
const Alphabet & targetAlphabet() const override
Get the target alphabet.
Definition: DNAToRNA.h:55
int translate(int state) const override
Translate a given state coded as a int from source alphabet to target alphabet.
Definition: DNAToRNA.cpp:12
const Alphabet & sourceAlphabet() const override
Get the source alphabet.
Definition: DNAToRNA.h:51
std::shared_ptr< const Alphabet > rna_
Definition: DNAToRNA.h:27
std::shared_ptr< const Alphabet > dna_
Definition: DNAToRNA.h:27
DNAToRNA(const DNAToRNA &d2r)
Definition: DNAToRNA.h:36
std::unique_ptr< Sequence > translate(const SequenceInterface &sequence) const override
Translate a whole sequence from source alphabet to target alphabet.
Definition: DNAToRNA.h:61
DNAToRNA & operator=(const DNAToRNA &d2r)
Definition: DNAToRNA.h:38
The sequence interface.
Definition: Sequence.h:34
This alphabet is used to deal NumericAlphabet.