Skip to content

Commit

Permalink
Adding index with services included in BioAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
mauri101-Ar committed Nov 4, 2024
1 parent ba5f1a2 commit 0699470
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ For a given gene, this service gets from the String database a list of genes and

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.

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

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

**NOTE:** If you are looking for documentation for a production deployment see [DEPLOYING.md](DEPLOYING.md).
Expand Down
32 changes: 20 additions & 12 deletions bio-api/bioapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,32 +643,40 @@ def associated_string_genes(gene_symbol: str, min_combined_score: int = 400) ->
return res


# Documentation of included services
services = [
{"name": "Genes symbols validator", "url": "[POST] /gene-symbols"},
{"name": "Genes symbols finder", "url": "[GET] /gene-symbols-finder"},
{"name": "Genes information", "url": "[POST] /information-of-genes"},
{"name": "Gene Groups", "url": "[GET] /genes-of-its-group/<gene_id>"},
{"name": "Genes of a metabolic pathway", "url": "[GET] /pathway-genes/<source>/<external_id>"},
{"name": "Metabolic pathways from different genes", "url": "[POST] /pathways-in-common"},
{"name": "Gene expression", "url": "[POST] /expression-of-genes"},
{"name": "Therapies and actionable genes in cancer", "url": "[POST] /information-of-oncokb"},
{"name": "Gene Ontology terms related to a list of genes", "url": "[POST] /genes-to-terms"},
{"name": "Gene Ontology terms related to another specific term", "url": "[POST] /related-terms"},
{"name": "Cancer related drugs", "url": "[POST] /drugs-pharm-gkb"},
{"name": "Predicted functional associations network", "url": "[POST] /string-relations"},
{"name": "Drugs that regulate a gene", "url": "[GET] /drugs-regulating-gene/<gene_id>"}
]


def create_app():
# Creates and configures the app
flask_app = Flask(__name__, instance_relative_config=True)

# Endpoints
@flask_app.route("/")
def homepage():
return render_template('homepage.html', version=VERSION)
# return render_template('index.html', title=f"API v{VERSION}", services=services)
return render_template('homepage.html', version=VERSION, services=services)

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

@flask_app.route("/bioapi-map")
def list_routes():
"""Lists all BioAPI endpoints"""
output = {"endpoints": []}
for rule in flask_app.url_map.iter_rules():
methods = ','.join(rule.methods)
line = urllib.parse.unquote(
"{:50s} {:20s} {}".format(rule.endpoint, methods, rule))
output["endpoints"].append(line)
return make_response(output, 200, headers)

@flask_app.route("/gene-symbols", methods=['POST'])
def gene_symbols():
"""Receives a list of gene IDs in any standard and returns the standardized corresponding gene IDs.
Expand Down
51 changes: 44 additions & 7 deletions bio-api/templates/homepage.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
<!-- templates/index.html -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<html lang="es">
<head>
<meta charset="utf-8">
<title>BioAPI</title>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BioAPI v{{ version }}</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
background-color: #f5f5f5;
font-family: Arial, Helvetica, sans-serif;
background-color: #f8f9fa;
font-family: Arial, sans-serif;
padding-top: 50px;
padding: 10px 15px;
}
.container {
max-width: 600px;
}
h1 {
color: #343a40;
margin-bottom: 20px;
}
h2 {
color: #6c757d;
margin-top: 30px;
}
.service-list .service-item {
padding: 5px 5px;
border-bottom: 1px solid #dee2e6;
text-align: left; /* Alinea el contenido a la izquierda */
}
.service-item span {
display: block; /* Coloca el nombre y el endpoint en líneas separadas */
}
.service-item code {
color: #6c757d;
font-size: 0.9em;
}
</style>
</head>
<body>
<h1>BioAPI {{ version }}</h1>
<h1>BioAPI v{{ version }}</h1>
<h2 class="mb-4">Servicios incluidos:</h2>
<ul class="list-group service-list">
{% for service in services %}
<li class="service-item">
<span>{{ service.name }}</span>
<code>{{ service.url }}</code>
</li>
{% endfor %}
</ul>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
</body>
</html>

0 comments on commit 0699470

Please sign in to comment.