Skip to content

Instantly share code, notes, and snippets.

@furqanbaqai
Created August 2, 2019 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save furqanbaqai/790452e1d85cf79b7721eb0c7b3b9499 to your computer and use it in GitHub Desktop.
Save furqanbaqai/790452e1d85cf79b7721eb0c7b3b9499 to your computer and use it in GitHub Desktop.
DNA to RNA mapping using JSON
/**
*
* 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
*/
/*
const toRna = (dna) => {
var dnaInput = dna.split('');
var output = '';
dnaInput.forEach(element => {
output += DNATORNA[element];
});
return output;
};
*/
const toRna = (dna) => {
var dnaArr = dna.split('');
var rna = dnaArr.map(i => DNATORNA[i]).join('');
console.log(rna);
};
const DNATORNA = {
"G": "C",
"C": "G",
"T": "A",
"A": "U"
};
toRna('ACGTGGTCTTAA');
module.exports = {
toRna
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment