Commit 3b61c022 authored by Randy Heiland's avatar Randy Heiland
Browse files

v3

parent afb44c5e
# pc4covid19 - COVID19 tissue simulator nanoHUB app
# pc4covid19 - COVID19 (SARS-CoV-2) tissue simulator nanoHUB app
**Version:** 2.1 - uses the core model at https://github.com/pc4covid19/COVID19/releases/tag/0.2.1
**Version:** 3.0
**Release date:** 26 April 2020
**Release date:** 3 July 2020
## Overview
This repository contains code and data for the nanoHUB app https://nanohub.org/tools/pc4covid19.
......@@ -20,9 +20,12 @@ for a summary of changes to the model.
**This model will be continually refined with input from the community, particularly experts in infectious diseases. The validation state will be updated as this progresses.**
## Release summary:
### 2.1:
Sync up with the version number of the published app, https://nanohub.org/tools/pc4covid19, and include a reference to the version of the core model in this README.
## Release summary:
### 3.0:
The major change to the GUI in this release is the addition of a 'Cell Types' tab.
This allows editing parameters associated with `<cell_definitions>` in the configuration file.
This version also includes a `<style>` block in the Jupyter notebook that fixed an unwanted scrollbar in the lengthy `About` tab.
### 2.0:
The major change to the GUI in this release is the addition of an 'Animate' tab.
......
from ipywidgets import Output
from ipywidgets import Output, Tab, Layout
from IPython.display import display, HTML
class AboutTab(object):
def __init__(self):
# self.tab = Output(layout={'height': '600px'})
# self.tab = Output(layout={'height': '900px'})
# self.tab = Output(layout={height=’85%’,min_height=’350px’})
# self.background = Output(layout={'height': 'auto'})
# self.legend = Output(layout={'height': 'auto'})
self.tab = Output(layout={'height': 'auto'})
# self.tab.append_display_data(HTML(filename='doc/about-good.html'))
# self.tab.append_display_data(HTML(filename='doc/about-bad.html'))
# self.background.append_display_data(HTML(filename='doc/about_background.html'))
# self.legend.append_display_data(HTML(filename='doc/about_legend.html'))
self.tab.append_display_data(HTML(filename='doc/about.html'))
# tab_layout = Layout(width='auto',height='auto', overflow_y='scroll',) # border='2px solid black',
# titles = ['Background', 'Legend']
# self.tab = Tab(children=[self.background, self.legend],
# _titles={i: t for i, t in enumerate(titles)},
# layout=tab_layout)
This diff is collapsed.
This diff is collapsed.
......@@ -10,6 +10,11 @@ from about import AboutTab
from config import ConfigTab
from microenv_params import MicroenvTab
from user_params import UserTab
try:
from cell_types import CellTypesTab
except:
# print("cell_types.py does not exist due to no <cell_definitions>")
pass
# from svg import SVGTab
from substrates import SubstrateTab
from animate_tab import AnimateTab
......@@ -42,8 +47,13 @@ full_xml_filename = os.path.abspath(xml_file)
tree = ET.parse(full_xml_filename) # this file cannot be overwritten; part of tool distro
xml_root = tree.getroot()
microenv_tab = MicroenvTab()
user_tab = UserTab()
if xml_root.find('.//cell_definitions'):
cell_types_tab = CellTypesTab()
# svg = SVGTab()
sub = SubstrateTab()
animate_tab = AnimateTab()
......@@ -132,12 +142,12 @@ def write_config_file(name):
sub.update_params(config_tab, user_tab)
# sub.numx = math.ceil( (config_tab.xmax.value - config_tab.xmin.value) / config_tab.xdelta.value )
# sub.numy = math.ceil( (config_tab.ymax.value - config_tab.ymin.value) / config_tab.ydelta.value )
# print("pc4covid19.py: ------- sub.numx, sub.numy = ", sub.numx, sub.numy)
# print("pc4covid19_v3.py: ------- sub.numx, sub.numy = ", sub.numx, sub.numy)
# callback from write_config_button
# def write_config_file_cb(b):
# path_to_share = os.path.join('~', '.local','share','pc4covid19')
# path_to_share = os.path.join('~', '.local','share','pc4covid19_v3')
# dirname = os.path.expanduser(path_to_share)
# val = write_config_box.value
......@@ -151,7 +161,7 @@ def write_config_file(name):
# default & previous config options)
def get_config_files():
cf = {'DEFAULT': full_xml_filename}
path_to_share = os.path.join('~', '.local','share','pc4covid19')
path_to_share = os.path.join('~', '.local','share','pc4covid19_v3')
dirname = os.path.expanduser(path_to_share)
try:
os.makedirs(dirname)
......@@ -163,12 +173,12 @@ def get_config_files():
# Find the dir path (full_path) to the cached dirs
if nanoHUB_flag:
full_path = os.path.expanduser("~/data/results/.submit_cache/pc4covid19") # does Windows like this?
full_path = os.path.expanduser("~/data/results/.submit_cache/pc4covid19_v3") # does Windows like this?
else:
# local cache
try:
cachedir = os.environ['CACHEDIR']
full_path = os.path.join(cachedir, "pc4covid19")
full_path = os.path.join(cachedir, "pc4covid19_v3")
except:
# print("Exception in get_config_files")
return cf
......@@ -215,7 +225,7 @@ def run_done_func(s, rdir):
if nanoHUB_flag:
# Email the user that their job has completed
os.system("submit mail2self -s 'nanoHUB pc4covid19' -t 'Your Run completed.'&")
os.system("submit mail2self -s 'nanoHUB pc4covid19_v3' -t 'Your Run completed.'&")
# save the config file to the cache directory
shutil.copy('config.xml', rdir)
......@@ -238,7 +248,6 @@ def run_done_func(s, rdir):
animate_tab.gen_button.disabled = False
# with debug_view:
# print('RDF DONE')
......@@ -290,7 +299,7 @@ def run_sim_func(s):
if nanoHUB_flag:
if remote_cb.value:
s.run(run_name, "-v ncn-hub_M@brown -n 8 -w 1440 pc4covid19-r7 config.xml") # "-r7" suffix??
s.run(run_name, "-v ncn-hub_M@brown -n 8 -w 1440 pc4covid19_v3-r7 config.xml") # "-r7" suffix??
else:
# read_config.index = 0 # reset Dropdown 'Load Config' to 'DEFAULT' when Run interactively
s.run(run_name, "--local ../bin/myproj config.xml")
......@@ -304,7 +313,6 @@ def run_sim_func(s):
# print('run_sim_func DONE')
# callback for stdout from simulation
def outcb(s):
# This is called when new output is received.
# Only update file list for certain messages:
......@@ -314,7 +322,7 @@ def outcb(s):
# svg.update('')
# sub.update('')
# sub.update_params(config_tab)
sub.update() # this only updates the "# cell frames" (max_frames) when stdout = "current simulated time"
sub.update()
return s
......@@ -357,14 +365,14 @@ if nanoHUB_flag:
run_button = Submit(label='Run',
start_func=run_sim_func,
done_func=run_done_func,
cachename='pc4covid19',
cachename='pc4covid19_v3',
showcache=False,
outcb=outcb)
else:
if (hublib_flag):
run_button = RunCommand(start_func=run_sim_func,
done_func=run_done_func,
cachename='pc4covid19',
cachename='pc4covid19_v3',
showcache=False,
outcb=outcb)
else:
......@@ -386,18 +394,24 @@ if nanoHUB_flag or hublib_flag:
read_config.observe(read_config_cb, names='value')
tab_height = 'auto'
tab_layout = widgets.Layout(width='auto',height=tab_height, overflow_y='scroll',) # border='2px solid black',
titles = ['About', 'Config Basics', 'Microenvironment', 'User Params', 'Out: Plots', 'Animate']
# titles = ['About', 'Config Basics', 'Microenvironment', 'User Params', 'Out: Plots']
# tabs = widgets.Tab(children=[about_tab.tab, config_tab.tab, microenv_tab.tab, user_tab.tab, sub.tab],
tabs = widgets.Tab(children=[about_tab.tab, config_tab.tab, microenv_tab.tab, user_tab.tab, sub.tab, animate_tab.tab],
#tab_layout = widgets.Layout(width='auto',height=tab_height, overflow_y='scroll',) # border='2px solid black',
tab_layout = widgets.Layout(width='auto',height=tab_height) # border='2px solid black',
if xml_root.find('.//cell_definitions'):
titles = ['About', 'Config Basics', 'Microenvironment', 'User Params', 'Cell Types', 'Out: Plots', 'Animate']
tabs = widgets.Tab(children=[about_tab.tab, config_tab.tab, microenv_tab.tab, user_tab.tab, cell_types_tab.tab, sub.tab, animate_tab.tab],
_titles={i: t for i, t in enumerate(titles)})
# layout=tab_layout)
else:
titles = ['About', 'Config Basics', 'Microenvironment', 'User Params', 'Out: Plots', 'Animate']
tabs = widgets.Tab(children=[about_tab.tab, config_tab.tab, microenv_tab.tab, user_tab.tab, sub.tab, animate_tab.tab],
_titles={i: t for i, t in enumerate(titles)},
layout=tab_layout)
homedir = os.getcwd()
tool_title = widgets.Label(r'\(\textbf{PhysiCell model of COVID19}\)')
# tool_title = widgets.Label(r'\(\textbf{pc4covid19_v3}\)')
tool_title = widgets.Label(r'\(\textbf{PhysiCell model for SARS-CoV-2}\)')
if nanoHUB_flag or hublib_flag:
# define this, but don't use (yet)
remote_cb = widgets.Checkbox(indent=False, value=False, description='Submit as Batch Job to Clusters/Grid')
......
This diff is collapsed.
......@@ -75,6 +75,7 @@ class SubstrateTab(object):
# self.y_range = 2000.
self.show_nucleus = False
self.semi_transparent = False
self.show_edge = True
substrates_default_disabled_flag = True # True = disable them by default; False=enable them
......@@ -95,8 +96,8 @@ class SubstrateTab(object):
tab_height = '500px'
constWidth = '180px'
constWidth2 = '150px'
tab_layout = Layout(width='900px', # border='2px solid black',
height=tab_height, ) #overflow_y='scroll')
# tab_layout = Layout(width='900px', # border='2px solid black',
# height=tab_height, ) #overflow_y='scroll')
max_frames = 1
# self.mcds_plot = interactive(self.plot_substrate, frame=(0, max_frames), continuous_update=False)
......@@ -262,13 +263,30 @@ class SubstrateTab(object):
def cell_nucleus_toggle_cb(b):
# self.update()
if (self.cell_nucleus_toggle.value):
self.show_nucleus = True
# self.show_nucleus = True
self.show_nucleus = False
else:
self.show_nucleus = False
self.i_plot.update()
self.cell_nucleus_toggle.observe(cell_nucleus_toggle_cb)
#---------------------
self.cell_semitrans_toggle = Checkbox(
description='translucent',
disabled=False,
value = self.semi_transparent,
# layout=Layout(width=constWidth2),
)
def cell_semitrans_toggle_cb(b):
if (self.cell_semitrans_toggle.value):
self.semi_transparent = True
else:
self.semi_transparent = False
self.i_plot.update()
self.cell_semitrans_toggle.observe(cell_semitrans_toggle_cb)
#----
self.cell_edges_toggle = Checkbox(
description='edges',
......@@ -298,9 +316,12 @@ class SubstrateTab(object):
if (self.cells_toggle.value):
self.cell_edges_toggle.disabled = False
self.cell_nucleus_toggle.disabled = False
self.cell_semitrans_toggle.disabled = False
# self.semi_transparent = True
else:
self.cell_edges_toggle.disabled = True
self.cell_nucleus_toggle.disabled = True
self.cell_semitrans_toggle.disabled = True
self.cells_toggle.observe(cells_toggle_cb)
......@@ -355,7 +376,9 @@ class SubstrateTab(object):
align_items='stretch',
flex_direction='row',
display='flex'))
row1b = Box( [self.cells_toggle, self.cell_nucleus_toggle, self.cell_edges_toggle], layout=Layout(border='1px solid black',
# row1b = Box( [self.cells_toggle, self.cell_nucleus_toggle, self.cell_edges_toggle], layout=Layout(border='1px solid black',
# row1b = Box( [self.cells_toggle, self.cell_semitrans_toggle, self.cell_edges_toggle], layout=Layout(border='1px solid black',
row1b = Box( [self.cells_toggle, self.cell_edges_toggle], layout=Layout(border='1px solid black',
width='50%',
height='',
align_items='stretch',
......@@ -862,17 +885,19 @@ class SubstrateTab(object):
# print('max=',markers_size.max())
#rwh - temp fix - Ah, error only occurs when "edges" is toggled on
# alpha_val = 1.0
# if (self.semi_transparent):
# alpha_val = 0.5
if (self.show_edge):
try:
# plt.scatter(xvals,yvals, s=markers_size, c=rgbs, edgecolor='black', linewidth=0.5)
self.circles(xvals,yvals, s=rvals, color=rgbs, edgecolor='black', linewidth=0.5)
# cell_circles = self.circles(xvals,yvals, s=rvals, color=rgbs, edgecolor='black', linewidth=0.5)
# self.circles(xvals,yvals, s=rvals, color=rgbs, edgecolor='black', linewidth=0.5, alpha=alpha_val)
cell_circles = self.circles(xvals,yvals, s=rvals, color=rgbs, edgecolor='black', linewidth=0.5)
# plt.sci(cell_circles)
except (ValueError):
pass
else:
# plt.scatter(xvals,yvals, s=markers_size, c=rgbs)
self.circles(xvals,yvals, s=rvals, color=rgbs)
# self.circles(xvals,yvals, s=rvals, color=rgbs, alpha=alpha_val, edgecolor=None )
# if (self.show_tracks):
# for key in self.trackd.keys():
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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