rna_transcription: iteration 1
This commit is contained in:
parent
0658b6a066
commit
1e2dd2cf99
2 changed files with 37 additions and 0 deletions
25
cpp/rna-transcription/rna_transcription.cpp
Normal file
25
cpp/rna-transcription/rna_transcription.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include "rna_transcription.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace transcription {
|
||||
|
||||
using namespace std;
|
||||
|
||||
char to_rna(char c)
|
||||
{
|
||||
static const unordered_map<char, char> nucleotide_map =
|
||||
{{'C', 'G'}, {'G', 'C'}, {'A', 'U'}, {'T', 'A'}};
|
||||
|
||||
return nucleotide_map.at(c);
|
||||
}
|
||||
|
||||
string to_rna(string str)
|
||||
{
|
||||
transform(str.begin(), str.end(), str.begin(),
|
||||
static_cast<char (*)(char)>(&to_rna));
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue