forked from cmap/merino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflask_assemble.py
66 lines (55 loc) · 2.83 KB
/
flask_assemble.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from flask import Flask, request, render_template
import assemble_automationify
import assemble
import prism_metadata
import normalization.normalize_with_prism_invariant as norm
template_directory = "/Users/elemire/Workspace/prism_pipeline"
app = Flask(__name__, template_folder=template_directory)
@app.route('/')
def make_home_page():
return render_template("assembly_line.html")
@app.route('/', methods=["POST"])
def assembly_line():
if request.method == "POST":
if request.form["submit"] == "SUBMIT":
raw_args = ["-det", request.form["det"]]
#TODO Might be a better way to do this. As far as I could see the form always returns an empty string rather than None. So I only want to add it to the args if there was something in it.
# Change this to a loop
if request.form["cfg"] != '':
raw_args.extend(["-config_filepath", request.form["cfg"]])
if request.form["outfile"] != '':
raw_args.extend(["-out", request.form["outfile"]])
if request.form["pod"] != '':
raw_args.extend(["-pod", request.form["pod"]])
args = assemble_automationify.build_parser().parse_args(raw_args)
try:
outfile = assemble_automationify.main(args)
except Exception as err:
return "Exception: {}".format(err)
except AssertionError as err:
return "AssertionError: {}".format(err)
#try:
#norm.normalize(outfile)
#except Exception as err:
#return "Exception: {}".format(err)
#except AssertionError as err:
#return "AssertionError: {}".format(err)
return "Assembly Successful \n GCT location {} \n NORM location {}".format(outfile, outfile[:-10] + 'NORM.gct')
return "Flask server does not handle method: {}".format(request.method)
@app.route('/null')
def make_null_page():
return render_template("assemble_null.html")
@app.route('/null', methods=["POST"])
def assemble_null():
if request.method == "POST":
if request.form["submit"] == "SUBMIT":
assay_plates = [prism_metadata.AssayPlate(assay_plate_barcode='-666', det_plate='PNUL001_DPNULL_X1', pool_id='-P666', ignore=False)]
assay_plates[0].det_plate_scan_time = '-666'
null_davepool = "/Users/elemire/Workspace/flask_test/DPNULL.txt"
null_cellset = '/Users/elemire/Workspace/flask_test/CS-1.txt'
raw_args = ["-pmp", request.form["-pmp"], "-prn", request.form["-prn"],
"-dmf", null_davepool, "-csdf", null_cellset, "-dp_csv", "DPNULL", request.form["-csv"]]
args = assemble.build_parser().parse_args(raw_args)
assemble.main(args, assay_plates=assay_plates)
if __name__ == '__main__':
app.run(debug=True)