Skip to content

Commit 0699470

Browse files
committed
Adding index with services included in BioAPI
1 parent ba5f1a2 commit 0699470

File tree

3 files changed

+66
-21
lines changed

3 files changed

+66
-21
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ For a given gene, this service gets from the String database a list of genes and
761761

762762
Service that takes gene symbol and returns a link to <https://go.drugbank.com> with all the drugs that upregulate and down regulate its expresion. Useful for embeding.
763763

764-
- URL: drugs-regulating-gene/*gene_id*
764+
- URL: /drugs-regulating-gene/*gene_id*
765765
- `gene_id` is the identifier of the gene.
766766
- Method: GET
767767
- Params: -
@@ -800,7 +800,7 @@ All kind of contribution is welcome! If you want to contribute just:
800800
### Run Flask dev server
801801

802802
1. Start up Docker services like MongoDB: `docker compose -f docker-compose.dev.yml up -d`.
803-
2. Go to the `bioapi` folder.
803+
2. Go to the `bio-api` folder.
804804
3. Run Flask server: `python3 bioapi.py`.
805805

806806
**NOTE:** If you are looking for documentation for a production deployment see [DEPLOYING.md](DEPLOYING.md).

bio-api/bioapi.py

+20-12
Original file line numberDiff line numberDiff line change
@@ -643,32 +643,40 @@ def associated_string_genes(gene_symbol: str, min_combined_score: int = 400) ->
643643
return res
644644

645645

646+
# Documentation of included services
647+
services = [
648+
{"name": "Genes symbols validator", "url": "[POST] /gene-symbols"},
649+
{"name": "Genes symbols finder", "url": "[GET] /gene-symbols-finder"},
650+
{"name": "Genes information", "url": "[POST] /information-of-genes"},
651+
{"name": "Gene Groups", "url": "[GET] /genes-of-its-group/<gene_id>"},
652+
{"name": "Genes of a metabolic pathway", "url": "[GET] /pathway-genes/<source>/<external_id>"},
653+
{"name": "Metabolic pathways from different genes", "url": "[POST] /pathways-in-common"},
654+
{"name": "Gene expression", "url": "[POST] /expression-of-genes"},
655+
{"name": "Therapies and actionable genes in cancer", "url": "[POST] /information-of-oncokb"},
656+
{"name": "Gene Ontology terms related to a list of genes", "url": "[POST] /genes-to-terms"},
657+
{"name": "Gene Ontology terms related to another specific term", "url": "[POST] /related-terms"},
658+
{"name": "Cancer related drugs", "url": "[POST] /drugs-pharm-gkb"},
659+
{"name": "Predicted functional associations network", "url": "[POST] /string-relations"},
660+
{"name": "Drugs that regulate a gene", "url": "[GET] /drugs-regulating-gene/<gene_id>"}
661+
]
662+
663+
646664
def create_app():
647665
# Creates and configures the app
648666
flask_app = Flask(__name__, instance_relative_config=True)
649667

650668
# Endpoints
651669
@flask_app.route("/")
652670
def homepage():
653-
return render_template('homepage.html', version=VERSION)
671+
# return render_template('index.html', title=f"API v{VERSION}", services=services)
672+
return render_template('homepage.html', version=VERSION, services=services)
654673

655674
@flask_app.route("/ping")
656675
def ping_ok():
657676
"""To use as healthcheck by Docker"""
658677
output = "ok"
659678
return make_response(output, 200, headers)
660679

661-
@flask_app.route("/bioapi-map")
662-
def list_routes():
663-
"""Lists all BioAPI endpoints"""
664-
output = {"endpoints": []}
665-
for rule in flask_app.url_map.iter_rules():
666-
methods = ','.join(rule.methods)
667-
line = urllib.parse.unquote(
668-
"{:50s} {:20s} {}".format(rule.endpoint, methods, rule))
669-
output["endpoints"].append(line)
670-
return make_response(output, 200, headers)
671-
672680
@flask_app.route("/gene-symbols", methods=['POST'])
673681
def gene_symbols():
674682
"""Receives a list of gene IDs in any standard and returns the standardized corresponding gene IDs.

bio-api/templates/homepage.html

+44-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,54 @@
1+
<!-- templates/index.html -->
12
<!DOCTYPE html>
2-
<html lang="en" dir="ltr">
3+
<html lang="es">
34
<head>
4-
<meta charset="utf-8">
5-
<title>BioAPI</title>
6-
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>BioAPI v{{ version }}</title>
8+
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
79
<style>
810
body {
9-
background-color: #f5f5f5;
10-
font-family: Arial, Helvetica, sans-serif;
11+
background-color: #f8f9fa;
12+
font-family: Arial, sans-serif;
13+
padding-top: 50px;
14+
padding: 10px 15px;
15+
}
16+
.container {
17+
max-width: 600px;
18+
}
19+
h1 {
20+
color: #343a40;
21+
margin-bottom: 20px;
22+
}
23+
h2 {
24+
color: #6c757d;
25+
margin-top: 30px;
26+
}
27+
.service-list .service-item {
28+
padding: 5px 5px;
29+
border-bottom: 1px solid #dee2e6;
30+
text-align: left; /* Alinea el contenido a la izquierda */
31+
}
32+
.service-item span {
33+
display: block; /* Coloca el nombre y el endpoint en líneas separadas */
34+
}
35+
.service-item code {
36+
color: #6c757d;
37+
font-size: 0.9em;
1138
}
1239
</style>
1340
</head>
1441
<body>
15-
<h1>BioAPI {{ version }}</h1>
42+
<h1>BioAPI v{{ version }}</h1>
43+
<h2 class="mb-4">Servicios incluidos:</h2>
44+
<ul class="list-group service-list">
45+
{% for service in services %}
46+
<li class="service-item">
47+
<span>{{ service.name }}</span>
48+
<code>{{ service.url }}</code>
49+
</li>
50+
{% endfor %}
51+
</ul>
52+
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
1653
</body>
1754
</html>

0 commit comments

Comments
 (0)