Skip to content

Commit

Permalink
Merge pull request #322 from favreau/master
Browse files Browse the repository at this point in the history
Fixes in covid movie scripts
  • Loading branch information
favreau authored Nov 13, 2023
2 parents bfc2458 + 90819d0 commit 957dcae
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 127 deletions.
108 changes: 10 additions & 98 deletions bioexplorer/pythonsdk/notebooks/widgets/BioExplorer_widgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 55,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -24,141 +24,53 @@
},
{
"cell_type": "code",
"execution_count": 56,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# w.display_clipping_planes([-50, 50])"
"w.display_clipping_planes([-50, 50])"
]
},
{
"cell_type": "code",
"execution_count": 57,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"core = be.core_api()\n",
"core.set_environment_map('/media/favreau/medias/hdri/0000.jpg')\n",
"status = core.set_renderer(\n",
" background_color=[0.2, 0.15, 0.3], head_light=False,\n",
" current='advanced',subsampling=4, max_accum_frames=64)\n",
"params = core.AdvancedRendererParams()\n",
"params.gi_samples = 1\n",
"params.gi_strength = 0.5\n",
"params.gi_ray_length = 100.0\n",
"params.shadow_intensity = 1.0\n",
"params.soft_shadow_strength = 0.0\n",
"params.epsilon_multiplier = 100.0\n",
"params.max_ray_depth = 10\n",
"params.show_background = True\n",
"params.main_exposure = 1.0\n",
"status = core.set_renderer_params(params)\n",
"status = core.set_renderer()"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b19eccf2f90247b2924291e07390e801",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HBox(children=(Select(description='Models:', options=('Demo scene',), value='Demo scene'), Sele…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"w.display_palette_for_models()"
]
},
{
"cell_type": "code",
"execution_count": 59,
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "020d85543ca745d9a35b0ca411b07846",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(VBox(children=(FloatSlider(value=0.5, description='X', max=1.0), FloatSlider(value=0.5, descrip…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"w.display_focal_distance(with_preview=False)"
]
},
{
"cell_type": "code",
"execution_count": 60,
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "73eca5277dfa467fa9815b7340dd308c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HBox(children=(Select(description='Models:', options=('Demo scene',), value='Demo scene'), Sele…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"w.display_palette_for_models()"
]
},
{
"cell_type": "code",
"execution_count": 61,
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'DEFAULT_GRID_LAYOUT' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/home/favreau/code/favreau/BioExplorer/bioexplorer/pythonsdk/notebooks/widgets/BioExplorer_widgets.ipynb Cell 8\u001b[0m line \u001b[0;36m1\n\u001b[0;32m----> <a href='vscode-notebook-cell:/home/favreau/code/favreau/BioExplorer/bioexplorer/pythonsdk/notebooks/widgets/BioExplorer_widgets.ipynb#X11sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m w\u001b[39m.\u001b[39;49mdisplay_model_visibility()\n",
"File \u001b[0;32m~/Notebooks/env/lib/python3.10/site-packages/bioexplorer/notebook_widgets.py:638\u001b[0m, in \u001b[0;36mWidgets.display_model_visibility\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 635\u001b[0m hide_aabb_btn\u001b[39m.\u001b[39mon_click(hide_aabbs)\n\u001b[1;32m 636\u001b[0m adjust_camera_btn\u001b[39m.\u001b[39mon_click(adjust_camera)\n\u001b[0;32m--> 638\u001b[0m hbox \u001b[39m=\u001b[39m HBox([model_select, hbox_params], layout\u001b[39m=\u001b[39mDEFAULT_GRID_LAYOUT)\n\u001b[1;32m 639\u001b[0m display(hbox)\n",
"\u001b[0;31mNameError\u001b[0m: name 'DEFAULT_GRID_LAYOUT' is not defined"
]
}
],
"outputs": [],
"source": [
"w.display_model_visibility()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def _add_metabolites(self, frame):
variable_guid = int(variable)
variable_description = variables[variable][1]
location_guid = int(location)
file_name = metabolites_folder + pdb_guid + '.pdb'
file_name = os.path.join(metabolites_folder, pdb_guid + '.pdb')
concentration = self._get_concentration(
variable_guid, simulation_guid, frame, location_guid)
nb_molecules = self._get_nb_molecules(concentration, location_guid)
Expand Down
26 changes: 13 additions & 13 deletions bioexplorer/pythonsdk/scripts/animated_high_glucose_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Surfactant,
Membrane,
Cell,
Sugars,
Sugar,
Volume,
MolecularSystemAnimationParams,
Vector2,
Expand Down Expand Up @@ -130,7 +130,7 @@ def __init__(
image_k=4,
image_samples_per_pixel=64,
log_level=1,
shaders=list(["bio_explorer"]),
shaders=list(["advanced"]),
magnetic=False,
):
self._magnetic = magnetic
Expand Down Expand Up @@ -445,7 +445,7 @@ def _add_cell(self, frame):

ace2_receptor = Protein(
name=receptor_name,
source=pdb_folder + "6m18.pdb",
source=os.path.join(pdb_folder, "6m18.pdb"),
occurrences=nb_receptors,
transmembrane_params=Vector2(-6.0, 5.0),
animation_params=MolecularSystemAnimationParams(
Expand All @@ -455,10 +455,10 @@ def _add_cell(self, frame):

membrane = Membrane(
lipid_sources=[
membrane_folder + "segA.pdb",
membrane_folder + "segB.pdb",
membrane_folder + "segC.pdb",
membrane_folder + "segD.pdb",
os.path.join(membrane_folder, "segA.pdb"),
os.path.join(membrane_folder, "segB.pdb"),
os.path.join(membrane_folder, "segC.pdb"),
os.path.join(membrane_folder, "segD.pdb"),
],
animation_params=MolecularSystemAnimationParams(
random_seed, frame + 1, 0.025, frame + 2, 0.2
Expand Down Expand Up @@ -570,7 +570,7 @@ def _add_cell(self, frame):
o_glycan_name = (
name + "_" + BioExplorer.NAME_GLYCAN_O_GLYCAN + "_" + str(index[0])
)
o_glycan = Sugars(
o_glycan = Sugar(
assembly_name=name,
name=o_glycan_name,
source=o_glycan_paths[0],
Expand All @@ -583,7 +583,7 @@ def _add_cell(self, frame):
0, 0, 0.0, frame + count + 5, 0.2
),
)
self._be.add_sugars(o_glycan)
self._be.add_sugar(o_glycan)
count += 1

def _add_surfactant_d(self, name, position, rotation, animation_params):
Expand Down Expand Up @@ -623,15 +623,15 @@ def _add_surfactant_a(self, name, position, rotation, animation_params):
def _add_glucose_to_surfactant_head(self, name):
for index in [321, 323]:
glucose_name = name + "_" + BioExplorer.NAME_GLUCOSE + "_" + str(index)
glucose = Sugars(
glucose = Sugar(
assembly_name=name,
name=glucose_name,
source=glucose_path,
protein_name=name + "_" + BioExplorer.NAME_SURFACTANT_HEAD,
representation=glycan_representation,
site_indices=[index],
)
self._be.add_sugars(glucose)
self._be.add_sugar(glucose)

def _add_surfactants_d(self, frame):
spd_sequences = [[-1550, 3750], [0, 3750], [0, 3750]]
Expand Down Expand Up @@ -827,7 +827,7 @@ def _set_clipping_planes(self):
self._core.add_clip_plane(plane)

def set_rendering_settings(self, renderer):
if renderer == "bio_explorer":
if renderer == "advanced":
self._core.set_renderer(
background_color=[96 / 255, 125 / 255, 139 / 255],
current=renderer,
Expand Down Expand Up @@ -988,7 +988,7 @@ def main(argv):
magnetic=args.magnetic,
)

scenario.set_rendering_settings("bio_explorer")
scenario.set_rendering_settings("advanced")
scenario.render_movie(
start_frame=args.from_frame,
end_frame=args.to_frame,
Expand Down
30 changes: 15 additions & 15 deletions bioexplorer/pythonsdk/scripts/animated_low_glucose_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Membrane,
Surfactant,
Cell,
Sugars,
Sugar,
MolecularSystemAnimationParams,
Volume,
Vector2,
Expand Down Expand Up @@ -132,7 +132,7 @@ def __init__(
image_k=4,
image_samples_per_pixel=64,
log_level=1,
shaders=list(["bio_explorer"]),
shaders=list(["advanced"]),
):
super().__init__(
hostname,
Expand Down Expand Up @@ -365,7 +365,7 @@ def _add_cell(self, frame):

ace2_receptor = Protein(
name=receptor_name,
source=pdb_folder + "6m18.pdb",
source=os.path.join(pdb_folder, "6m18.pdb"),
occurrences=nb_receptors,
transmembrane_params=Vector2(-6.0, 5.0),
animation_params=MolecularSystemAnimationParams(
Expand All @@ -375,10 +375,10 @@ def _add_cell(self, frame):

membrane = Membrane(
lipid_sources=[
membrane_folder + "segA.pdb",
membrane_folder + "segB.pdb",
membrane_folder + "segC.pdb",
membrane_folder + "segD.pdb",
os.path.join(membrane_folder, "segA.pdb"),
os.path.join(membrane_folder, "segB.pdb"),
os.path.join(membrane_folder, "segC.pdb"),
os.path.join(membrane_folder, "segD.pdb"),
],
animation_params=MolecularSystemAnimationParams(
random_seed, frame + 1, 0.025, frame + 2, 0.2
Expand Down Expand Up @@ -483,7 +483,7 @@ def _add_cell(self, frame):
o_glycan_name = (
name + "_" + BioExplorer.NAME_GLYCAN_O_GLYCAN + "_" + str(index[0])
)
o_glycan = Sugars(
o_glycan = Sugar(
assembly_name=name,
name=o_glycan_name,
source=o_glycan_paths[0],
Expand All @@ -496,7 +496,7 @@ def _add_cell(self, frame):
0, 0, 0.0, frame + count + 5, 0.2
),
)
self._check(self._be.add_sugars(o_glycan))
self._check(self._be.add_sugar(o_glycan))
count += 1

def _add_surfactant_d(self, name, position, rotation, animation_params):
Expand Down Expand Up @@ -717,10 +717,10 @@ def _add_lymphocyte(self, frame):
]

pdb_lipids = [
membrane_folder + "segA.pdb",
membrane_folder + "segB.pdb",
membrane_folder + "segC.pdb",
membrane_folder + "segD.pdb",
os.path.join(membrane_folder, "segA.pdb"),
os.path.join(membrane_folder, "segB.pdb"),
os.path.join(membrane_folder, "segC.pdb"),
os.path.join(membrane_folder, "segD.pdb"),
]

membrane = Membrane(
Expand Down Expand Up @@ -797,7 +797,7 @@ def _set_clipping_planes(self):
self._core.add_clip_plane(plane)

def set_rendering_settings(self, renderer):
if renderer == "bio_explorer":
if renderer == "advanced":
self._core.set_renderer(
background_color=[96 / 255, 125 / 255, 139 / 255],
current=renderer,
Expand Down Expand Up @@ -951,7 +951,7 @@ def main(argv):
shaders=args.shaders,
)

scenario.set_rendering_settings("bio_explorer")
scenario.set_rendering_settings("advanced")
scenario.render_movie(
start_frame=args.from_frame,
end_frame=args.to_frame,
Expand Down

0 comments on commit 957dcae

Please sign in to comment.