-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplement.cpp
More file actions
58 lines (53 loc) · 1.54 KB
/
complement.cpp
File metadata and controls
58 lines (53 loc) · 1.54 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
/*
///////////////////////////////////////////////////////////////////////////
Finds a complementary sequence of the given sequence.
Inputs:
1) R or RNA for RNA; D or DNA for DAN sequence type
2) Sequence
Output: Complimentary DNA/RNA sequence
///////////////////////////////////////////////////////////////////////////
*/
#include <cstdlib>
#include <cstdio>
#include <string>
using namespace std;
int main (int argc, char **argv)
{
if(argc==3)
{
string input = (string)argv[2];
if((string)argv[1]=="R" || (string)argv[1]=="RNA")
{
for(char &c:input)
{
if(c=='A') c='U';
else if(c=='U') c='A';
else if(c=='G') c='C';
else if(c=='C') c='G';
else if(c=='a') c='u';
else if(c=='u') c='a';
else if(c=='g') c='c';
else if(c=='c') c='g';
}
printf("%s",input.c_str());
}
else if((string)argv[1]=="D" || (string)argv[1]=="DNA")
{
for(char &c:input)
{
if(c=='A') c='T';
else if(c=='T') c='A';
else if(c=='G') c='C';
else if(c=='C') c='G';
else if(c=='a') c='t';
else if(c=='t') c='a';
else if(c=='g') c='c';
else if(c=='c') c='g';
}
printf("%s",input.c_str());
}
else printf("\n\nYour input sucks!\n\n");
}
else printf("\n\nYour input sucks!\n\n");
return 0;
}