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:
gcc -o /my/bin/path/translate translate.c
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
> node-v0.2.5/node translate.js
Server running at http://127.0.0.1:8080
> curl -s "http://localhost:8080/?dna=ATGATGATAGATAGATATAGTAGATATGATCGTCAGCCATACG"
MMIDRYSRYDRQPY
Server running at http://127.0.0.1:8080
> curl -s "http://localhost:8080/?dna=ATGATGATAGATAGATATAGTAGATATGATCGTCAGCCATACG"
MMIDRYSRYDRQPY
That's it,
Pierre
No comments:
Post a Comment