Translating a DNA to a Protein using server-side javascript and C: my notebook
In my previous post , I used Node.js to translate a DNA to a protein on the Server-side, using javascript. In the following post, I again will translate a DNAn but this time by calling a specialized C program on the server side.
Source code
The C program
The C program reads a DNA string from stdin a translate it using the standard genetic code:Compilation:
The Node.js script
When the Node.js server receive a DNA parameter, it spawns a new process to the C program and we write the DNA to this process via 'stdin'.Each time a new 'data' event (containing the protein) is received, it is printed to the http response. At the end of the process, we close the stream by calling 'end()'.
test
Server running at http://127.0.0.1:8080
> curl -s "http://localhost:8080/?dna=ATGATGATAGATAGATATAGTAGATATGATCGTCAGCCATACG"
MMIDRYSRYDRQPY
That's it,
Pierre