From 0860b10238050c0fd3e6f57748314f8751cf2ac8 Mon Sep 17 00:00:00 2001 From: gitjannes Date: Thu, 7 Nov 2024 16:23:06 +0100 Subject: [PATCH 01/12] Runs can be deleted --- protzilla/run_v2.py | 8 ++ ui/runs/templates/runs/index.html | 112 ++++++++++++------------- ui/runs/urls.py | 1 + ui/runs/views.py | 24 +++++- user_data/workflows/workflow_Test.yaml | 111 ++++++++++++++++++++++++ 5 files changed, 198 insertions(+), 58 deletions(-) create mode 100644 user_data/workflows/workflow_Test.yaml diff --git a/protzilla/run_v2.py b/protzilla/run_v2.py index c4b6835b..f3b8bd9e 100644 --- a/protzilla/run_v2.py +++ b/protzilla/run_v2.py @@ -4,6 +4,9 @@ import threading import traceback +import os +import shutil + import protzilla.constants.paths as paths from protzilla.steps import Messages, Output, Plots, Step from protzilla.utilities import format_trace @@ -18,6 +21,11 @@ def get_available_run_names() -> list[str]: if not directory.name.startswith(".") ] +def delete_run_folder(run_name) -> None: + path = os.path.join(paths.RUNS_PATH, "test") + + if os.path.isdir(path): + shutil.rmtree(path) class Run: class ErrorHandlingContextManager: diff --git a/ui/runs/templates/runs/index.html b/ui/runs/templates/runs/index.html index 5c081ca1..6bdd8714 100644 --- a/ui/runs/templates/runs/index.html +++ b/ui/runs/templates/runs/index.html @@ -5,67 +5,67 @@ {% endblock %} + {% block content %}
-
- {% if messages %} -
- {% for message in messages %} - - {% endfor %} -
-
- {% endif %} +
+
+
+ {% csrf_token %} +
+

Work on a new run:

+ +
+
+ + +
+
+ + +
+ +
+
-
-
-
- {% csrf_token %} -
-

Work on a new run:

- -
-
- - -
-
- - -
- -
-
+
+
+ {% csrf_token %} +
+

Continue an existing run:

+ +
+ +
+ Manage databases +
-
-
- {% csrf_token %} -
-

Continue an existing run:

- -
- -
- Manage databases -
+
+
+ {% csrf_token %} +
+

Delete an existing run:

+ +
+ +
-{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/ui/runs/urls.py b/ui/runs/urls.py index aa371831..a6f4c36c 100644 --- a/ui/runs/urls.py +++ b/ui/runs/urls.py @@ -7,6 +7,7 @@ path("", views.index, name="index"), path("create", views.create, name="create"), path("continue", views.continue_, name="continue"), + path("delete", views.delete_, name="delete"), path("detail/", views.detail, name="detail"), path("/plot", views.plot, name="plot"), path("/tables/", views.tables, name="tables_nokey"), diff --git a/ui/runs/views.py b/ui/runs/views.py index b95be756..e2c63b02 100644 --- a/ui/runs/views.py +++ b/ui/runs/views.py @@ -18,7 +18,8 @@ from django.shortcuts import render from django.urls import reverse -from protzilla.run import Run, get_available_run_names +from protzilla.run import Run, get_available_run_names +from protzilla.run_v2 import delete_run_folder from protzilla.run_helper import log_messages from protzilla.stepfactory import StepFactory from protzilla.steps import Step @@ -229,6 +230,25 @@ def continue_(request: HttpRequest): return HttpResponseRedirect(reverse("runs:detail", args=(run_name,))) +def delete_(request: HttpRequest): + """ + Continues an existing run. The user is redirected to the detail page of the run and + can resume working on the run. + + :param request: the request object + :type request: HttpRequest + + :return: the rendered details page of the run + :rtype: HttpResponse + """ + run_name = request.POST["run_name"] + if run_name in active_runs: + del active_runs[run_name] + + delete_run_folder(run_name) + + return HttpResponseRedirect(reverse("runs:index")) + def next_(request, run_name): """ @@ -247,7 +267,7 @@ def next_(request, run_name): run = active_runs[run_name] name = request.POST.get("name", None) if name: - run.steps.name_current_step_instance(name) + run.steps.name_current_step_instance(name) run.step_next() return HttpResponseRedirect(reverse("runs:detail", args=(run_name,))) diff --git a/user_data/workflows/workflow_Test.yaml b/user_data/workflows/workflow_Test.yaml new file mode 100644 index 00000000..2a5df49f --- /dev/null +++ b/user_data/workflows/workflow_Test.yaml @@ -0,0 +1,111 @@ +df_mode: disk_memory +steps: +- form_inputs: + aggregation_method: Sum + intensity_name: iBAQ + map_to_uniprot: false + inputs: {} + instance_identifier: MaxQuantImport_1 + type: MaxQuantImport +- form_inputs: + feature_orientation: Columns (samples in rows, features in columns) + inputs: {} + instance_identifier: MetadataImport_1 + type: MetadataImport +- form_inputs: + percentage: 0.5 + inputs: {} + instance_identifier: FilterProteinsBySamplesMissing_1 + plot_inputs: + graph_type: Bar chart + type: FilterProteinsBySamplesMissing +- form_inputs: + deviation_threshold: 2.0 + inputs: {} + instance_identifier: FilterSamplesByProteinIntensitiesSum_1 + plot_inputs: + graph_type: Bar chart + type: FilterSamplesByProteinIntensitiesSum +- form_inputs: + number_of_neighbours: 5 + inputs: {} + instance_identifier: ImputationByKNN_1 + plot_inputs: + graph_type: Boxplot + graph_type_quantities: Bar chart + group_by: None + visual_transformation: log10 + type: ImputationByKNN +- form_inputs: + number_of_neighbors: 20 + inputs: {} + instance_identifier: OutlierDetectionByLocalOutlierFactor_1 + plot_inputs: {} + type: OutlierDetectionByLocalOutlierFactor +- form_inputs: + percentile: 0.5 + inputs: {} + instance_identifier: NormalisationByMedian_1 + plot_inputs: + graph_type: Boxplot + group_by: None + visual_transformation: log10 + type: NormalisationByMedian +- form_inputs: + log_base: log2 + inputs: {} + instance_identifier: TransformationLog_1 + plot_inputs: + graph_type: Histogram + group_by: None + type: TransformationLog +- form_inputs: + input_df: TransformationLog_1 + protein_group: A0A075B6S2 + similarity: 1 + similarity_measure: euclidean distance + inputs: {} + instance_identifier: PlotProtQuant_1 + type: PlotProtQuant +- form_inputs: + alpha: 0.05 + group1: AD + group2: CTR + grouping: Group + multiple_testing_correction_method: Benjamini-Hochberg + protein_df: TransformationLog_1 + ttest_type: Welch's t-Test + inputs: {} + instance_identifier: DifferentialExpressionTTest_1 + type: DifferentialExpressionTTest +- form_inputs: + fc_threshold: 1 + input_dict: DifferentialExpressionTTest_1 + proteins_of_interest: [] + inputs: {} + instance_identifier: PlotVolcano_1 + type: PlotVolcano +- form_inputs: + differential_expression_threshold: 1 + direction: both + gene_sets_restring: [] + organism: 9606 + protein_df: DifferentialExpressionTTest_1 + inputs: {} + instance_identifier: EnrichmentAnalysisGOAnalysisWithString_1 + type: EnrichmentAnalysisGOAnalysisWithString +- form_inputs: + colors: [] + cutoff: 0.05 + gene_sets: + - Process + - Component + - Function + - KEGG + input_df_step_instance: EnrichmentAnalysisGOAnalysisWithString_1 + title: TestName + top_terms: 10 + value: p-value + inputs: {} + instance_identifier: PlotGOEnrichmentBarPlot_1 + type: PlotGOEnrichmentBarPlot From dd5edfba0a69e6e2db44ed0cf91894259079fd8e Mon Sep 17 00:00:00 2001 From: gitjannes Date: Thu, 7 Nov 2024 16:31:25 +0100 Subject: [PATCH 02/12] Fixed Comments --- ui/runs/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/runs/views.py b/ui/runs/views.py index e2c63b02..770da36f 100644 --- a/ui/runs/views.py +++ b/ui/runs/views.py @@ -232,12 +232,12 @@ def continue_(request: HttpRequest): def delete_(request: HttpRequest): """ - Continues an existing run. The user is redirected to the detail page of the run and - can resume working on the run. + Deletes an existing run. The user is redirected to the index page. :param request: the request object :type request: HttpRequest + :return: the rendered details page of the run :rtype: HttpResponse """ From 40ab5880f7cce7c35ec9ec7d9cbb8b4badf10c86 Mon Sep 17 00:00:00 2001 From: gitjannes Date: Thu, 7 Nov 2024 16:36:51 +0100 Subject: [PATCH 03/12] gitignore modified --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6d9a540c..3b385444 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ user_data/external_data/* user_data/debug/* ui/static/admin/* ui/uploads/* +userdata/workflows/workflow_Test.yaml .vscode/* .flake8 From 7145a3d97167291cada768f47a06200314298162 Mon Sep 17 00:00:00 2001 From: gitjannes Date: Thu, 7 Nov 2024 16:39:27 +0100 Subject: [PATCH 04/12] gitignore modified --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3b385444..65d56072 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ .DS_Store .idea/ user_data/runs/* +user_data/workflows/workflow_Test.yaml user_data/external_data/* user_data/debug/* ui/static/admin/* ui/uploads/* -userdata/workflows/workflow_Test.yaml .vscode/* .flake8 From 18fdbcf988ea348b6d6c0b3d015f4b1bb80df609 Mon Sep 17 00:00:00 2001 From: gitjannes Date: Thu, 7 Nov 2024 16:40:56 +0100 Subject: [PATCH 05/12] gitignore modified --- .gitignore | 1 + user_data/workflows/workflow_Test.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 65d56072..0c169bc3 100644 --- a/.gitignore +++ b/.gitignore @@ -147,3 +147,4 @@ dmypy.json #custom file everyone has Miniconda3*.sh Miniconda3*.exe +user_data/workflows/workflow_Test.yaml diff --git a/user_data/workflows/workflow_Test.yaml b/user_data/workflows/workflow_Test.yaml index 2a5df49f..45569312 100644 --- a/user_data/workflows/workflow_Test.yaml +++ b/user_data/workflows/workflow_Test.yaml @@ -109,3 +109,4 @@ steps: inputs: {} instance_identifier: PlotGOEnrichmentBarPlot_1 type: PlotGOEnrichmentBarPlot + From 65d4fdb62ee952082c9ee3a4aae37b138f684679 Mon Sep 17 00:00:00 2001 From: gitjannes Date: Thu, 7 Nov 2024 16:42:56 +0100 Subject: [PATCH 06/12] fixed workflow --- user_data/workflows/workflow_Test.yaml | 112 ------------------------- 1 file changed, 112 deletions(-) delete mode 100644 user_data/workflows/workflow_Test.yaml diff --git a/user_data/workflows/workflow_Test.yaml b/user_data/workflows/workflow_Test.yaml deleted file mode 100644 index 45569312..00000000 --- a/user_data/workflows/workflow_Test.yaml +++ /dev/null @@ -1,112 +0,0 @@ -df_mode: disk_memory -steps: -- form_inputs: - aggregation_method: Sum - intensity_name: iBAQ - map_to_uniprot: false - inputs: {} - instance_identifier: MaxQuantImport_1 - type: MaxQuantImport -- form_inputs: - feature_orientation: Columns (samples in rows, features in columns) - inputs: {} - instance_identifier: MetadataImport_1 - type: MetadataImport -- form_inputs: - percentage: 0.5 - inputs: {} - instance_identifier: FilterProteinsBySamplesMissing_1 - plot_inputs: - graph_type: Bar chart - type: FilterProteinsBySamplesMissing -- form_inputs: - deviation_threshold: 2.0 - inputs: {} - instance_identifier: FilterSamplesByProteinIntensitiesSum_1 - plot_inputs: - graph_type: Bar chart - type: FilterSamplesByProteinIntensitiesSum -- form_inputs: - number_of_neighbours: 5 - inputs: {} - instance_identifier: ImputationByKNN_1 - plot_inputs: - graph_type: Boxplot - graph_type_quantities: Bar chart - group_by: None - visual_transformation: log10 - type: ImputationByKNN -- form_inputs: - number_of_neighbors: 20 - inputs: {} - instance_identifier: OutlierDetectionByLocalOutlierFactor_1 - plot_inputs: {} - type: OutlierDetectionByLocalOutlierFactor -- form_inputs: - percentile: 0.5 - inputs: {} - instance_identifier: NormalisationByMedian_1 - plot_inputs: - graph_type: Boxplot - group_by: None - visual_transformation: log10 - type: NormalisationByMedian -- form_inputs: - log_base: log2 - inputs: {} - instance_identifier: TransformationLog_1 - plot_inputs: - graph_type: Histogram - group_by: None - type: TransformationLog -- form_inputs: - input_df: TransformationLog_1 - protein_group: A0A075B6S2 - similarity: 1 - similarity_measure: euclidean distance - inputs: {} - instance_identifier: PlotProtQuant_1 - type: PlotProtQuant -- form_inputs: - alpha: 0.05 - group1: AD - group2: CTR - grouping: Group - multiple_testing_correction_method: Benjamini-Hochberg - protein_df: TransformationLog_1 - ttest_type: Welch's t-Test - inputs: {} - instance_identifier: DifferentialExpressionTTest_1 - type: DifferentialExpressionTTest -- form_inputs: - fc_threshold: 1 - input_dict: DifferentialExpressionTTest_1 - proteins_of_interest: [] - inputs: {} - instance_identifier: PlotVolcano_1 - type: PlotVolcano -- form_inputs: - differential_expression_threshold: 1 - direction: both - gene_sets_restring: [] - organism: 9606 - protein_df: DifferentialExpressionTTest_1 - inputs: {} - instance_identifier: EnrichmentAnalysisGOAnalysisWithString_1 - type: EnrichmentAnalysisGOAnalysisWithString -- form_inputs: - colors: [] - cutoff: 0.05 - gene_sets: - - Process - - Component - - Function - - KEGG - input_df_step_instance: EnrichmentAnalysisGOAnalysisWithString_1 - title: TestName - top_terms: 10 - value: p-value - inputs: {} - instance_identifier: PlotGOEnrichmentBarPlot_1 - type: PlotGOEnrichmentBarPlot - From 86d4a87e520e71b5231761b96a7ec2a1de12671a Mon Sep 17 00:00:00 2001 From: gitjannes Date: Tue, 12 Nov 2024 15:04:01 +0100 Subject: [PATCH 07/12] Added requested Changes from Reviews --- protzilla/run_v2.py | 3 ++- ui/runs/templates/runs/index.html | 14 ++++++++++++++ ui/runs/views.py | 14 +++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/protzilla/run_v2.py b/protzilla/run_v2.py index f3b8bd9e..f0499ac0 100644 --- a/protzilla/run_v2.py +++ b/protzilla/run_v2.py @@ -22,11 +22,12 @@ def get_available_run_names() -> list[str]: ] def delete_run_folder(run_name) -> None: - path = os.path.join(paths.RUNS_PATH, "test") + path = os.path.join(paths.RUNS_PATH, run_name) if os.path.isdir(path): shutil.rmtree(path) + class Run: class ErrorHandlingContextManager: def __init__(self, run): diff --git a/ui/runs/templates/runs/index.html b/ui/runs/templates/runs/index.html index 6bdd8714..4da97d87 100644 --- a/ui/runs/templates/runs/index.html +++ b/ui/runs/templates/runs/index.html @@ -8,6 +8,20 @@ {% block content %}
+
+ {% if messages %} +
+ {% for message in messages %} + + {% endfor %} +
+
+ {% endif %}
diff --git a/ui/runs/views.py b/ui/runs/views.py index 770da36f..6bfc709a 100644 --- a/ui/runs/views.py +++ b/ui/runs/views.py @@ -245,7 +245,19 @@ def delete_(request: HttpRequest): if run_name in active_runs: del active_runs[run_name] - delete_run_folder(run_name) + try: + delete_run_folder(run_name) + except Exception as e: + display_message( + { + "level": 40, + "msg": f"Couldn't delete the run '{run_name}' . Please check the permissions for this file or try running Protzilla as administrator.", + "trace": format_trace(traceback.format_exception(e)), + }, + request, + ) + traceback.print_exc() + return HttpResponseRedirect(reverse("runs:index")) return HttpResponseRedirect(reverse("runs:index")) From cadc4f2a83ee618bbf08bba16dd69568b5173ad0 Mon Sep 17 00:00:00 2001 From: gitjannes Date: Wed, 13 Nov 2024 14:45:11 +0100 Subject: [PATCH 08/12] Fixed Ui not showing properly --- ui/runs/templates/runs/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/runs/templates/runs/index.html b/ui/runs/templates/runs/index.html index 4da97d87..f259ca09 100644 --- a/ui/runs/templates/runs/index.html +++ b/ui/runs/templates/runs/index.html @@ -8,7 +8,7 @@ {% block content %}
-
+
{% if messages %}
{% for message in messages %} @@ -22,7 +22,7 @@

{% endif %} -
+
{% csrf_token %} From 21331279f3945bfaa6a2c571d210b1c0ed07e392 Mon Sep 17 00:00:00 2001 From: gitjannes Date: Wed, 13 Nov 2024 14:47:59 +0100 Subject: [PATCH 09/12] Fixed Git ignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0c169bc3..667a2dc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ .DS_Store .idea/ user_data/runs/* -user_data/workflows/workflow_Test.yaml user_data/external_data/* user_data/debug/* ui/static/admin/* From c81ebb0cb727da4f09e9593dd7af4d89ec5ae828 Mon Sep 17 00:00:00 2001 From: gitjannes Date: Wed, 13 Nov 2024 14:49:14 +0100 Subject: [PATCH 10/12] Fixed linebreak --- ui/runs/templates/runs/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/runs/templates/runs/index.html b/ui/runs/templates/runs/index.html index f259ca09..d6be8f3d 100644 --- a/ui/runs/templates/runs/index.html +++ b/ui/runs/templates/runs/index.html @@ -5,7 +5,6 @@ {% endblock %} - {% block content %}
From c05d34f30291cefe91dc9c67b19b166c64562066 Mon Sep 17 00:00:00 2001 From: gitjannes Date: Wed, 13 Nov 2024 17:45:04 +0100 Subject: [PATCH 11/12] Added worklflows ordner to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 667a2dc8..cd16602a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store .idea/ user_data/runs/* +user_data/workflows/* user_data/external_data/* user_data/debug/* ui/static/admin/* From faa7ae7fd0f8944459ac74d896f3a6291d969b81 Mon Sep 17 00:00:00 2001 From: gitjannes Date: Wed, 13 Nov 2024 17:56:13 +0100 Subject: [PATCH 12/12] final --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index cd16602a..adf78463 100644 --- a/.gitignore +++ b/.gitignore @@ -147,4 +147,3 @@ dmypy.json #custom file everyone has Miniconda3*.sh Miniconda3*.exe -user_data/workflows/workflow_Test.yaml