Skip to content

Commit

Permalink
nanoshaper changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinAchondo committed Jun 11, 2024
1 parent c0a09d6 commit 1d7c244
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
6 changes: 3 additions & 3 deletions xppbe/Mesh/Mesh_softwares/NanoShaper/config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Grid_scale = 2.0
Grid_scale = $GRID_SCALE
Grid_perfil = 90.0
XYZR_FileName = /Extra/5pti.xyzr
XYZR_FileName = $XYZR_PATH
Build_epsilon_maps = false
Build_status_map = false
Save_Mesh_MSMS_Format = true
Expand All @@ -11,7 +11,7 @@ Skin_Surface_Parameter = 0.45
Cavity_Detection_Filling = false
Conditional_Volume_Filling_Value = 11.4
Keep_Water_Shaped_Cavities = false
Probe_Radius = 1.4
Probe_Radius = $PROBE_RADIUS
Accurate_Triangulation = true
Triangulation = true
Check_duplicated_vertices = true
Expand Down
29 changes: 12 additions & 17 deletions xppbe/Mesh/Mesh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,15 @@ def generate_nanoshaper_mesh(
if not os.path.exists(nanoshaper_temp_dir):
os.makedirs(nanoshaper_temp_dir)

# Execute NanoShaper
config_template_file = open(nanoshaper_dir + "config", "r")
config_file = open(nanoshaper_temp_dir + "surfaceConfiguration.prm", "w")
for line in config_template_file:
if "XYZR_FileName" in line:
line = "XYZR_FileName = " + mesh_xyzr_path + " \n"
elif "Grid_scale" in line:
line = "Grid_scale = {:04.1f} \n".format(density_to_nanoshaper_grid_scale_conversion(density))
elif "Probe_Radius" in line:
line = "Probe_Radius = {:03.1f} \n".format(probe_radius)

config_file.write(line)

config_file.close()
config_template_file.close()
with open(nanoshaper_dir + "config", 'r') as config_template_file:
text = config_template_file.read()

text = text.replace('$GRID_SCALE',str(float(density_to_nanoshaper_grid_scale_conversion(density))))
text = text.replace('$XYZR_PATH',mesh_xyzr_path)
text = text.replace('$PROBE_RADIUS',str(float(probe_radius)))

with open(nanoshaper_temp_dir + "surfaceConfiguration.prm", "w") as config_file:
config_file.write(text)

original_dir = os.getcwd()

Expand Down Expand Up @@ -105,11 +99,12 @@ def generate_nanoshaper_mesh(
if not save_mesh_build_files:
shutil.rmtree(nanoshaper_temp_dir)

os.chdir(original_dir)

except (OSError, FileNotFoundError):
print("The file doesn't exist or it wasn't created by NanoShaper")

finally:
os.chdir(original_dir)


def density_to_nanoshaper_grid_scale_conversion(mesh_density):
grid_scale = round(0.797 * (mesh_density**0.507), 2)
Expand Down

0 comments on commit 1d7c244

Please sign in to comment.