Update S11: Practice 3 authored by Rodrigo's avatar Rodrigo
![](https://github.com/davidrol6/2020-2021-PNE/raw/master/s11-client-server-4/Cover/Cover.png) ![](https://gitlab.etsit.urjc.es/rperez/pne-wiki/-/raw/master/s11-client-server-4/Cover/Cover.png)
# Session 11: Practice 3 # Session 11: Practice 3
...@@ -10,35 +10,34 @@ ...@@ -10,35 +10,34 @@
## Contents ## Contents
* [Introduction](#introduction) * [Introduction](#introduction)
* [Localhost IP address](#localhost-ip-address) * [Localhost IP address](#localhost-ip-address)
* [Exercises](#exercises) * [Exercises](#exercises)
* [Exercise 1: PING](#exercise-1-ping) * [Exercise 1: PING](#exercise-1-ping)
* [Exercise 2: GET](#exercise-2-get) * [Exercise 2: GET](#exercise-2-get)
* [Exercise 3: INFO](#exercise-3-info) * [Exercise 3: INFO](#exercise-3-info)
* [Exercise 4: COMP](#exercise-4-comp) * [Exercise 4: COMP](#exercise-4-comp)
* [Exercise 5: REV](#exercise-5-rev) * [Exercise 5: REV](#exercise-5-rev)
* [Exercise 6: GENE](#exercise-6-gene) * [Exercise 6: GENE](#exercise-6-gene)
* [Exercise 7: Test-client](#exercise-7-test-client) * [Exercise 7: Test-client](#exercise-7-test-client)
* [End of the session](#end-of-the-session) * [End of the session](#end-of-the-session)
* [Author](#author) * [Author](#author)
* [Credits](#credits) * [Credits](#credits)
* [License](#license) * [License](#license)
## Introduction ## Introduction
The goal of this practice is to develop our own **Seq** server for working with **DNA sequences**. We have been working with DNA sequences for many sessions, but always in our local computer. Now we will make these calculations available to other applications on Internet The goal of this practice is to develop our own **Seq** server for working with **DNA sequences**. We have been working with DNA sequences for many sessions, but always in our local computer. Now we will make these calculations available to other applications on Internet
The first step is to **define** the set of **rules** and **commands** that the **clients** need to follow in order to access the **services** given by our **server**: we should define the **protocol** The first step is to **define** the set of **rules** and **commands** that the **clients** need to follow in order to access the **services** given by our **server**: we should define the **protocol**
| Service name | Request message | Argument | Response message | Description |
| Service name | Request message | Argument |Response message | Description | |--------------|-----------------|----------|------------------|-------------|
|--------------|-----------------|---------|-----------------|-------------| | **PING** | "PING" | none | "OK" | Ping service for testing if the server is alive of not |
| **PING** | "PING" | none | "OK" | Ping service for testing if the server is alive of not | | **GET** | "GET n" | n: 0-4 | A sequence | Get the sequence n. It could be any valid sequence of any length. There are only 5 sequences, numbered from 0 to 4 |
| **GET** | "GET n" | n: 0-4 | A sequence | Get the sequence n. It could be any valid sequence of any length. There are only 5 sequences, numbered from 0 to 4 | | **INFO** | "INFO seq" | seq: A sequence | See format below | Get information about the given sequence: total length, number of bases and their percentages |
| **INFO** | "INFO seq" | seq: A sequence | See format below | Get information about the given sequence: total length, number of bases and their percentages | | **COMP** | "COMP seq" | seq: A sequene | The complement sequence | Calculate the complement of the given sequence |
| **COMP** | "COMP seq" | seq: A sequene | The complement sequence | Calculate the complement of the given sequence | | **REV** | "REV seq" | seq: A sequence | The reverse sequence | Calculate the reverse of the given sequence |
| **REV** | "REV seq" | seq: A sequence | The reverse sequence | Calculate the reverse of the given sequence | | **GENE** | "GENE name" | Gene name. See format below | The sequence of the gene | Get the complete sequence of the given GENE |
| **GENE** | "GENE name" | Gene name. See format below | The sequence of the gene | Get the complete sequence of the given GENE |
The response message returned by the **INFO** service should be like this example: The response message returned by the **INFO** service should be like this example:
...@@ -57,7 +56,7 @@ The server will be programmed **step by step**, following the guides given in th ...@@ -57,7 +56,7 @@ The server will be programmed **step by step**, following the guides given in th
## Localhost IP address ## Localhost IP address
There is a special **IP** address: **127.0.0.1**, which is used to identify **your local machines**. When programming a server, instead of having to used the real IP, it is** easier to use this IP. Doing so, you do not have to change the code when running the server in a different computer There is a special **IP** address: **127.0.0.1**, which is used to identify **your local machines**. When programming a server, instead of having to used the real IP, it is\*\* easier to use this IP. Doing so, you do not have to change the code when running the server in a different computer
**We will always use the 127.0.0.1 address** in our servers **We will always use the 127.0.0.1 address** in our servers
...@@ -73,7 +72,7 @@ you should use the **Seq1 module** developed in **practice 1** ...@@ -73,7 +72,7 @@ you should use the **Seq1 module** developed in **practice 1**
* **Filename:** P3/Seq-Server.py * **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 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**: For **testing the server** we use this command, executed from the **command line**:
...@@ -89,7 +88,6 @@ And this is what we should get in the **Server's console**: ...@@ -89,7 +88,6 @@ And this is what we should get in the **Server's console**:
![](https://github.com/myTeachingURJC/2019-2020-PNE/raw/master/s11-client-server-4/exercises-02.png) ![](https://github.com/myTeachingURJC/2019-2020-PNE/raw/master/s11-client-server-4/exercises-02.png)
### Exercise 2: GET ### Exercise 2: GET
* **Filename:** P3/Seq-Server.py * **Filename:** P3/Seq-Server.py
...@@ -172,7 +170,6 @@ And this is what we should get in the **Server's console**: ...@@ -172,7 +170,6 @@ And this is what we should get in the **Server's console**:
![](https://github.com/myTeachingURJC/2019-2020-PNE/raw/master/s11-client-server-4/exercises-10.png) ![](https://github.com/myTeachingURJC/2019-2020-PNE/raw/master/s11-client-server-4/exercises-10.png)
### Exercise 6: GENE ### Exercise 6: GENE
* **Filename:** P3/Seq-Server.py * **Filename:** P3/Seq-Server.py
...@@ -261,7 +258,6 @@ CAATAAAGAAGGGCTGATCTCAAACAGCCTGAGCCTGGTGTCCTAATGGAATGA ...@@ -261,7 +258,6 @@ CAATAAAGAAGGGCTGATCTCAAACAGCCTGAGCCTGGTGTCCTAATGGAATGA
Process finished with exit code 0 Process finished with exit code 0
``` ```
## END of the session ## END of the session
The session is finished. Make sure, during this week, that everything in this list is checked! The session is finished. Make sure, during this week, that everything in this list is checked!
...@@ -272,7 +268,6 @@ The session is finished. Make sure, during this week, that everything in this li ...@@ -272,7 +268,6 @@ The session is finished. Make sure, during this week, that everything in this li
* [ ] test-client.py * [ ] test-client.py
* [ ] All the previous files have been pushed to your remote Github repo * [ ] All the previous files have been pushed to your remote Github repo
# Credits # Credits
* [Juan González-Gómez](https://github.com/Obijuan) (Obijuan) * [Juan González-Gómez](https://github.com/Obijuan) (Obijuan)
... ...
......