-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.2.PeptideEncoding
More file actions
84 lines (69 loc) · 2.29 KB
/
Copy path2.2.PeptideEncoding
File metadata and controls
84 lines (69 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <map>
#include <string>
using namespace std;
map<string, char> RNAtable = { { "AAA", 'K' },{ "AAC", 'N' },{ "AAG", 'K' },{ "AAU", 'N' },{ "ACA", 'T' },{ "ACC", 'T' },{ "ACG", 'T' },{ "ACU", 'T' },
{ "AGA", 'R' },{ "AGC", 'S' },{ "AGG", 'R' },{ "AGU", 'S' },{ "AUA", 'I' },{ "AUC", 'I' },{ "AUG", 'M' },{ "AUU", 'I' },
{ "CAA", 'Q' },{ "CAC", 'H' },{ "CAG", 'Q' },{ "CAU", 'H' },{ "CCA", 'P' },{ "CCC", 'P' },{ "CCG", 'P' },{ "CCU", 'P' },
{ "CGA", 'R' },{ "CGC", 'R' },{ "CGG", 'R' },{ "CGU", 'R' },{ "CUA", 'L' },{ "CUC", 'L' },{ "CUG", 'L' },{ "CUU", 'L' },
{ "GAA", 'E' },{ "GAC", 'D' },{ "GAG", 'E' },{ "GAU", 'D' },{ "GCA", 'A' },{ "GCC", 'A' },{ "GCG", 'A' },{ "GCU", 'A' },
{ "GGA", 'G' },{ "GGC", 'G' },{ "GGG", 'G' },{ "GGU", 'G' },{ "GUA", 'V' },{ "GUC", 'V' },{ "GUG", 'V' },{ "GUU", 'V' },
{ "UAA", ' ' },{ "UAC", 'Y' },{ "UAG", ' ' },{ "UAU", 'Y' },{ "UCA", 'S' },{ "UCC", 'S' },{ "UCG", 'S' },{ "UCU", 'S' },
{ "UGA", ' ' },{ "UGC", 'C' },{ "UGG", 'W' },{ "UGU", 'C' },{ "UUA", 'L' },{ "UUC", 'F' },{ "UUG", 'L' },{ "UUU", 'F' } };
string Translation(string pattern) {
string peptide = "";
for (int i = 0; i < pattern.length(); i += 3) {
peptide += RNAtable.at(pattern.substr(i, 3));
}
return peptide;
}
string Transcription(string dna) {
string rna = "";
for (int i = 0; i < dna.length(); i++) {
if (dna[i] == 'T') {
rna += 'U';
}
else {
rna += dna[i];
}
}
return rna;
}
string reversePattern(string pattern) {
string reversePattern;
for (int i = 0; i < pattern.length(); i++)
{
switch (pattern[i])
{
case 'T':
reversePattern = 'A' + reversePattern;
break;
case 'A':
reversePattern = 'T' + reversePattern;
break;
case 'G':
reversePattern = 'C' + reversePattern;
break;
case 'C':
reversePattern = 'G' + reversePattern;
break;
}
}
return reversePattern;
}
int main() {
string dna, peptide, rna, reverseRNA, tmp;
cin >> dna;
cin >> peptide;
for (int i = 0; i < dna.length() - peptide.length() * 3 + 1; i++)
{
rna = Transcription(dna.substr(i, peptide.length() * 3));
tmp = reversePattern(dna.substr(i, peptide.length() * 3));
reverseRNA = Transcription(tmp);
if (peptide == Translation(rna) || peptide == Translation(reverseRNA))
{
cout << dna.substr(i, peptide.length() * 3) << endl;
}
}
return 0;
}