This entry uses the same example of DNA sequence translation into protein as was described in an earlier entry where VBA was used. As in that example, the code deals with DNA sequence ambiguity expressed using IUPAC codes (R = A and G mixture). This is its only novel or interesting feature from a functionality point of view in the example given.
The aims of this entry are to:
- A simple web page
- In a Google spreadsheet
- In server-side Node.js
The code is on GitHub
- Copy the HTML to a file named "DNA_Translator.html"
- Save this in a location recognized by your web server (On my Mac running Apache, I save it to "/Library/WebServer/Documents/".
- View the web page using the URL http://localhost/DNA_Translator.html
- Assuming the web server is is working, you should see a crude form with two inpout textareas and one button, screenshot:
To do this:
- Create a new Google spreadsheet.
- Paste the code containing the user-defined functions in this GitHub link into the script editor.
- Add another script file by selecting File->New->Script File in the script editor and paste in the code from this GitHub link.
- To use call the functionality as UDFs, enter these dummy DNA sequence values in cells A1 and A2:
- In cell B1, this function call "=getTripletsFromDNA(A1, "|")" produces AAA|CCC|GGG|TTT
- while "=getTripletsFromDNA(A2 "|")" gives RAA|CCC|GGG|TTT
- To test the translation of these two dummy sequences enter the formulas "=getAminoAcidsFromDNA(A1,"|")" and "=getAminoAcidsFromDNA(A2,"|")" into cells C1 and C2, respectively. The output from these calls is:
See how the R is dealt with in the second call, it results in a double amino acid mixture.