Commit f2bafcc5 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Add load of example data in run form, Implements #21

parent d0646eb7
......@@ -93,3 +93,7 @@ clean_freq = 1
run_local = 1
data_prepare = 2
max_concurrent_dl = 5
[example]
query =
target =
......@@ -172,7 +172,7 @@ Configuration
Changing the default configuration is not required for standalone mode, but you can want to custom some parts of the program.
Configuration is stored in the `/etc/dgenies/application.properties` file (linux) or in the `application.properties` file of the install folder (windows). The file is divided in 8 parts described below.
Configuration is stored in the `/etc/dgenies/application.properties` file (linux) or in the `application.properties` file of the install folder (windows). The file is divided in 9 parts described below.
To change this file, please copy it into `application.properties.local` (at the same location) to avoid erase of the file on upgrades.
......@@ -281,6 +281,14 @@ Several parameters for jobs:
* `data_prepare`: max number of data prepare jobs launched locally.
* `max_concurrent_dl`: max number of concurrent upload of files allowed.
### Example
Here, you can fill example data. At least target is required to enable example data.
Fill for target and query the absolute local path of the file. This path will not be shown to the client. Only the file name will be shown.
If at least target is filled, a button "Load example" will be shown in the run form. Click on it will load example data in the form.
Maintenance
......
......@@ -403,3 +403,15 @@ class AppConfigReader:
except (NoOptionError, NoSectionError):
pass
return allowed_ip
def _get_example_query(self):
try:
return self.reader.get("example", "query")
except (NoOptionError, NoSectionError):
return ""
def _get_example_target(self):
try:
return self.reader.get("example", "target")
except (NoOptionError, NoSectionError):
return ""
class Fasta:
def __init__(self, name, path, type_f):
self.__name = name
self.__path = path
self.__type = type_f
def __init__(self, name, path, type_f, example=False):
self._name = name
self._path = path
self._type = type_f
self._example = example
def set_path(self, path):
self.__path = path
self._path = path
def get_path(self):
return self.__path
return self._path
def set_name(self, name):
self.__name = name
self._name = name
def get_name(self):
return self.__name
return self._name
def get_type(self):
return self.__type
return self._type
def is_example(self):
return self._example
......@@ -371,7 +371,10 @@ class JobManager:
def __getting_local_file(self, fasta: Fasta, type_f):
finale_path = os.path.join(self.output_dir, type_f + "_" + os.path.basename(fasta.get_path()))
shutil.move(fasta.get_path(), finale_path)
if fasta.is_example():
shutil.copy(fasta.get_path(), finale_path)
else:
shutil.move(fasta.get_path(), finale_path)
with open(os.path.join(self.output_dir, "." + type_f), "w") as save_file:
save_file.write(finale_path)
return finale_path
......
......@@ -10,11 +10,15 @@ dgenies.run.max_upload_file_size = -1
dgenies.run.files = [undefined, undefined];
dgenies.run.allow_upload = false;
dgenies.run.ping_interval = null;
dgenies.run.target_example = "";
dgenies.run.query_example = "";
dgenies.run.init = function (s_id, allowed_ext, max_upload_file_size=1073741824) {
dgenies.run.init = function (s_id, allowed_ext, max_upload_file_size=1073741824, target_example="", query_example="") {
dgenies.run.s_id = s_id;
dgenies.run.allowed_ext = allowed_ext;
dgenies.run.max_upload_file_size = max_upload_file_size
dgenies.run.max_upload_file_size = max_upload_file_size;
dgenies.run.target_example = target_example;
dgenies.run.query_example = query_example;
dgenies.run.restore_form();
dgenies.run.set_events();
dgenies.run.init_fileuploads();
......@@ -154,6 +158,15 @@ dgenies.run.get_file_size_str = function(size) {
return Math.round(size / 1073741824) + " Go";
};
dgenies.run.fill_examples = function () {
$("select.target").val("1").trigger("change");
$("input#target").val("example://" + dgenies.run.target_example);
if (dgenies.run.query_example !== "") {
$("select.query").val("1").trigger("change");
$("input#query").val("example://" + dgenies.run.query_example);
}
};
dgenies.run.set_events = function() {
let max_file_size_txt = dgenies.run.get_file_size_str(dgenies.run.max_upload_file_size);
$("input.file-query").change(function () {
......@@ -204,6 +217,9 @@ dgenies.run.set_events = function() {
$("select.target").change(function() {
dgenies.run.change_fasta_type("target", $("select.target").find(":selected").text().toLowerCase())
});
$("button#example").click(function() {
dgenies.run.fill_examples();
});
};
dgenies.run.change_fasta_type = function (fasta, type, keep_url=false) {
......@@ -381,7 +397,8 @@ dgenies.run.ping_upload = function () {
};
dgenies.run.check_url = function (url) {
return url.startsWith("http://") || url.startsWith("https://") || url.startsWith("ftp://");
return url.startsWith("http://") || url.startsWith("https://") || url.startsWith("ftp://") ||
url.startsWith("example://");
};
dgenies.run.start_uploads = function() {
......@@ -427,6 +444,7 @@ dgenies.run.start_uploads = function() {
dgenies.run.show_global_loading = function () {
$("button#submit").hide();
$("button#example").hide();
$("div#uploading-loading").show();
};
......
......@@ -11,7 +11,7 @@
{% endblock %}
{% block onload %}
{{ super() }}
dgenies.run.init('{{ s_id }}',{{ allowed_ext }}, {{ max_upload_file_size }});
dgenies.run.init('{{ s_id }}',{{ allowed_ext }}, {{ max_upload_file_size }}, '{{ target }}', '{{ query }}');
{% endblock %}
{% block content %}
<form id="submit_minimap" method=post action="#">
......@@ -107,6 +107,9 @@
<p class="afterworlff">* We will send you results by mail.</p>
<p class="afterworlff">** Can be gzipped.</p>
<button type="button" id="submit">Submit</button>
{% if example %}
<button type="button" id="example">Load example</button>
{% endif %}
</div>
<div id="uploading-loading" style="display:none;">Uploading files...</div>
<div class="hidden-input-files">
......
......@@ -64,7 +64,10 @@ def run():
email = request.args["email"]
return render_template("run.html", id_job=id_job, email=email,
menu="run", allowed_ext=ALLOWED_EXTENSIONS, s_id=s_id,
max_upload_file_size=config_reader.max_upload_file_size)
max_upload_file_size=config_reader.max_upload_file_size,
example=config_reader.example_target != "",
target=os.path.basename(config_reader.example_target),
query=os.path.basename(config_reader.example_query))
@app.route("/run-test", methods=['GET'])
......@@ -134,20 +137,34 @@ def launch_analysis():
# Save files:
query = None
if file_query != "":
query_name = os.path.splitext(file_query.replace(".gz", ""))[0] if file_query_type == "local" else None
query_path = os.path.join(app.config["UPLOAD_FOLDER"], upload_folder, file_query) \
if file_query_type == "local" else file_query
if file_query_type == "local" and not os.path.exists(query_path):
errors.append("Query file not correct!")
example = False
if file_query.startswith("example://"):
example = True
query_path = config_reader.example_query
query_name = os.path.basename(query_path)
file_query_type = "local"
else:
query_name = os.path.splitext(file_query.replace(".gz", ""))[0] if file_query_type == "local" else None
query_path = os.path.join(app.config["UPLOAD_FOLDER"], upload_folder, file_query) \
if file_query_type == "local" else file_query
if file_query_type == "local" and not os.path.exists(query_path):
errors.append("Query file not correct!")
form_pass = False
query = Fasta(name=query_name, path=query_path, type_f=file_query_type, example=example)
example = False
if file_target.startswith("example://"):
example = True
target_path = config_reader.example_target
target_name = os.path.basename(target_path)
file_target_type = "local"
else:
target_name = os.path.splitext(file_target.replace(".gz", ""))[0] if file_target_type == "local" else None
target_path = os.path.join(app.config["UPLOAD_FOLDER"], upload_folder, file_target) \
if file_target_type == "local" else file_target
if file_target_type == "local" and not os.path.exists(target_path):
errors.append("Target file not correct!")
form_pass = False
query = Fasta(name=query_name, path=query_path, type_f=file_query_type)
target_name = os.path.splitext(file_target.replace(".gz", ""))[0] if file_target_type == "local" else None
target_path = os.path.join(app.config["UPLOAD_FOLDER"], upload_folder, file_target) \
if file_target_type == "local" else file_target
if file_target_type == "local" and not os.path.exists(target_path):
errors.append("Target file not correct!")
form_pass = False
target = Fasta(name=target_name, path=target_path, type_f=file_target_type)
target = Fasta(name=target_name, path=target_path, type_f=file_target_type, example=example)
if form_pass:
# Launch job:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment