🎉 Exercism Research is now launched. Help Exercism, help science and have some fun at research.exercism.io 🎉
Avatar of cedricvaneer

cedricvaneer's solution

to RNA Transcription in the CFML Track

Published at Jan 20 2020 · 0 comments
Test suite

Given a DNA strand, return 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 code in this exercise, you will only need to have CommandBox CLI installed. This binary runs CFML code from the command line.

To run the tests, cd into the exercise folder and run the following:

box task run TestRunner
# Or start up a test watcher that will rerun when files change
box task run TestRunner --:watcher

The tests leverage a library called TestBox which supports xUnit and BDD style of testing. All test suites will be written in the BDD style which uses closures to define test specs. You won't need to worry about installing TestBox. The CLI test runner will take care of that for you. You just need to be connected to the internet the first time you run it. You can read more about it here:



Hyperphysics http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.


component extends="testbox.system.BaseSpec" {

	function beforeAll(){
	  SUT = createObject( 'RnaTranscription' );

	function run(){
		describe( "My RnaTranscription class", function(){			

			it( 'RNA complement of cytosine is guanine', function(){
				expect( SUT.toRna( dna='C' ) ).toBe( 'G' );

			it( 'RNA complement of guanine is cytosine', function(){
				expect( SUT.toRna( dna='G' ) ).toBe( 'C' );

			it( 'RNA complement of thymine is adenine', function(){
				expect( SUT.toRna( dna='T' ) ).toBe( 'A' );

			it( 'RNA complement of adenine is uracil', function(){
				expect( SUT.toRna( dna='A' ) ).toBe( 'U' );

			it( 'RNA complement', function(){
				expect( SUT.toRna( dna='ACGTGGTCTTAA' ) ).toBe( 'UGCACCAGAAUU' );



component extends="RnaTranscriptionTest" {

	function beforeAll(){
	  SUT = createObject( 'Solution' );

component {
	public string function toRNA( required string DNA ) {
		var RNA = "";
		for (var letter in listToArray(arguments.DNA, "")) {
			switch (uCase(letter)) {
				case "G":
					RNA &= "C";
				case "C":
					RNA &= "G";
				case "T":
					RNA &= "A";
				case "A":
					RNA &= "U";
		return RNA;

Community comments

Find this solution interesting? Ask the author a question to learn more.

What can you learn from this solution?

A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.

Here are some questions to help you reflect on this solution and learn the most from it.

  • What compromises have been made?
  • Are there new concepts here that you could read more about to improve your understanding?