Initial Commit
This commit is contained in:
33
go/rna-transcription/README.md
Normal file
33
go/rna-transcription/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Rna Transcription
|
||||
|
||||
Write a program that, given a DNA strand, returns its RNA complement (per RNA transcription).
|
||||
|
||||
Both DNA and RNA strands are a sequence of nucleotides.
|
||||
|
||||
The four nucleotides found in DNA are adenine (**A**), cytosine (**C**),
|
||||
guanine (**G**) and thymine (**T**).
|
||||
|
||||
The four nucleotides found in RNA are adenine (**A**), cytosine (**C**),
|
||||
guanine (**G**) and uracil (**U**).
|
||||
|
||||
Given a DNA strand, its transcribed RNA strand is formed by replacing
|
||||
each nucleotide with its complement:
|
||||
|
||||
* `G` -> `C`
|
||||
* `C` -> `G`
|
||||
* `T` -> `A`
|
||||
* `A` -> `U`
|
||||
|
||||
To run the tests simply run the command `go test` in the exercise directory.
|
||||
|
||||
If the test suite contains benchmarks, you can run these with the `-bench`
|
||||
flag:
|
||||
|
||||
go test -bench .
|
||||
|
||||
For more detailed info about the Go track see the [help
|
||||
page](http://exercism.io/languages/go).
|
||||
|
||||
## Source
|
||||
|
||||
Rosalind [view source](http://rosalind.info/problems/rna)
|
24
go/rna-transcription/cases_test.go
Normal file
24
go/rna-transcription/cases_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package strand
|
||||
|
||||
// Source: exercism/x-common
|
||||
// Commit: 6985644 Merge pull request #121 from mikeyjcat/add-roman-numerals-test-definition
|
||||
|
||||
var rnaTests = []struct {
|
||||
input string
|
||||
expected string
|
||||
}{
|
||||
// rna complement of cytosine is guanine
|
||||
{"C", "G"},
|
||||
|
||||
// rna complement of guanine is cytosine
|
||||
{"G", "C"},
|
||||
|
||||
// rna complement of thymine is adenine
|
||||
{"T", "A"},
|
||||
|
||||
// rna complement of adenine is uracil
|
||||
{"A", "U"},
|
||||
|
||||
// rna complement
|
||||
{"ACGTGGTCTTAA", "UGCACCAGAAUU"},
|
||||
}
|
25
go/rna-transcription/rna_transcription_test.go
Normal file
25
go/rna-transcription/rna_transcription_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package strand
|
||||
|
||||
import "testing"
|
||||
|
||||
const testVersion = 2
|
||||
|
||||
func TestRNATranscription(t *testing.T) {
|
||||
if TestVersion != testVersion {
|
||||
t.Fatalf("Found TestVersion = %v, want %v", TestVersion, testVersion)
|
||||
}
|
||||
for _, test := range rnaTests {
|
||||
if actual := ToRNA(test.input); actual != test.expected {
|
||||
t.Errorf("ToRNA(%s): %s, expected %s",
|
||||
test.input, actual, test.expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkRNATranscription(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, test := range rnaTests {
|
||||
ToRNA(test.input)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user