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