Skip to content

Instantly share code, notes, and snippets.

@TheTomster
Created June 7, 2016 20:37
Show Gist options
  • Save TheTomster/2396006d17883e176464bfa7bee8b2d8 to your computer and use it in GitHub Desktop.
Save TheTomster/2396006d17883e176464bfa7bee8b2d8 to your computer and use it in GitHub Desktop.
#include <ctype.h>
#include <stdio.h>
int main(int argc, char **argv)
{
char line[8192];
char *j, c;
while (fgets(line, sizeof(line), stdin)) {
if (line[0] == '>') {
printf("%s", line);
continue;
}
for (j = line; *j; j++) {
switch (toupper(*j)) {
case 'A':
c = 'T';
break;
case 'C':
c = 'G';
break;
case 'G':
c = 'C';
break;
case 'T':
case 'U':
c = 'A';
break;
case 'M':
c = 'K';
break;
case 'R':
c = 'Y';
break;
case 'W':
c = 'W';
break;
case 'S':
c = 'S';
break;
case 'Y':
c = 'R';
break;
case 'K':
c = 'M';
break;
case 'V':
c = 'B';
break;
case 'H':
c = 'D';
break;
case 'D':
c = 'H';
break;
case 'B':
c = 'V';
break;
case 'N':
c = 'N';
break;
default:
c = *j;
}
printf("%c", c);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment