Skip to content

Commit 61e26b9

Browse files
Exercises - Protein Translation - Patch 1 (to clarify biological terminology) (#1048)
* Update protein_translation.h to clarify terminology Renamed typedef statements to better reflect biological terminology: Methionine, Serine, etc. are examples of amino acids, and a protein is a sequence of several amino acids. A single RNA strand corresponds to one protein, not several. * Update test_protein_translation.c to clarify terminology proteins_t => protein_t A single RNA strand corresponds to a single protein. * Update example.h to clarify terminology Renamed typedef statements to better reflect biological terminology: Methionine, Serine, etc. are examples of amino acids, and a protein is a sequence of several amino acids. A single RNA strand corresponds to one protein, not several. * Update example.c to reflect clarified terminology Renamed some variables and type definitions to match biological terminology: one codon corresponds to one amino acid, and one RNA sequence of several amino acids corresponds to one protein. * Apply suggested fixes --------- Co-authored-by: Ryan Hartlage <ryanplusplus@gmail.com>
1 parent e1c68d5 commit 61e26b9

4 files changed

Lines changed: 145 additions & 144 deletions

File tree

exercises/practice/protein-translation/.meta/example.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ enum { codon_length = 3 };
55

66
typedef struct {
77
const char *const codon;
8-
protein_t protein;
8+
amino_acid_t amino_acid;
99
bool stop;
10-
} protein_translation_t;
10+
} amino_acid_translation_t;
1111

12-
static const protein_translation_t translations[] = {
12+
static const amino_acid_translation_t translations[] = {
1313
{ "AUG", Methionine, false },
1414
{ "UUU", Phenylalanine, false },
1515
{ "UUC", Phenylalanine, false },
@@ -31,9 +31,9 @@ static const protein_translation_t translations[] = {
3131
static const size_t translation_count =
3232
sizeof(translations) / sizeof(translations[0]);
3333

34-
proteins_t proteins(const char *const rna)
34+
protein_t protein(const char *const rna)
3535
{
36-
proteins_t proteins = { .valid = true, .count = 0 };
36+
protein_t protein = { .valid = true, .count = 0 };
3737

3838
size_t rna_length = strlen(rna);
3939

@@ -43,20 +43,21 @@ proteins_t proteins(const char *const rna)
4343
for (size_t j = 0; j < translation_count; j++) {
4444
if (strncmp(rna + i, translations[j].codon, codon_length) == 0) {
4545
if (translations[j].stop) {
46-
return proteins;
46+
return protein;
4747
} else {
48-
proteins.proteins[proteins.count++] = translations[j].protein;
48+
protein.amino_acids[protein.count++] =
49+
translations[j].amino_acid;
4950
found_codon = true;
5051
break;
5152
}
5253
}
5354
}
5455

5556
if (!found_codon) {
56-
proteins.valid = false;
57-
return proteins;
57+
protein.valid = false;
58+
return protein;
5859
}
5960
}
6061

61-
return proteins;
62+
return protein;
6263
}

exercises/practice/protein-translation/.meta/example.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <stdbool.h>
55
#include <stddef.h>
66

7-
#define MAX_PROTEINS 10
7+
#define MAX_AMINO_ACIDS 10
88

99
typedef enum {
1010
Methionine,
@@ -14,14 +14,14 @@ typedef enum {
1414
Tyrosine,
1515
Cysteine,
1616
Tryptophan,
17-
} protein_t;
17+
} amino_acid_t;
1818

1919
typedef struct {
2020
bool valid;
2121
size_t count;
22-
protein_t proteins[MAX_PROTEINS];
23-
} proteins_t;
22+
amino_acid_t amino_acids[MAX_AMINO_ACIDS];
23+
} protein_t;
2424

25-
proteins_t proteins(const char *const rna);
25+
protein_t protein(const char *const rna);
2626

2727
#endif

exercises/practice/protein-translation/protein_translation.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <stdbool.h>
55
#include <stddef.h>
66

7-
#define MAX_PROTEINS 10
7+
#define MAX_AMINO_ACIDS 10
88

99
typedef enum {
1010
Methionine,
@@ -14,14 +14,14 @@ typedef enum {
1414
Tyrosine,
1515
Cysteine,
1616
Tryptophan,
17-
} protein_t;
17+
} amino_acid_t;
1818

1919
typedef struct {
2020
bool valid;
2121
size_t count;
22-
protein_t proteins[MAX_PROTEINS];
23-
} proteins_t;
22+
amino_acid_t amino_acids[MAX_AMINO_ACIDS];
23+
} protein_t;
2424

25-
proteins_t proteins(const char *const rna);
25+
protein_t protein(const char *const rna);
2626

2727
#endif

0 commit comments

Comments
 (0)