Skip to content

Session 19: Practice 7

Juan Gonzalez-Gomez edited this page Apr 1, 2020 · 32 revisions

Session 19: Practice 7

  • Time: 2h
  • Date: Wednesday, April-1st-2020
  • Goals:
    • Practicing with JSON and the API REST
    • Reading information from the Ensembl project

Contents

Introduction

The goal of this practice is to develop a python application that reads 10 genes from the Ensembl database and perform some calculations on them: total number of bases, number of every base and its percentage and most frequent base

These are the genes that we want to get from the remote database: FRAT1, ADA, FXN, RNU6_269P, MIR633, TTTY4C, RBMY2YP, FGFR3, KDR, ANK2

This practice is guided. On every exercise we will implement new functionalities in our application

I recommend you to read again the information on the Session-4: The Ensembl genome browser

Recall that the ensembl database can be accessed in two ways. The first one is by means of a browser. We write the ensembl URL in the brower and we get a web page, provided by the emsembl server. This interface is meant for humans

The second one is an interface for applications. The applications can get objects directly from the server by means of its API REST. Therefore, the first step is to know this API: what objects can we get from the databse and what are the names we should use for accessing to that resources. These names are called endpoints

Here you can find the API REST of the ensembl project. You should have a look at it to get familiar with the terminology and names

Exercises

Let's create our first application that receives information directly from a remote application

Exercise 1: PING

Go to the API REST of the ensembl project and try to find an endpoint for checking if the service is alive (try searching for ping)

Click on the ping endpoint. You will see the documentation. As a Engineer is your work to read all the provided information and understand how this endpoint works. I will help you a litlte bit

The name of the endpoint is info/ping and it should be accessed using the HTTP GET method. On the top right we can see all the formats in which the information can be received: json, xml and jsonp. We are using json

In the bottom there is an example on how to use this endpoint. Click on the given URL:

Implement the ping service in the server. It should return a response message with a page saying that the server is alive. It should include a link to the main page. If a different resource is requested an Error web page is returned

  • Server Filename: P6/Seq2-server.py
  • HTML file: P6/form-1.html
  • HTML file: P6/Error.html

In this animation you can see it working:

Exercise 2: GET

Extend the previous server for implementing the get service. It should return the requested sequence (0 - 4). A response message with a page with the sequence is generated. It should include a link to the main page

  • Server Filename: P6/Seq2-server.py
  • HTML file: P6/form-2.html

This is how it should work:

Exercise 3: GENE

Extend the previous server for implementing the gene service. It should return the requested gene by its name. A response message with a page with the gene is generated. It should include a link to the main page

  • Server Filename: P6/Seq2-server.py
  • HTML file: P6/form-3.html

This is how it should work:

Exercise 4: Operation

Extend the previous server for implementing the operation service. It should return the requested operation on the sequence introduced. There are three operation: Info about the sequence, its complement and its reverse . A response message with a page with the results of the operation is generated. It should include a link to the main page

  • Server Filename: P6/Seq2-server.py
  • HTML file: P6/form-4.html

This is how it should work:

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 16 checked!
  • Your working repo contains the P6 Folder with the following files:
    • Seq2-server.py
    • Error.html
    • form-1.html
    • form-2 html
    • form-3 html
    • form-4 html
  • 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