forked from packetzero/code1920
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ribosome_test.go
54 lines (46 loc) · 1.52 KB
/
ribosome_test.go
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
package microbio
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTranslate(t *testing.T) {
ribosome := Ribosome{}
rna := MakeStrand([]byte("UACGGGAUGUCACCUACGGUAUAACGCGGG"), RIBOSE)
protein := ribosome.Translate(rna)
assert.Equal(t, "SER-PRO-THR-VAL", protein.String())
}
func TestTranslateEmpty(t *testing.T) {
ribosome := Ribosome{}
rna := MakeStrand([]byte(""), RIBOSE)
protein := ribosome.Translate(rna)
assert.Equal(t, "", protein.String())
}
// Make sure Translate doesn't crash when a full 3-base codon
// is not remaining in strand
func TestTranslateInvalidLength(t *testing.T) {
ribosome := Ribosome{}
rna := MakeStrand([]byte("UACGGGAUGUCACCUAC"), RIBOSE)
protein := ribosome.Translate(rna)
assert.Equal(t, 0, len(protein))
assert.Equal(t, "", protein.String())
rna = MakeStrand([]byte("UACGGGAUGUCACCUA"), RIBOSE)
protein = ribosome.Translate(rna)
assert.Equal(t, 0, len(protein))
assert.Equal(t, "", protein.String())
}
// No 'AUG' codon, so Translate should return empty
func TestTranslateNoStart(t *testing.T) {
ribosome := Ribosome{}
rna := MakeStrand([]byte("AUAUAUAAAAGGUA"), RIBOSE)
protein := ribosome.Translate(rna)
assert.Equal(t, 0, len(protein))
assert.Equal(t, "", protein.String())
}
// See what happens when no STOP codon found
func TestTranslateNoEnd(t *testing.T) {
ribosome := Ribosome{}
rna := MakeStrand([]byte("UACGGGAUG"+"UCACCUACGGUA"+"CGCGGG"), RIBOSE)
protein := ribosome.Translate(rna)
assert.Equal(t, 0, len(protein))
assert.Equal(t, "", protein.String())
}