Skip to content

Commit e076cca

Browse files
authored
Merge pull request #348 from PhysiCell-Tools/development
Galaxy sync; better ICs cells; cell scalars colorbar
2 parents e0a2368 + c3663d8 commit e076cca

7 files changed

Lines changed: 541 additions & 872 deletions

File tree

bin/cell_def_tab.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,10 @@ def __init__(self, xml_creator):
312312
self.tab_widget.addTab(self.create_motility_tab(),"Motility")
313313
self.tab_widget.addTab(self.create_secretion_tab(),"Secretion")
314314
self.tab_widget.addTab(self.create_interaction_tab(),"Interactions")
315-
self.tab_widget.addTab(self.create_intracellular_tab(),"Intracellular")
315+
if not self.xml_creator.nanohub_flag and not self.xml_creator.galaxy_flag:
316+
self.tab_widget.addTab(self.create_intracellular_tab(),"Intracellular")
317+
else:
318+
self.intracellular_type_dropdown = None
316319
self.tab_widget.addTab(self.create_custom_data_tab(),"Custom Data")
317320
self.tab_widget.addTab(self.create_miscellaneous_tab(),"Misc")
318321

@@ -5432,8 +5435,11 @@ def fill_celltypes_comboboxes(self):
54325435

54335436
self.cell_adhesion_affinity_dropdown.addItem(name)
54345437

5435-
val = self.param_d[self.current_cell_def]['asymmetric_division_probability'][name]
5436-
self.cycle_tab.add_row_to_asym_div_table(name, val=val)
5438+
try:
5439+
val = self.param_d[self.current_cell_def]['asymmetric_division_probability'][name]
5440+
self.cycle_tab.add_row_to_asym_div_table(name, val=val)
5441+
except:
5442+
print(f"fill_celltypes_comboboxes(): Exception: {name}, asymmetric_division_probability= {self.param_d[self.current_cell_def]['asymmetric_division_probability']}")
54375443

54385444
# self.ics_tab.celltype_combobox.addItem(name)
54395445

@@ -5755,16 +5761,19 @@ def new_asym_div_params(self, cdname, creating_new_cell_in_studio):
57555761
self.param_d[cdname]['asymmetric_division_probability'][cdname2] = '0' if cdname != cdname2 else '1.0'
57565762
self.param_d[cdname2]['asymmetric_division_probability'][cdname] = '0' if cdname != cdname2 else '1.0'
57575763

5764+
# Use default values found in PhysiCell, e.g., *_standard_models.cpp, etc.
57585765
def new_death_params(self, cdname):
57595766
sval = self.default_sval
57605767
duration_sval = '1.e9'
57615768
self.param_d[cdname]["death_rate"] = '5.31667e-05' # deprecated??
57625769
self.param_d[cdname]["apoptosis_death_rate"] = '5.31667e-05'
57635770
self.param_d[cdname]["apoptosis_01_duration"] = '516'
57645771
self.param_d[cdname]["apoptosis_01_fixed_duration"] = False
5765-
57665772
self.param_d[cdname]["apoptosis_duration_flag"] = False
57675773

5774+
self.param_d[cdname]["apoptosis_01_trate"] = '0.001938'
5775+
self.param_d[cdname]["apoptosis_01_fixed_trate"] = False
5776+
57685777
self.param_d[cdname]["apoptosis_unlysed_rate"] = '0.05'
57695778
self.param_d[cdname]["apoptosis_lysed_rate"] = '0'
57705779
self.param_d[cdname]["apoptosis_cyto_rate"] = '1.66667e-02'
@@ -6385,7 +6394,8 @@ def update_intracellular_params(self):
63856394

63866395

63876396
else:
6388-
self.intracellular_type_dropdown.setCurrentIndex(0)
6397+
if self.intracellular_type_dropdown is not None:
6398+
self.intracellular_type_dropdown.setCurrentIndex(0)
63896399

63906400
#-----------------------------------------------------------------------------------------
63916401
def update_custom_data_params(self):

bin/galaxy_functions.py

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
import os
2+
import glob
3+
import zipfile
4+
from PyQt5.QtWidgets import QMessageBox
5+
6+
try:
7+
from galaxy_ie_helpers import put
8+
except:
9+
pass
10+
11+
#-----------------------------------------------------------------
12+
# Helper functions for Galaxy
13+
def save_project_galaxy(self):
14+
fname = "my_model.zip"
15+
file_str = "config/*.csv"
16+
file_str = os.path.join(os.getcwd(), file_str)
17+
print('-------- save_project_galaxy(): zip up all ',file_str)
18+
19+
msgBox = QMessageBox()
20+
msgBox.setText(f"This will start a job that bundles your current model's config file, its cells and substrates ICs, and its rules, and creates and copies '{fname}' to the Galaxy History. You can download it from there once it completes.")
21+
msgBox.setIcon(QMessageBox.Information)
22+
msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
23+
returnValue = msgBox.exec()
24+
if returnValue == QMessageBox.Cancel:
25+
return
26+
27+
try:
28+
with zipfile.ZipFile(fname, 'w') as myzip:
29+
# myzip.write(self.current_xml_file)
30+
myzip.write(self.current_xml_file, os.path.basename(self.current_xml_file))
31+
for f in glob.glob(file_str):
32+
myzip.write(f, os.path.basename(f)) # 2nd arg avoids full filename
33+
# csv_files = glob.glob(file_str)
34+
# print("csv_files = ",csv_files)
35+
# for f in glob.glob(file_str):
36+
# myzip.write(f, os.path.basename(f)) # 2nd arg avoids full filename
37+
put(fname)
38+
# print("dummy put...")
39+
except:
40+
self.show_error_message(f"Error: put({fname})")
41+
return
42+
43+
44+
def load_project_galaxy_history(self):
45+
from galaxy_history import LoadProjectWindow
46+
self.project_historyUI = LoadProjectWindow()
47+
self.project_historyUI.xml_creator = self
48+
# hack to bring to foreground
49+
self.project_historyUI.hide()
50+
self.project_historyUI.show()
51+
52+
def get_galaxy_history(self):
53+
from galaxy_history import GalaxyHistoryWindow
54+
self.galaxy_historyUI = GalaxyHistoryWindow(self)
55+
# hack to bring to foreground
56+
self.galaxy_historyUI.hide()
57+
self.galaxy_historyUI.show()
58+
59+
def download_config_galaxy(self):
60+
# put("config/PhysiCell_settings.xml")
61+
# put( args.filepath, file_type=args.filetype, history_id=args.history_id )
62+
# fname = "/opt/pcstudio/config/PhysiCell_settings.xml"
63+
fname = self.current_xml_file
64+
msgBox = QMessageBox()
65+
msgBox.setText("This will start a job that copies your current model's config file to the Galaxy History. You can download it from there once it completes.")
66+
msgBox.setIcon(QMessageBox.Information)
67+
msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
68+
returnValue = msgBox.exec()
69+
if returnValue == QMessageBox.Cancel:
70+
return
71+
try:
72+
put(fname)
73+
# print("dummy put...")
74+
except:
75+
self.show_error_message(f"Error: put({fname})")
76+
return
77+
78+
def download_zipped_csv_galaxy(self):
79+
# fname = "/opt/pcstudio/all_csv.zip"
80+
msgBox = QMessageBox()
81+
msgBox.setText("This will start a job that copies a zip file of all output/*.csv to the Galaxy History. You can download it from there once it completes.")
82+
msgBox.setIcon(QMessageBox.Information)
83+
msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
84+
returnValue = msgBox.exec()
85+
if returnValue == QMessageBox.Cancel:
86+
return
87+
fname = "all_csv.zip"
88+
print("download_zipped_csv_galaxy(): cwd= ",os.getcwd())
89+
try:
90+
# file_str = "/opt/pcstudio/output/*.csv"
91+
file_str = "output/*.csv"
92+
file_str = os.path.join(os.getcwd(), file_str)
93+
print('-------- download_zipped_csv_galaxy(): zip up all ',file_str)
94+
# fname = "/opt/pcstudio/output/all_csv.zip"
95+
with zipfile.ZipFile(fname, 'w') as myzip:
96+
# csv_files = glob.glob(file_str)
97+
# print("csv_files = ",csv_files)
98+
for f in glob.glob(file_str):
99+
myzip.write(f, os.path.basename(f)) # 2nd arg avoids full filename
100+
except:
101+
self.show_error_message(f"Error zipping all output/*.csv")
102+
return
103+
104+
try:
105+
put(fname)
106+
# print("dummy put...")
107+
except:
108+
self.show_error_message(f"Error: put({fname})")
109+
110+
def download_all_zipped_galaxy(self):
111+
# fname = "/opt/pcstudio/all_output.zip"
112+
msgBox = QMessageBox()
113+
msgBox.setText("This will start a job that copies a zip file of all output/* to the Galaxy History. You can download it from there once it completes. If you have a lot of output files from your simulation, it may take a while to complete, but it runs in the background and will not affect your ability to continue using the Studio.")
114+
msgBox.setIcon(QMessageBox.Information)
115+
msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
116+
returnValue = msgBox.exec()
117+
if returnValue == QMessageBox.Cancel:
118+
return
119+
120+
fname = "all_output.zip"
121+
print("download_all_zipped_galaxy(): cwd= ",os.getcwd())
122+
try:
123+
# file_str = "/opt/pcstudio/output/*.csv"
124+
file_str = "output/*"
125+
file_str = os.path.join(os.getcwd(), file_str)
126+
print('-------- download_all_zipped_galaxy(): zip up all ',file_str)
127+
# fname = "/opt/pcstudio/output/all_csv.zip"
128+
with zipfile.ZipFile(fname, 'w') as myzip:
129+
# all_files = glob.glob(file_str)
130+
# print("all_files = ",all_files)
131+
for f in glob.glob(file_str):
132+
myzip.write(f, os.path.basename(f)) # 2nd arg avoids full filename
133+
except:
134+
self.show_error_message(f"Error zipping all output/*")
135+
return
136+
137+
try:
138+
put(fname)
139+
# print("dummy put")
140+
except:
141+
self.show_error_message(f"Error: put({fname})")

0 commit comments

Comments
 (0)