diff options
Diffstat (limited to 'c/rna-transcription/src')
-rw-r--r-- | c/rna-transcription/src/rna_transcription.c | 16 | ||||
-rw-r--r-- | c/rna-transcription/src/rna_transcription.h | 6 |
2 files changed, 22 insertions, 0 deletions
diff --git a/c/rna-transcription/src/rna_transcription.c b/c/rna-transcription/src/rna_transcription.c new file mode 100644 index 0000000..2328f72 --- /dev/null +++ b/c/rna-transcription/src/rna_transcription.c @@ -0,0 +1,16 @@ +#include "rna_transcription.h" +#include <string.h> +#include <stdlib.h> + +char *to_rna(const char *dna) { + size_t len = strlen(dna); + char *rna = calloc(len + 1, sizeof(*rna)); + for (size_t idx = 0; idx < len; idx++) + switch (dna[idx]) { + case 'G': rna[idx] = 'C'; break; + case 'C': rna[idx] = 'G'; break; + case 'T': rna[idx] = 'A'; break; + case 'A': rna[idx] = 'U'; break; + } + return rna; +} diff --git a/c/rna-transcription/src/rna_transcription.h b/c/rna-transcription/src/rna_transcription.h new file mode 100644 index 0000000..af10db9 --- /dev/null +++ b/c/rna-transcription/src/rna_transcription.h @@ -0,0 +1,6 @@ +#ifndef RNA_TRANSCRIPTION_H +#define RNA_TRANSCRIPTION_H + +char *to_rna(const char *dna); + +#endif |