Skip to content

Session 13: Practice 4

Juan Gonzalez-Gomez edited this page Mar 9, 2020 · 29 revisions

Session 13: Practice 4

  • Time: 2h
  • Date: Wednesday, March-11th-2020
  • Goals: *

Contents

Introduction

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 its 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: lightgreen
/info/C C.html Information about the Cytosine base. Color: yellow
/info/G G.html Information about the Guanine base. Color: ligthblue
/info/T T.html Information about the Guanine base. Color: pink

Exercises

We will implement the Web Server step by step. The exercise will guide you

Exercise 1: A.html

  • Filename: P4/A.html

Let's start by writing the HTML page for the Adenine base. We will use it as a template. The pages for the other bases will be similar but with a different color and information

The page should look like this:

You can preview your page with pycham. Just open the html file in pycharm and press on the top right brower icons. For example in firefox's icon:

The page is quite similar to the Page of the Green server. Use the H1 tags for the base name, and the P tags for the letter and its chemical formula. Finally, you can place links to other URLS using the a tag. In this example you can see how to place a link to the wikipedia's main page:

<a href="https://en.wikipedia.org/">Wikipedia</a>

Exercise 2: info/A

  • Filename: P4/EX2.py
  • Description: Write a webserver that returns the A.html file when the info/A resource is requested by the client. When the URL http://127.0.0.1:8080/info/A is written in the browser, we should see the web page of the A base. If another resource is requested, the server will send a response message with a blank body (therefore a blank page will be shown)

Exercise 3: info/C

  • Filenames: P4/C.html and P4/EX3.py
  • Description: Extend the previous web server for accessing to the web pages of the C base, in addition to the A base. It should be available in the path /info/C

Exercise 4: info/G and info/T

  • Filenames: P4/T.html and P4/EX4.py
  • Description: Extend the previous web server for accessing to the web pages of the G and T bases, in addition to A and C. They should be available in the path /info/G and /info/T respectively

Exercise 5: REV

  • 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:

Exercise 6: GENE

  • 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:

Exercise 7: Test client

  • 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

END of the session

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

Author

Credits

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

License

Links

Clone this wiki locally