Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
a090d75
added comment
gitjannes Nov 21, 2024
375b934
Implemented get_available_runs(), a function that returns all runs wi…
gitjannes Nov 22, 2024
16cdfb8
Added filter.py, where the filters will be implemented. added (tempo…
gitjannes Nov 22, 2024
c566121
Made filtered_index more understandable
gitjannes Nov 22, 2024
5c1d1ab
fixed somethings
gitjannes Nov 26, 2024
dc20121
fiexed import for filter.py
gitjannes Nov 26, 2024
1d29f3a
Added structure to filter.py
gitjannes Nov 26, 2024
a85fea3
continue menu revised and delete feature implemented (#554)
maximilianKalff Nov 26, 2024
c841f8f
added memory_mode to runinfo
gitjannes Nov 26, 2024
e9eae3f
new run info works
gitjannes Nov 26, 2024
3e92367
fixed get_available_runs for mac
gitjannes Nov 26, 2024
855f889
fixed smth
gitjannes Nov 26, 2024
3231d43
added favourite in views.py
gitjannes Nov 26, 2024
4436b43
favourite function fixed
gitjannes Nov 26, 2024
6150878
first layout draft
maximilianKalff Nov 26, 2024
6070b55
Merge branch 'run-selection' of https://github.com/cschlaffner/PROTzi…
maximilianKalff Nov 26, 2024
30a68de
Proof of Concept for letting user choose favourites. its very ugly
gitjannes Nov 26, 2024
5d4281a
filter methods logic implemented, working with hardcoded filter
sarahvgls Nov 27, 2024
a39b2be
Added tag functionality for runs (no frontend tho). Tested how to get…
gitjannes Dec 2, 2024
8aa0f53
Select Visualisation, Run Selection code refactored
maximilianKalff Dec 5, 2024
6bd2e3e
Selection Header & Filter input value fixed
maximilianKalff Dec 5, 2024
9c131d9
Reworked index.html to only show available runs. Added new html page …
gitjannes Dec 10, 2024
f6aa54e
Header fixed, Button hover effect, first run always selected, deselec…
maximilianKalff Dec 12, 2024
397d70d
Minor visual changes (text in rows centered; thicker header line, etc.)
maximilianKalff Dec 12, 2024
1aab2bd
Arcordeon with one little bug
maximilianKalff Dec 12, 2024
2cd55b8
Added Steps into the filter selection
gitjannes Dec 12, 2024
e6db66d
Merge branch 'run-selection' of https://github.com/cschlaffner/PROTzi…
gitjannes Dec 12, 2024
ff4fa08
Added added html forms and js functions to add/delete tags. added set…
gitjannes Dec 12, 2024
373963b
fixed issue concerning non-existing metadata.yaml
gitjannes Dec 12, 2024
0b0fec4
ugly tags & back-end fixes
maximilianKalff Dec 12, 2024
7c35a10
Merge branch 'run-selection' of https://github.com/cschlaffner/PROTzi…
maximilianKalff Dec 12, 2024
8bb2d07
small fix for writing metadata
gitjannes Dec 12, 2024
383b1ad
Merge branch 'run-selection' of https://github.com/cschlaffner/PROTzi…
gitjannes Dec 12, 2024
9f9b8db
a tag with standard name can now be added to runs, it is displayed i…
gitjannes Dec 12, 2024
78ef886
added ugly text input field for tag naming, but the js function doesn…
gitjannes Dec 12, 2024
6b07f1f
the user-selected filters now filter
gitjannes Dec 16, 2024
3af2117
very ugly delete button shenanigans for tags, kinda works but wonky
gitjannes Dec 16, 2024
4c7ad64
Fixed tag adding, tags are now also saved as a set
gitjannes Dec 16, 2024
99be316
added the "addable_tags" key to the runs so that frontend doesnt have…
gitjannes Dec 17, 2024
6fe7878
Deleted comments that were now irrelevant, added descriptions to som…
gitjannes Dec 17, 2024
1e341f5
Moved filters into views_helper.py, deleted now obsolete filters.py, …
gitjannes Dec 17, 2024
1a0fa27
Missed a comment
gitjannes Dec 17, 2024
0b69258
minor fix
sarahvgls Dec 18, 2024
a4333e5
Moved favourite attribute of a run into the metadata for the run
gitjannes Dec 19, 2024
e5b9d8a
added displaying of active filters on reload, fixed filtering for steps
sarahvgls Dec 19, 2024
04e52fb
Removed outdated favourite functionality in front end
gitjannes Dec 19, 2024
f475e09
Merge branch 'run-selection' of https://github.com/cschlaffner/PROTzi…
gitjannes Dec 19, 2024
d7eb107
first version of clear filters button, working, handled error
sarahvgls Dec 19, 2024
468bd52
merge chaos
sarahvgls Dec 19, 2024
fc74963
merge chaos
sarahvgls Dec 19, 2024
0b7ee18
changed button positioning
sarahvgls Jan 5, 2025
a1e0134
adapted memory mode filter to other selection style
sarahvgls Jan 5, 2025
100ba51
sorting methods first version
sarahvgls Jan 6, 2025
527c6e3
"multiple runs selected bug" fixed & run stays selected when reloadin…
maximilianKalff Jan 6, 2025
2a6863b
Merge branch 'run-selection' of https://github.com/cschlaffner/PROTzi…
maximilianKalff Jan 6, 2025
e6e5988
bug fixed, caused by previous bug fix :))
maximilianKalff Jan 6, 2025
03594cf
bugfix when adding first tag fixed
sarahvgls Jan 8, 2025
fa0e73a
sorting in columns WIP
sarahvgls Jan 8, 2025
f9f8b30
implemented sorting by clicking on column header
sarahvgls Jan 9, 2025
3b40f60
swapped continue and delete button
gitjannes Jan 15, 2025
01340a0
changed lines between list items
sarahvgls Jan 15, 2025
edb1bbb
removed margin from continue button
gitjannes Jan 15, 2025
1cb0f60
Merge branch 'run-selection' of https://github.com/cschlaffner/PROTzi…
gitjannes Jan 15, 2025
ac81250
made continue button color-changing
gitjannes Jan 15, 2025
ab35179
protgraph semi fix
gitjannes Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions protzilla/data_analysis/protein_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from logging import INFO, ERROR


def variation_graph(protein_id: str, run_name: str):
def variation_graph(protein_id: str, run_name="Protgraph"):
"""
Wrapper function for creating a Protein-Variation-Graph for a given UniProt Protein.
VARIANT feature entries inserting amino acids are filtered out before graph creation
Expand Down Expand Up @@ -76,14 +76,24 @@ def _create_protein_variation_graph(protein_id: str, run_name: str) -> dict:
messages=[dict(level=ERROR, msg=msg, trace=request.__dict__)],
)

bingbong = Path(RUNS_PATH, "Protgraph/graphs/", f"{protein_id}.txt")


output_folder_path = run_path / "graphs"
output_csv = output_folder_path / f"{protein_id}.csv"
graph_path = output_folder_path / f"{protein_id}.graphml"
cmd_str = f"protgraph -egraphml {path_to_protein_file} \
"""cmd_str = f"protgraph {bingbong} \
-egraphml \
--export_output_folder={output_folder_path} \
--output_csv={output_csv} \
-ft VARIANT \
-d skip"
-d skip" """
cmd_str = f"""protgraph "{bingbong}" \
-egraphml \
--export_output_folder="{output_folder_path}" \
--output_csv="{output_csv}" \
--feature_table VARIANT \
--digestion skip"""

subprocess.run(cmd_str, shell=True)

Expand Down
29 changes: 25 additions & 4 deletions protzilla/disk_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pandas as pd
import yaml
from plotly.io import read_json, write_json
from plotly.io import read_json, write_json, write_image

import protzilla.utilities as utilities
from protzilla.constants import paths
Expand Down Expand Up @@ -126,6 +126,7 @@ def read_run(self, file: Path | None = None) -> StepManager:
return step_manager

def write_run(self, step_manager: StepManager) -> None:
print("i try to wrtie")
with ErrorHandler():
if not self.run_dir.exists():
self.run_dir.mkdir(parents=True, exist_ok=True)
Expand All @@ -139,6 +140,9 @@ def write_run(self, step_manager: StepManager) -> None:
for step in step_manager.all_steps:
run[KEYS.STEPS].append(self._write_step(step))
self.yaml_operator.write(self.run_file, run)
print("i wrote the run!")



def read_workflow(self) -> StepManager:
return self.read_run(self.workflow_file)
Expand Down Expand Up @@ -223,22 +227,27 @@ def _write_step(self, step: Step, workflow_mode: bool = False) -> dict:
step_data[KEYS.STEP_TYPE] = step.__class__.__name__
step_data[KEYS.STEP_INSTANCE_IDENTIFIER] = step.instance_identifier
step_data[KEYS.STEP_FORM_INPUTS] = sanitize_inputs(step.form_inputs)
print("write step:", step)
if not workflow_mode:
print("write step 2")
step_data[KEYS.STEP_INPUTS] = sanitize_inputs(step.inputs)
step_data[KEYS.STEP_PLOTS] = self._write_plots(
print("write step 3")
step_data[KEYS.STEP_PLOTS] = self._write_plots( #broken - Jannes, 10.04.2025
step.instance_identifier, step.plots
)
print("write step 4")
step_data[KEYS.STEP_OUTPUTS] = self._write_output(
instance_identifier=step.instance_identifier, output=step.output
)
step_data[KEYS.STEP_MESSAGES] = step.messages.messages
print("write step 5")
return step_data

def _read_outputs(self, output: dict) -> Output:
with ErrorHandler():
step_output = {}
for key, value in output.items():
if isinstance(value, str) and Path(value).exists():
if isinstance(value, str) and Path(value).exists() and ".graphml" not in value:
step_output[key] = self.dataframe_operator.read(value)
else:
step_output[key] = value
Expand Down Expand Up @@ -266,16 +275,28 @@ def _read_plots(self, plots: dict) -> Plots:

def _write_plots(self, instance_identifier: str, plots: Plots) -> dict:
with ErrorHandler():
print("try to write plots")
print(plots)
plots_data = {}
for i, plot in enumerate(plots):
print(1)
file_path = self.plot_dir / f"{instance_identifier}_plot{i}.json"
print(2)
self.plot_dir.mkdir(parents=True, exist_ok=True)
print(3)
if not isinstance(
plot, bytes
): # TODO the data integration plots are of type byte, and therefore cannot be written using this methodology
print(4)
write_json(plot, file_path)
plot.write_image(str(file_path).replace(".json", ".png"))
try:
plot.write_image(str(file_path).replace(".json", ".png"))
except Exception as e:
print(e)
print(6)
plots_data[i] = str(file_path)
print(7)
print("juhu")
return plots_data

@property
Expand Down
4 changes: 1 addition & 3 deletions protzilla/methods/data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ class ProteinGraphVariationGraph(DataAnalysisStep):

input_keys = [
"protein_id",
"run_name",
#"run_name",
]
output_keys = [
"graph_path",
Expand All @@ -780,8 +780,6 @@ def method(self, inputs: dict) -> dict:
return variation_graph(**inputs)

def insert_dataframes(self, steps: StepManager, inputs) -> dict:
inputs["peptide_df"] = steps.peptide_df
inputs["isoform_df"] = steps.isoform_df
return inputs


Expand Down
67 changes: 67 additions & 0 deletions protzilla/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
import threading
import traceback

import os
import shutil
import datetime

import protzilla.constants.paths as paths
from protzilla.steps import Messages, Output, Plots, Step
from protzilla.utilities import format_trace
from protzilla.disk_operator import DiskOperator, YamlOperator


def get_available_run_names() -> list[str]:
Expand All @@ -19,6 +24,68 @@ def get_available_run_names() -> list[str]:
if not directory.name.startswith(".")
]

def get_available_runinfo() -> tuple[list[dict[str, str | list[str]]], list[dict[str, str | list[str]]], set[str]]:
if not paths.RUNS_PATH.exists():
return []
runs = []
runs_favourited = []
all_tags = set()
for directory in paths.RUNS_PATH.iterdir(): #not sorted the same for different os?
if directory.name.startswith("."):
continue
name = directory.name
creation_time = directory.stat().st_ctime
modification_time = directory.stat().st_mtime

disk_operator = DiskOperator(name, "dummy_workflow_name")
directory_path = os.path.join(paths.RUNS_PATH, name)
run_yaml_path = os.path.join(directory_path, "run.yaml")
step_manager = disk_operator.read_run(run_yaml_path)
steps = step_manager.all_steps
step_names = []
for step in steps:
step_names.append(step.display_name)

# empty initialization to ensure backwardscompatibility for runs without metadata.yaml
favourite = False
tags = set()

metadata_yaml_path = os.path.join(directory_path, "metadata.yaml")
if os.path.isfile(metadata_yaml_path):
yaml_operator = YamlOperator()
metadata = yaml_operator.read(metadata_yaml_path)
tags = metadata.get("tags", set())
favourite = metadata.get("favourite", False)

for tag in tags:
all_tags.add(tag)

run = {
"run_name": name,
"creation_date": datetime.datetime.fromtimestamp(creation_time).strftime("%d %m %Y"), #TODO: reutrn the pure datetime, convert in html)
"modification_date": datetime.datetime.fromtimestamp(modification_time).strftime("%d %m %Y"),
"memory_mode": step_manager.df_mode,
"run_steps" : step_names,
"favourite_status" : favourite,
"run_tags": tags
}

if favourite:
runs_favourited.append(run)
else:
runs.append(run)

for run in runs + runs_favourited:
possible_tags = list(all_tags - run["run_tags"])
run["addable_tags"] = possible_tags

return (runs, runs_favourited, all_tags)

def delete_run_folder(run_name) -> None:
path = os.path.join(paths.RUNS_PATH, run_name)

if os.path.isdir(path):
shutil.rmtree(path)

class Run:
class ErrorHandlingContextManager:
Expand Down
9 changes: 0 additions & 9 deletions protzilla/run_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
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
Expand All @@ -21,12 +18,6 @@ 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, run_name)

if os.path.isdir(path):
shutil.rmtree(path)


class Run:
class ErrorHandlingContextManager:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ umap-learn==0.5.3
Werkzeug==2.2.3
numba==0.57.0
Pillow==9.5.0
kaleido==0.2.1
kaleido==0.1.0.post1
requests==2.31.0
psutil==5.9.5
tqdm==4.65.0
Expand Down
4 changes: 2 additions & 2 deletions ui/runs/forms/data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ def fill_form(self, run: Run) -> None:


class ProteinGraphPeptidesToIsoformForm(MethodForm):
protein_ID = CustomCharField(
protein_id = CustomCharField(
label="Protein ID", initial="Enter the Uniprot-ID of the protein"
)
# TODO: workflow_meta line 2255 - 2263
Expand All @@ -1058,7 +1058,7 @@ class ProteinGraphPeptidesToIsoformForm(MethodForm):


class ProteinGraphVariationGraphForm(MethodForm):
protein_ID = CustomCharField(
protein_id = CustomCharField(
label="Protein ID", initial="Enter the Uniprot-ID of the protein"
)
# TODO: workflow_meta line 2291 - 2295
Expand Down
Loading