Commit 6a2e622c authored by gsaxena's avatar gsaxena
Browse files

This commit represents an attempt to run physiboss_cell_lines_mpi example from...

This commit represents an attempt to run physiboss_cell_lines_mpi example from Vincent. Had to bring that example in and lots of other files which we "thought" were not important. For e.g., files in beta directory which help to set-up MaBoss (this is downloaded then installed when we "make" physiboss_cell_lines_mpi project). Thus, execute on MN0 node (has outside internet connection). Doing "make clean" removes MaBoss and it needs to be downloded again with "make". The example does not crash but produces identical SVG files. Thus, committing and requesting Vincent to check the example.
parent 0c17e019
......@@ -63,8 +63,13 @@ all:
# sample projects
list-projects:
@echo "Sample projects: template2D template3D biorobots-sample cancer-biorobots-sample heterogeneity-sample"
@echo " cancer-immune-sample virus-macrophage-sample template"
@echo " cancer-immune-sample virus-macrophage-sample template pred-prey-farmer"
@echo ""
@echo "Sample intracellular projects: ode-energy-sample physiboss-cell-lines-sample cancer-metabolism-sample"
@echo "physiboss-cell-lines-mpi"
@echo ""
# ---- non-intracellular projects
template2D:
cp ./sample_projects/template2D/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
......@@ -139,6 +144,15 @@ virus-macrophage-sample:
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects/virus_macrophage/config/* ./config/
pred-prey-farmer:
cp ./sample_projects/pred_prey_farmer/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
cp ./sample_projects/pred_prey_farmer/main.cpp ./main.cpp
cp Makefile Makefile-backup
cp ./sample_projects/pred_prey_farmer/Makefile .
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects/pred_prey_farmer/config/* ./config/
beta-testing:
cp ./sample_projects/beta_testing/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
......@@ -148,6 +162,52 @@ beta-testing:
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects/beta_testing/config/* ./config/
# ---- intracellular projects
ode-energy-sample:
cp ./sample_projects_intracellular/ode/ode_energy/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
cp ./sample_projects_intracellular/ode/ode_energy/main.cpp ./main.cpp
cp Makefile Makefile-backup
cp ./sample_projects_intracellular/ode/ode_energy/Makefile .
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects_intracellular/ode/ode_energy/config/* ./config/
physiboss-cell-lines-sample:
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines/main.cpp ./main.cpp
cp Makefile Makefile-backup
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines/Makefile .
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines/config/* ./config/
physiboss-cell-lines-mpi:
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines_mpi/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines_mpi/main.cpp ./main.cpp
cp Makefile Makefile-backup
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines_mpi/Makefile .
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines_mpi/config/* ./config/
ecoli-acetic-switch-sample:
cp ./sample_projects_intracellular/fba/ecoli_acetic_switch/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
cp ./sample_projects_intracellular/fba/ecoli_acetic_switch/main_ecoli_acetic_switch.cpp ./main.cpp
cp Makefile Makefile-backup
cp ./sample_projects_intracellular/fba/ecoli_acetic_switch/Makefile ./
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects_intracellular/fba/ecoli_acetic_switch/config/* ./config/
cancer-metabolism-sample:
cp ./sample_projects_intracellular/fba/cancer_metabolism/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
cp ./sample_projects_intracellular/fba/cancer_metabolism/main.cpp ./main.cpp
cp Makefile Makefile-backup
cp ./sample_projects_intracellular/fba/cancer_metabolism/Makefile ./
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects_intracellular/fba/cancer_metabolism/config/* ./config/
# early examples for convergence testing
physicell_test_mech1: $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_mechanics_1.cpp
......
......@@ -66,8 +66,9 @@ list-projects:
@echo " cancer-immune-sample virus-macrophage-sample template pred-prey-farmer"
@echo ""
@echo "Sample intracellular projects: ode-energy-sample physiboss-cell-lines-sample cancer-metabolism-sample"
@echo "physiboss-cell-lines-mpi"
@echo ""
# ---- non-intracellular projects
template2D:
cp ./sample_projects/template2D/custom_modules/* ./custom_modules/
......@@ -142,7 +143,7 @@ virus-macrophage-sample:
cp ./sample_projects/virus_macrophage/Makefile .
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects/virus_macrophage/config/* ./config/
pred-prey-farmer:
cp ./sample_projects/pred_prey_farmer/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
......@@ -180,6 +181,15 @@ physiboss-cell-lines-sample:
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines/config/* ./config/
physiboss-cell-lines-mpi:
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines_mpi/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines_mpi/main.cpp ./main.cpp
cp Makefile Makefile-backup
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines_mpi/Makefile .
cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml
cp ./sample_projects_intracellular/boolean/physiboss_cell_lines_mpi/config/* ./config/
ecoli-acetic-switch-sample:
cp ./sample_projects_intracellular/fba/ecoli_acetic_switch/custom_modules/* ./custom_modules/
touch main.cpp && cp main.cpp main-backup.cpp
......
......@@ -26,7 +26,7 @@ class MaBoSSNetwork
RunConfig* config;
StochasticSimulationEngine* engine;
NetworkState state;
//NetworkState state; <--- Gaurav Saxena is making this public again so that we cast test code
NetworkState output_mask;
/** \brief Time step between each MaBoSS simulation */
......@@ -50,6 +50,7 @@ class MaBoSSNetwork
public:
NetworkState state;
/** Constructor */
MaBoSSNetwork() {
......
"""
anim_subtrate2D.py - quick & dirty contour plots of 2D substrates using matplotlib
Usage: (from an /output directory)
python anim_subtrate2D.py substrate_idx
substrate_idx: 0 offset
(rf. initial.xml for <variables> block to see substrates ("variable"))
Author: Randy Heiland
"""
import sys,pathlib
import xml.etree.ElementTree as ET
import os
import math
import scipy.io
import matplotlib
#import matplotlib.pyplot as plt # NB! do this AFTER the TkAgg line below!
from matplotlib.colors import BoundaryNorm
from matplotlib.ticker import MaxNLocator
import numpy as np
try:
# apparently we need mpl's Qt backend to do keypresses
# matplotlib.use("Qt5Agg")
matplotlib.use("TkAgg")
import matplotlib.pyplot as plt
except:
print("\n---Error: cannot use matplotlib's TkAgg backend")
# print("Consider installing Anaconda's Python 3 distribution.")
raise
current_idx = 0
# print("# args=",len(sys.argv)-1)
use_defaults = True
current_idx = 0
xmin = 0.0
xmax = 1000 # but overridden by "width" attribute in .svg
vmin = 0.0
vmax = 1050
fix_cmap = 0
time_delay = 0.1
# if (len(sys.argv) == 7):
# use_defaults = False
# kdx = 1
# current_idx = int(sys.argv[kdx])
# kdx += 1
# xmin = float(sys.argv[kdx])
# kdx += 1
# xmax = float(sys.argv[kdx])
# kdx += 1
# ymin = float(sys.argv[kdx])
# kdx += 1
# ymax = float(sys.argv[kdx])
# kdx += 1
# field_idx = int(sys.argv[kdx])
# else:
# print("Usage:")
# usage_str = "start_index xmin xmax ymin ymax field_idx"
# print(usage_str)
# print("e.g.,")
# eg_str = "%s 0 -500 500 -500 500 0" % (sys.argv[0])
# print(eg_str)
# sys.exit(1)
if (len(sys.argv) < 2):
print("Usage: " + sys.argv[0] + " substrate_idx")
print("(substrate_idx is 0-offset)\n")
sys.exit(1)
else:
kdx = 1
field_idx = int(sys.argv[kdx])
#field_idx = 0
field_idx += 4
print('current_idx, field_idx = ',current_idx, field_idx)
# figure out the domain sizes (might not be square)
ifname = "initial.xml"
tree = ET.parse(ifname)
xml_root = tree.getroot()
xcoord_vals = xml_root.find(".//x_coordinates").text.split()
ycoord_vals = xml_root.find(".//y_coordinates").text.split()
xmin = float(xcoord_vals[0])
xmax = float(xcoord_vals[-1]) # should be 999.0
ymin = float(ycoord_vals[0])
ymax = float(ycoord_vals[-1]) # should be 999.0
# numx = int((xmax - xmin) / xdel) # need to also round maybe?
# numy = int((ymax - ymin) / ydel)
numx = len(xcoord_vals)
numy = len(ycoord_vals)
print("numx, numy = ",numx,numy) # e.g., 75 75
fig = plt.figure(figsize=(7,5.8))
#ax = fig.gca()
count = -1
cbar = None
#-----------------------------------------------------
def plot_substrate():
global current_idx, axes_max, cbar
xml_file = "output%08d.xml" % current_idx
tree = ET.parse(xml_file)
root = tree.getroot()
# print('time=' + root.find(".//current_time").text)
mins = float(root.find(".//current_time").text)
hrs = mins/60.
days = hrs/24.
title_str = '%d days, %d hrs, %d mins' % (int(days),(hrs%24), mins - (hrs*60))
print(title_str)
fname = "output%08d_microenvironment0.mat" % current_idx
output_dir_str = '.'
fullname = output_dir_str + "/" + fname
if not pathlib.Path(fullname).is_file():
print("file not found",fullname)
return
info_dict = {}
scipy.io.loadmat(fullname, info_dict)
M = info_dict['multiscale_microenvironment']
print('plot_substrate: field_idx=',field_idx)
f = M[field_idx,:] #
print("M.shape = ",M.shape) # e.g., (6, 421875) (where 421875=75*75*75)
# numx = int(M.shape[1] ** (1./3) + 1)
# numy = numx
print("numx, numy = ",numx, numy )
nxny = numx * numy
# idx_plane = 37
# idx0 = idx_plane * nxny
# idx1 = idx0 + nxny
# xgrid = M[0, idx0:idx1].reshape(numy, numx)
# ygrid = M[1, idx0:idx1].reshape(numy, numx)
#N = int(math.sqrt(len(M[0,:])))
#grid2D = M[0,:].reshape(N,N)
xgrid = M[0, :].reshape(numy, numx)
ygrid = M[1, :].reshape(numy, numx)
# print("M.shape = ",M.shape) # e.g., (6, 421875) (where 421875=75*75*75)
# xgrid = M[0, :].reshape(numy, numx)
# ygrid = M[1, :].reshape(numy, numx)
# xvec = grid2D[0,:]
#xvec.size
#xvec.shape
num_contours = 30
num_contours = 10
# vmin = 30.
# vmax = 38.
levels = MaxNLocator(nbins=30).tick_values(vmin, vmax)
# cmap = plt.get_cmap('PiYG')
cmap = plt.get_cmap('viridis')
norm = BoundaryNorm(levels, ncolors=cmap.N, clip=True)
# my_plot = plt.contourf(xvec,xvec,M[field_idx,:].reshape(N,N), num_contours, cmap='viridis') #'viridis'
if fix_cmap > 0:
# my_plot = plt.contourf(xvec,xvec,M[field_idx,:].reshape(N,N), levels=levels, cmap=cmap)
my_plot = plt.contourf(xgrid, ygrid, M[field_idx, :].reshape(numy, numx, ), levels=levels, extend='both', cmap=cmap)
else:
# my_plot = plt.contourf(xvec,xvec,M[field_idx,:].reshape(N,N), cmap=cmap)
my_plot = plt.contourf(xgrid, ygrid, M[field_idx, :].reshape(numy, numx), cmap=cmap)
if cbar == None: # if we always do this, it creates an additional colorbar!
# cbar = plt.colorbar(my_plot, boundaries=np.arange(vmin, vmax, 1.0))
cbar = plt.colorbar(my_plot)
else:
cbar.ax.clear()
cbar = plt.colorbar(my_plot, cax=cbar.ax)
# plt.axis('equal')
plt.title(title_str)
# plt.show()
plt.draw_if_interactive()
png_file = "aaa%08d.png" % current_idx
fig.savefig(png_file)
plt.pause(time_delay)
#------------------------------
step_value = 1
def press(event):
global current_idx, step_value
# print('press', event.key)
sys.stdout.flush()
if event.key == 'escape':
sys.exit(1)
elif event.key == 'h': # help
print('esc: quit')
print('right arrow: increment by step_value')
print('left arrow: decrement by step_value')
print('up arrow: increment step_value by 1')
print('down arrow: decrement step_value by 1')
print('0: reset to 0th frame')
print('h: help')
elif event.key == 'left': # left arrow key
# print('go backwards')
# fig.canvas.draw()
current_idx -= step_value
if (current_idx < 0):
current_idx = 0
plot_substrate()
# plot_svg()
elif event.key == 'right': # right arrow key
# print('go forwards')
# fig.canvas.draw()
current_idx += step_value
plot_substrate()
# plot_svg()
elif event.key == 'up': # up arrow key
step_value += 1
print('step_value=',step_value)
elif event.key == 'down': # down arrow key
step_value -= 1
if (step_value <= 0):
step_value = 1
print('step_value=',step_value)
elif event.key == '0': # reset to 0th frame/file
current_idx = 0
plot_substrate()
# plot_svg()
else:
print('press', event.key)
#------------------------------
plot_substrate()
print("\nNOTE: click in plot window to give it focus before using arrow key to advance.")
fig.canvas.mpl_connect('key_press_event', press)
#plot_substrate(frame_idx)
plt.show()
{
"coin-or":
{
"_refurl": "https://www.coin-or.org/download/binary/Clp/",
"linux-x64":
{
"version": "Clp-1.17.6-linux64.zip",
"url": "https://maboss.curie.fr/pub/Clp-1.17.6-linux64.zip"
},
"win64":
{
"version": "Clp-1.17.6-win64.zip",
"url": "https://maboss.curie.fr/pub/Clp-1.17.6-win64.zip"
},
"osx":
{
"version": "Clp-1.17.6-osx64.zip",
"url": "https://maboss.curie.fr/pub/Clp-1.17.6-osx64.zip"
}
},
"libsbml":
{
"_refurl": "https://sourceforge.net/projects/sbml/files/libsbml/5.14.0-experimental/binaries/",
"linux-x64":
{
"version": "libSBML-5.19.0-linux64.zip",
"url": "https://maboss.curie.fr/pub/libSBML-5.19.0-linux64.zip"
},
"win64":
{
"version": "libSBML-5.19.0-win64.zip",
"url": "https://maboss.curie.fr/pub/libSBML-5.19.0-win64.zip"
},
"osx":
{
"version": "libSBML-5.19.0-osx64.zip",
"url": "https://maboss.curie.fr/pub/libSBML-5.19.0-osx64.zip"
}
}
}
# This script provides simple parameter sweep functionality. The script creates
# This script provides simple parameter exploration functionality. The script creates
# a new folder (subdirectory) for each set of parameters, makes changes to a default
# configuration (.xml) file using specified parameter values (in an accompanying .txt file),
# copies the new config file into the new folder, then
......@@ -9,62 +9,71 @@ import xml.etree.ElementTree as ET
from shutil import copyfile
import os
import sys
import subprocess
print(len(sys.argv))
# print(len(sys.argv))
if (len(sys.argv) < 3):
usage_str = "Usage: %s <pgm> <params.txt>" % (sys.argv[0])
usage_str = "Usage: %s <exec_pgm> <params.txt>" % (sys.argv[0])
print(usage_str)
print("e.g.: python params_run.py cancer_biorobots params_run.txt")
print("e.g.: python params_run.py biorobots params_biorobots.txt")
exit(1)
else:
pgm = sys.argv[1]
exec_pgm = sys.argv[1]
params_file = sys.argv[2]
background_str = " &" # works on Unix
if sys.platform == 'win32':
background_str = ""
xml_file_in = 'config/PhysiCell_settings.xml'
xml_file_out = 'config/tmp.xml'
copyfile(xml_file_in,xml_file_out)
copyfile(xml_file_in, xml_file_out)
tree = ET.parse(xml_file_out)
xml_root = tree.getroot()
first_time = True
output_dirs = []
with open(params_file) as f:
for line in f:
print(len(line),line)
# print(len(line),line)
print(line, end="")
if (line[0] == '#'):
continue
(key, val) = line.split()
if (key == 'folder'):
if first_time: # we've read the 1st 'folder'
first_time = False
else: # we've read additional 'folder's
# write the config file to the previous folder (output) dir and start a simulation
print('---write (previous) config file and start its sim')
tree.write(xml_file_out)
cmd = pgm + " " + xml_file_out + " &"
os.system(cmd)
xml_file_out = val + '/config.xml' # copy config file into the output dir
output_dirs.append(val)
if ('.' in key):
if (key == 'run_it'):
# write the config file to the previous folder (output) dir and start a simulation
# print('---write config file and start its sim')
print('---write config file (and start sim): ', xml_file_out)
tree.write(xml_file_out) # will create folder_name/config.xml
log_file = folder_name + ".log"
cmd = exec_pgm + " " + xml_file_out + " > " + log_file + " " + background_str
print("----- cmd = ",cmd)
# os.system(cmd) # <------ Execute the simulation
# subprocess.Popen([exec_pgm, xml_file_out])
with open(log_file,"w") as outf:
subprocess.Popen([exec_pgm, xml_file_out],stdout=outf)
elif ('.' in key):
k = key.split('.')
uep = xml_root
for idx in range(len(k)):
uep = uep.find('.//' + k[idx]) # unique entry point (uep) into xml
# print(k[idx])
uep.text = val
# d[key] = val
else:
if (key == 'folder' and not os.path.exists(val)):
print('creating ' + val)
os.makedirs(val)
xml_root.find('.//' + key).text = val
tree.write(xml_file_out)
if (key == 'folder'):
folder_name = val
output_dirs.append(folder_name)
if (not os.path.exists(folder_name)):
print("--- parsed 'folder', makedir " + folder_name)
os.makedirs(folder_name)
# xml_file_out = folder_name + '/config.xml' # copy config file into the output dir
xml_file_out = os.path.join(folder_name, 'config.xml') # copy config file into the output dir
#cwd = os.getcwd()
cmd = pgm + " " + xml_file_out + " &"
os.system(cmd)
try:
xml_root.find('.//' + key).text = val
except:
print("--- Error: could not find ",key," in .xml\n")
sys.exit(1)
print(output_dirs)
print("\n ------\n Your output results will appear in these directories:\n ",output_dirs)
print("and check for a .log file of each name for your terminal output from each simulation.\n")
"""
Provide simple plotting functionality for PhysiCell output results.
Authors:
Randy Heiland (heiland@iu.edu)
Dr. Paul Macklin (macklinp@iu.edu)
--- Versions ---
0.1 - initial version
"""
# https://doc.qt.io/qtforpython/gettingstarted.html
import os
import sys
import getopt
import shutil
from pathlib import Path
import xml.etree.ElementTree as ET # https://docs.python.org/2/library/xml.etree.elementtree.html
from xml.dom import minidom
from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import *
from vis_tab_cells_only import Vis
def SingleBrowse(self):
# if len(self.csv) < 2:
filePath = QFileDialog.getOpenFileName(self,'',".",'*.xml')
# if filePath != "" and not filePath in self.csv:
# self.csv.append(filePath)
# print(self.csv)
class PhysiCellXMLCreator(QWidget):
# def __init__(self, parent = None):
def __init__(self, parent = None):
super(PhysiCellXMLCreator, self).__init__(parent)
self.title_prefix = "PhysiCell Visualization"
self.setWindowTitle(self.title_prefix)
# Menus
vlayout = QVBoxLayout(self)
# vlayout.setContentsMargins(5, 35, 5, 5)
# menuWidget = QWidget(self.menu())
# vlayout.addWidget(menuWidget)
# self.setWindowIcon(self.style().standardIcon(getattr(QStyle, 'SP_DialogNoButton')))
# self.setWindowIcon(QtGui.QIcon('physicell_logo_25pct.png'))
# self.grid = QGridLayout()
# lay.addLayout(self.grid)
self.setLayout(vlayout)
# self.setMinimumSize(400, 790) # width, height (height >= Cell Types|Death params)
# self.setMinimumSize(400, 500) # width, height (height >= Cell Types|Death params)
# self.setMinimumSize(800, 620) # width, height (height >= Cell Types|Death params)
# self.setMinimumSize(800, 660) # width, height (height >= Cell Types|Death params)
# self.setMinimumSize(800, 800) # width, height (height >= Cell Types|Death params)
self.setMinimumSize(700, 770) # width, height (height >= Cell Types|Death params)
# self.setMinimumSize(600, 600) # width, height (height >= Cell Types|Death params)
# self.resize(400, 790) # width, height (height >= Cell Types|Death params)
# self.menubar = QtWidgets.QMenuBar(self)
# self.file_menu = QtWidgets.QMenu('File')
# self.file_menu.insertAction("Open")
# self.menubar.addMenu(self.file_menu)
# GUI tabs
# By default, let's startup the app with a default of template2D (a copy)
# self.new_model_cb() # default on startup
# read_file = "../data/subcellular_flat.xml"
# read_file = "../data/cancer_biorobots_flat.xml"
# read_file = "../data/pred_prey_flat.xml"
model_name = "pred_prey_flat"
model_name = "biorobots_flat"
model_name = "cancer_biorobots_flat"
model_name = "test1"
model_name = "test-gui"
model_name = "covid19_v5_flat"
model_name = "template"
# model_name = "randy_test" #rwh
# read_file = "data/" + model_name + ".xml"
# then what??
# binDirectory = os.path.realpath(os.path.abspath(__file__))