|
1 |
| -local translate = require('protein-translation') |
| 1 | +local protein_translation = require('protein-translation') |
2 | 2 |
|
3 | 3 | describe('protein-translation', function()
|
4 |
| - describe('translate.codon', function() |
5 |
| - it('should translate AUG to Methionine', function() |
6 |
| - assert.equal('Methionine', translate.codon('AUG')) |
7 |
| - end) |
| 4 | + it('empty rna sequence results in no proteins', function() |
| 5 | + assert.are.same({}, protein_translation.proteins('')) |
| 6 | + end) |
8 | 7 |
|
9 |
| - it('should translate UUU and UUC to Phenylalanine', function() |
10 |
| - assert.equal('Phenylalanine', translate.codon('UUU')) |
11 |
| - assert.equal('Phenylalanine', translate.codon('UUC')) |
12 |
| - end) |
| 8 | + it('methionine rna sequence', function() |
| 9 | + assert.are.same({ 'Methionine' }, protein_translation.proteins('AUG')) |
| 10 | + end) |
13 | 11 |
|
14 |
| - it('should translate UUA and UUG to Leucine', function() |
15 |
| - assert.equal('Leucine', translate.codon('UUA')) |
16 |
| - assert.equal('Leucine', translate.codon('UUG')) |
17 |
| - end) |
| 12 | + it('phenylalanine rna sequence 1', function() |
| 13 | + assert.are.same({ 'Phenylalanine' }, protein_translation.proteins('UUU')) |
| 14 | + end) |
18 | 15 |
|
19 |
| - it('should translate UCU, UCC, UCA, and UCG to Serine', function() |
20 |
| - assert.equal('Serine', translate.codon('UCU')) |
21 |
| - assert.equal('Serine', translate.codon('UCC')) |
22 |
| - assert.equal('Serine', translate.codon('UCA')) |
23 |
| - assert.equal('Serine', translate.codon('UCG')) |
24 |
| - end) |
| 16 | + it('phenylalanine rna sequence 2', function() |
| 17 | + assert.are.same({ 'Phenylalanine' }, protein_translation.proteins('UUC')) |
| 18 | + end) |
25 | 19 |
|
26 |
| - it('should translate UAU and UAC to Tyrosine', function() |
27 |
| - assert.equal('Tyrosine', translate.codon('UAU')) |
28 |
| - assert.equal('Tyrosine', translate.codon('UAC')) |
29 |
| - end) |
| 20 | + it('leucine rna sequence 1', function() |
| 21 | + assert.are.same({ 'Leucine' }, protein_translation.proteins('UUA')) |
| 22 | + end) |
30 | 23 |
|
31 |
| - it('should translate UGU and UGC to Cysteine', function() |
32 |
| - assert.equal('Cysteine', translate.codon('UGU')) |
33 |
| - assert.equal('Cysteine', translate.codon('UGC')) |
34 |
| - end) |
| 24 | + it('leucine rna sequence 2', function() |
| 25 | + assert.are.same({ 'Leucine' }, protein_translation.proteins('UUG')) |
| 26 | + end) |
35 | 27 |
|
36 |
| - it('should translate UGG to Tryptophan', function() |
37 |
| - assert.equal('Tryptophan', translate.codon('UGG')) |
38 |
| - end) |
| 28 | + it('serine rna sequence 1', function() |
| 29 | + assert.are.same({ 'Serine' }, protein_translation.proteins('UCU')) |
| 30 | + end) |
39 | 31 |
|
40 |
| - it('should translate UAA, UAG, and UGA to STOP codons', function() |
41 |
| - assert.equal('STOP', translate.codon('UAA')) |
42 |
| - assert.equal('STOP', translate.codon('UAG')) |
43 |
| - assert.equal('STOP', translate.codon('UGA')) |
44 |
| - end) |
| 32 | + it('serine rna sequence 2', function() |
| 33 | + assert.are.same({ 'Serine' }, protein_translation.proteins('UCC')) |
| 34 | + end) |
45 | 35 |
|
46 |
| - it('should raise an error when an unknown codon is translated', function() |
47 |
| - assert.has_error(function() |
48 |
| - translate.codon('MIA') |
49 |
| - end) |
50 |
| - end) |
| 36 | + it('serine rna sequence 3', function() |
| 37 | + assert.are.same({ 'Serine' }, protein_translation.proteins('UCA')) |
51 | 38 | end)
|
52 | 39 |
|
53 |
| - describe('translate.rna_strand', function() |
54 |
| - it('should translate each codon in a strand into the corresponding protein', function() |
55 |
| - assert.same({ 'Methionine', 'Phenylalanine', 'Tryptophan' }, translate.rna_strand('AUGUUUUGG')) |
56 |
| - end) |
| 40 | + it('serine rna sequence 4', function() |
| 41 | + assert.are.same({ 'Serine' }, protein_translation.proteins('UCG')) |
| 42 | + end) |
57 | 43 |
|
58 |
| - it('should stop translation when a STOP codon is encountered', function() |
59 |
| - assert.same({ 'Methionine', 'Phenylalanine' }, translate.rna_strand('AUGUUUUAA')) |
60 |
| - assert.same({ 'Tryptophan', 'Cysteine', 'Tyrosine' }, translate.rna_strand('UGGUGUUAUUAAUGGUUU')) |
61 |
| - end) |
| 44 | + it('tyrosine rna sequence 1', function() |
| 45 | + assert.are.same({ 'Tyrosine' }, protein_translation.proteins('UAU')) |
| 46 | + end) |
62 | 47 |
|
63 |
| - it('should raise an error when an unknown codon is encountered', function() |
64 |
| - assert.has_error(function() |
65 |
| - translate.rna_strand('UGUCARROT') |
66 |
| - end) |
67 |
| - end) |
| 48 | + it('tyrosine rna sequence 2', function() |
| 49 | + assert.are.same({ 'Tyrosine' }, protein_translation.proteins('UAC')) |
| 50 | + end) |
| 51 | + |
| 52 | + it('cysteine rna sequence 1', function() |
| 53 | + assert.are.same({ 'Cysteine' }, protein_translation.proteins('UGU')) |
| 54 | + end) |
68 | 55 |
|
69 |
| - it('should not raise an error when an unknown codon occurs after a STOP codon', function() |
70 |
| - assert.same({ 'Cysteine' }, translate.rna_strand('UGUUGACARROT')) |
| 56 | + it('cysteine rna sequence 2', function() |
| 57 | + assert.are.same({ 'Cysteine' }, protein_translation.proteins('UGC')) |
| 58 | + end) |
| 59 | + |
| 60 | + it('tryptophan rna sequence', function() |
| 61 | + assert.are.same({ 'Tryptophan' }, protein_translation.proteins('UGG')) |
| 62 | + end) |
| 63 | + |
| 64 | + it('stop codon rna sequence 1', function() |
| 65 | + assert.are.same({}, protein_translation.proteins('UAA')) |
| 66 | + end) |
| 67 | + |
| 68 | + it('stop codon rna sequence 2', function() |
| 69 | + assert.are.same({}, protein_translation.proteins('UAG')) |
| 70 | + end) |
| 71 | + |
| 72 | + it('stop codon rna sequence 3', function() |
| 73 | + assert.are.same({}, protein_translation.proteins('UGA')) |
| 74 | + end) |
| 75 | + |
| 76 | + it('sequence of two protein codons translates into proteins', function() |
| 77 | + assert.are.same({ 'Phenylalanine', 'Phenylalanine' }, protein_translation.proteins('UUUUUU')) |
| 78 | + end) |
| 79 | + |
| 80 | + it('sequence of two different protein codons translates into proteins', function() |
| 81 | + assert.are.same({ 'Leucine', 'Leucine' }, protein_translation.proteins('UUAUUG')) |
| 82 | + end) |
| 83 | + |
| 84 | + it('translate rna strand into correct protein list', function() |
| 85 | + assert.are.same({ 'Methionine', 'Phenylalanine', 'Tryptophan' }, protein_translation.proteins('AUGUUUUGG')) |
| 86 | + end) |
| 87 | + |
| 88 | + it('translation stops if stop codon at beginning of sequence', function() |
| 89 | + assert.are.same({}, protein_translation.proteins('UAGUGG')) |
| 90 | + end) |
| 91 | + |
| 92 | + it('translation stops if stop codon at end of two-codon sequence', function() |
| 93 | + assert.are.same({ 'Tryptophan' }, protein_translation.proteins('UGGUAG')) |
| 94 | + end) |
| 95 | + |
| 96 | + it('translation stops if stop codon at end of three-codon sequence', function() |
| 97 | + assert.are.same({ 'Methionine', 'Phenylalanine' }, protein_translation.proteins('AUGUUUUAA')) |
| 98 | + end) |
| 99 | + |
| 100 | + it('translation stops if stop codon in middle of three-codon sequence', function() |
| 101 | + assert.are.same({ 'Tryptophan' }, protein_translation.proteins('UGGUAGUGG')) |
| 102 | + end) |
| 103 | + |
| 104 | + it('translation stops if stop codon in middle of six-codon sequence', function() |
| 105 | + assert.are.same({ 'Tryptophan', 'Cysteine', 'Tyrosine' }, protein_translation.proteins('UGGUGUUAUUAAUGGUUU')) |
| 106 | + end) |
| 107 | + |
| 108 | + it('sequence of two non-stop codons does not translate to a stop codon', function() |
| 109 | + assert.are.same({ 'Methionine', 'Methionine' }, protein_translation.proteins('AUGAUG')) |
| 110 | + end) |
| 111 | + |
| 112 | + it('unknown amino acids, not part of a codon, can\'t translate', function() |
| 113 | + assert.has_error(function() |
| 114 | + protein_translation.proteins('XYZ') |
71 | 115 | end)
|
72 | 116 | end)
|
| 117 | + |
| 118 | + it('incomplete rna sequence can translate if valid until a stop codon', function() |
| 119 | + assert.are.same({ 'Phenylalanine', 'Phenylalanine' }, protein_translation.proteins('UUCUUCUAAUGGU')) |
| 120 | + end) |
73 | 121 | end)
|
0 commit comments