-
Notifications
You must be signed in to change notification settings - Fork 7
Session 13: Practice 4

- Time: 2h
- Date: Wednesday, March-11th-2020
- Goals: *
The goal of this practice is to develop a web server with information about the four bases: A, C, T and G. Each base should have each page, with the following information: Name, letter, chemical formula and a link to the wikipedia URL with more information.In addition, each page will be in a different color. This table describe the names of the resources (path) for getting the web pages
| Resource | html page | Description |
|---|---|---|
| /info/A | A.html | Information about the Adenine base. Color: Green |
| /info/C | C.html | Information about the Adenine base. Color: yellow |
We will implement the Seq Server and develop some example clients for testing it. While developing the server, we will use the printf and nc linux commands for sending messages to the server. But you can also do it from your own client, if you like
The server will be stored in the Seq-Server.py file inside folder P3
you should use the Seq1 module developed in practice 1
- Filename: P3/Seq-Server.py
Let's start by programming a server that implements the PING command. The client will send a message with the word PING. Then, the server should parse the request message. If the PING command is detected, it should generate the response message "OK!\n". Also, it should print on the console the message "PING command!" in GREEN, and then the response message in white
For testing the server we use this command, executed from the command line:
printf "PING" | nc 127.0.0.1 8080
This is what we will see on the linux console:

And this is what we should get in the Server's console:

- Filename: P3/Seq-Server.py
Modify the Seq server for implementing the GET command. The client sends a message with the word GET followed by a number between 0 and 4. The server will return a response message with a sequence associated to that number. These sequences are for testing purposes, therefore you can use whatever sequences you want. They should be stored into a list. The server uses the number received in the GET command for accessing this list and returning the sequence
For testing the server we use this command, executed from the command line:
printf "GET 2" | nc 127.0.0.1 8080
In this example the client is asking for the sequence number 2
This is what is shown in the Linux's console:

And this is what we should get in the Server's console:

- Filename: P3/Seq-Server.py
Modify the Seq server for implementing the INFO command. The client sends a message with the word INFO followed by a sequence. The server will return a response message with information about that sequence. This information should be obtained using the Seq Class
For testing the server we use commands like this, executed from the Linux's command line:
printf "INFO AACCGTA" | nc 127.0.0.1 8080
This is what is shown in the Linux's console:

And this is what we should get in the Server's console:

- Filename: P3/Seq-Server.py
Modify the Seq server for implementing the COMP command. The client sends a message with the word COMP followed by a sequence. The server will return a response message with the complement of that sequence. It should be obtained using the Seq Class
For testing the server we use commands like this, executed from the Linux's command line:
printf "COMP AACCGTA" | nc 127.0.0.1 8080
This is what is shown in the Linux's console:

And this is what we should get in the Server's console:

- Filename: P3/Seq-Server.py
Modify the Seq server for implementing the REV command. The client sends a message with the word REV followed by a sequence. The server will return a response message with the reverse of the given sequence. It should be obtained using the Seq Class
For testing the server we use commands like this, executed from the Linux's command line:
printf "REV AACCGTA" | nc 127.0.0.1 8080
This is what is shown in the Linux's console:

And this is what we should get in the Server's console:

- Filename: P3/Seq-Server.py
Modify the Seq server for implementing the GENE command. The client sends a message with the word REV followed by a gene name: U5, ADA, FRAT1, FXN or RNU6_269P. The server will return a response message with the complete sequence of that gene. It should be obtained using the Seq Class (and reading the gene from the corresponding file)
For testing the server we use commands like this, executed from the Linux's command line:
printf "GENE U5" | nc 127.0.0.1 8080
This is what is shown in the Linux's console:

And this is what we should get in the Server's console:

- Filename: P3/test-client.py
Finally let's create a client for testing our server. You should use the Client class from practice 2. Use the talk method
For the services INFO, COMP and REV, use the sequence obtained when calling the GET 0 command
The client should write messages on the console indicating the test it is performing and the response obtained from the server:
-----| Practice 3, Exercise 7 |------
Connection to SERVER at 127.0.0.1, PORT: 8080
* Testing PING...
OK!
* Testing GET...
GET 0: ACCTCCTCTCCAGCAATGCCAACCCCAGTCCAGGCCCCCATCCGCCCAGGATCTCGATCA
GET 1: AAAAACATTAATCTGTGGCCTTTCTTTGCCATTTCCAACTCTGCCACCTCCATCGAACGA
GET 2: CAAGGTCCCCTTCTTCCTTTCCATTCCCGTCAGCTTCATTTCCCTAATCTCCGTACAAAT
GET 3: CCCTAGCCTGACTCCCTTTCCTTTCCATCCTCACCAGACGCCCGCATGCCGGACCTCAAA
GET 4: AGCGCAAACGCTAAAAACCGGTTGAGTTGACGCACGGAGAGAAGGGGTGTGTGGGTGGGT
* Testing INFO...
Sequence: ACCTCCTCTCCAGCAATGCCAACCCCAGTCCAGGCCCCCATCCGCCCAGGATCTCGATCA
Total length: 60
A: 13 (21.7%)
C: 29 (48.3%)
G: 9 (15.0%)
T: 9 (15.0%)
* Testing COMP...
COMP ACCTCCTCTCCAGCAATGCCAACCCCAGTCCAGGCCCCCATCCGCCCAGGATCTCGATCA
TGGAGGAGAGGTCGTTACGGTTGGGGTCAGGTCCGGGGGTAGGCGGGTCCTAGAGCTAGT
* Testing REV...
REV ACCTCCTCTCCAGCAATGCCAACCCCAGTCCAGGCCCCCATCCGCCCAGGATCTCGATCA
ACTAGCTCTAGGACCCGCCTACCCCCGGACCTGACCCCAACCGTAACGACCTCTCCTCCA
* Testing GENE...
GENE U5
ATAGACCAAACATGAGAGGCTGTGAATGGTATAATCTTCGCCGTTCGACAGGTAAGGTTATTTTTATTTTTTTTTTTTACTATTAAAGCGCTTTATAGATGTTTGTTCTTAAT
[...]
CTAATGTTAACATAAATGGAACTTACATCATTAGCATTATCTCAGACCGTAATAAAATTTGAACAGTAATA
GENE ADA
AGATCGCGCCACTTCACTGCAGCCTCCGCGAAAGAGCGAAACTCCGTCTCAGTAAATAAATAAATAAATAAATAAATAAATAAATAAATAAATAAATAACCTGTACCCGCGTGTTATTTCCCTCCGTCCTTACCTCCTCCCGGCTCCTTCCCTTTCACCTGAGATAACCACTCTTCTCGTATCTATGCTCATCTTTCCCTTGCTTTACATTTTTTCCACCGATGCA
[...]
GAGTGGTTGGGGAA
GENE FRAT1
ACCTCCTCTCCAGCAATGCCAACCCCAGTCCAGGCCCCCATCCGCCCAGGATCTCGATCAAAAAACATTAATCTGTGGCCTTTCTTTGCCATTTCCAACTCTGCCACCTCCATCGAACGACAAGGTCCCCTTCTTCCTTTCCATTCCCGTCAGCTTCATTTCCCTAATCTCCGTACAAATCCCTAGCCTGACTCCCTTTCCTTTCCATCCTCACCAGACGCCCGCA
[...]
CTTTTCAGGGCTGG
GENE FXN
TCTCAAGCATATATAAGCTATGAAAGAAACGTTCACAATCTGTATTCCTTTGCAACATACTAAAGTAAAAATGTCTTTTAAGGTGTATTAACAACTTAATATTTACCATACACTTAGCAGGGTCTAGGGCTTGTCCCCCCACAAAAATACACTTTACATAGATGAACTCATTTTACCCTTAAAGTAACCCTAAGAAGTAGAAACTTTAATAAACTCCATTTTACAG
[...]
GGGTTGAGGAAGGC
GENE RNU6_269P
GAGCAGGAGCAGGTGCTGGCACAAGAGATAGAAGAGCTGTATTTGAAGCTGTCCTCACAGGGTTAACAAGAGTTCTGGACAGAAATATAGTTATAATTAAGCATTAGTCAGGCTGCAATTTGACTCATTTCCTTGTAGCCAGAATTCATGGAGCACTAGATGTTGACCATTTGTATCCCCATTGTTTCTACAGATGAAATTTCTGATGTTAGAATCATAAGGGTTT
[...]
CAATAAAGAAGGGCTGATCTCAAACAGCCTGAGCCTGGTGTCCTAATGGAATGA
Process finished with exit code 0
The session is finished. Make sure, during this week, that everything in this list is checked!
- You have all the items of the session 10 checked!
- Your working repo contains the P3 Folder with the following files:
- Seq-server.py
- test-client.py
- All the previous files have been pushed to your remote Github repo
- Juan González-Gómez (Obijuan)

- Alvaro del Castillo. He designed and created the original content of this subject. Thanks a lot :-)

S0: Introduction
S1: Tools I
S2: Tools II
S3: Practicing with the tools
S8: Client-Server-1
S9: Client-Server-2
S10: Client-server-3
S11: Client-server-4
S12: HTTP protocol-1
S13: HTTP protocol-2
S14: HTTP module
S15: HTTP module
S16: HTML forms
S17: HTML forms