-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from NBISweden/experimental/add-initial-annotat…
…ion-functionality Experimental/add initial annotation functionality
- Loading branch information
Showing
24 changed files
with
35,302 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.DS_Store | ||
__pycache__/ | ||
__pycache__/ | ||
venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,12 @@ | ||
# syntax=docker/dockerfile:1.4 | ||
FROM python:3.9-slim as BUILDER | ||
FROM python:3.9-slim | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update && \ | ||
apt-get -y install gcc mono-mcs && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY requirements.txt /app | ||
RUN --mount=type=cache,target=/root/.cache/pip \ | ||
pip3 install -r requirements.txt | ||
|
||
COPY . /app | ||
|
||
ENTRYPOINT ["python3"] | ||
CMD ["app.py"] | ||
|
||
FROM builder as dev-envs | ||
|
||
RUN <<EOF | ||
apk update | ||
apk add git | ||
EOF | ||
|
||
RUN <<EOF | ||
addgroup -S docker | ||
adduser -S --shell /bin/bash --ingroup docker vscode | ||
EOF | ||
# install Docker tools (cli, buildx, compose) | ||
COPY --from=gloursdocker/docker / / | ||
CMD ["flask", "--app", "app.py", "--debug", "run", "--host", "0.0.0.0"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,86 @@ | ||
from flask import Flask, request, render_template, Response | ||
from add import add | ||
from placeholder import VectorOligoSearch | ||
from flask import ( | ||
Flask, | ||
request, | ||
render_template, | ||
Response, | ||
json, | ||
make_response, | ||
jsonify | ||
) | ||
import io | ||
import csv | ||
import logging | ||
from itertools import chain | ||
from search.oligo_search import search, search_to_file | ||
from search.search import SearchError | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
app = Flask(__name__) | ||
|
||
|
||
|
||
@app.route('/') | ||
def hello(): | ||
return render_template('root.html') | ||
def root(): | ||
return render_template('root.html') | ||
|
||
@app.route('/form', methods=['POST', 'GET']) | ||
# Sample form POST to get input and render result | ||
|
||
@app.route('/search', methods=['POST', 'GET']) | ||
def form(): | ||
form_input = None | ||
gene_ids = [] | ||
output = None | ||
error = None | ||
status_code = 200 | ||
|
||
if request.method == 'POST': | ||
form_input = request.form['userInput'] | ||
output = VectorOligoSearch(form_input) | ||
try: | ||
gene_id = request.form['gene-id'] | ||
gene_list = request.form.get('gene-list', "").strip() | ||
gene_ids = ( | ||
[gene_id] if len(gene_list) == 0 | ||
else [g.strip().rstrip('\r\n') for g in gene_list.split("\n")] | ||
) | ||
output = search(gene_ids) | ||
except SearchError as e: | ||
error = str(e) | ||
status_code = 404 | ||
|
||
return render_template( | ||
'form.html', | ||
gene_ids=gene_ids, | ||
output=output, | ||
error=error, | ||
status_code=status_code, | ||
) | ||
|
||
|
||
return render_template('form.html', | ||
input=form_input, | ||
output=output) | ||
@app.route('/oligo-search') | ||
def oligo_search(): | ||
gene_ids = request.args.getlist('gene-id') | ||
try: | ||
output = search(gene_ids) | ||
return jsonify(output) | ||
except SearchError as e: | ||
error = str(e) | ||
return make_response(jsonify({"error": error}), 404) | ||
|
||
# Sample download generated CSV | ||
@app.route("/get") | ||
def getPlotCSV(): | ||
genome_id = request.args.get('id') | ||
csv = VectorOligoSearch(genome_id) | ||
def get_data(): | ||
gene_ids = request.args.getlist('gene-id') | ||
format = request.args.get('format', 'csv') | ||
(output, ext) = search_to_file( | ||
gene_ids, | ||
output_format=format | ||
) | ||
return Response( | ||
csv, | ||
output, | ||
mimetype="text/csv", | ||
headers={"Content-disposition": | ||
f"attachment; filename={genome_id}.csv"}) | ||
headers={ | ||
"Content-disposition": | ||
f"attachment; filename=oligo-sequences.{ext}" | ||
} | ||
) | ||
|
||
if __name__ == '__main__': | ||
app.run(host='0.0.0.0', port=8000) | ||
app.run(host='0.0.0.0', port=8000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Technical questions | ||
- How strictly do we want to stick to the original code? | ||
- Are there any restrictions on how much we can clean up the code? | ||
- |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.