Skip to content

Commit

Permalink
Allow custom Python executables
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed May 8, 2024
1 parent c69038e commit fa4d652
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 40 deletions.
40 changes: 21 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,38 @@
.PHONY: visual
.PHONY: clean

PYTHON = python3

docs:
mkdir -p ./documentation
pdoc ./pyMBE.py -o ./documentation --docformat google
PDOC_ALLOW_EXEC=0 ${PYTHON} -m pdoc ./pyMBE.py -o ./documentation --docformat google

tests:
python3 testsuite/lj_tests.py
python3 testsuite/set_particle_acidity_test.py
python3 testsuite/bond_tests.py
python3 testsuite/generate_perpendicular_vectors_test.py
python3 testsuite/create_molecule_position_test.py
python3 testsuite/seed_test.py
python3 testsuite/read-write-df_test.py
python3 testsuite/parameter_test.py
python3 testsuite/henderson_hasselbalch_tests.py
python3 testsuite/cph_ideal_tests.py
python3 testsuite/grxmc_ideal_tests.py
python3 testsuite/peptide_tests.py
python3 testsuite/gcmc_tests.py
python3 testsuite/weak_polyelectrolyte_dialysis_test.py
python3 testsuite/globular_protein_tests.py
${PYTHON} testsuite/lj_tests.py
${PYTHON} testsuite/set_particle_acidity_test.py
${PYTHON} testsuite/bond_tests.py
${PYTHON} testsuite/generate_perpendicular_vectors_test.py
${PYTHON} testsuite/create_molecule_position_test.py
${PYTHON} testsuite/seed_test.py
${PYTHON} testsuite/read-write-df_test.py
${PYTHON} testsuite/parameter_test.py
${PYTHON} testsuite/henderson_hasselbalch_tests.py
${PYTHON} testsuite/cph_ideal_tests.py
${PYTHON} testsuite/grxmc_ideal_tests.py
${PYTHON} testsuite/peptide_tests.py
${PYTHON} testsuite/gcmc_tests.py
${PYTHON} testsuite/weak_polyelectrolyte_dialysis_test.py
${PYTHON} testsuite/globular_protein_tests.py

sample:
python3 samples/peptide.py
${PYTHON} samples/peptide.py

visual:
python3 visualization/vmd-traj.py
${PYTHON} visualization/vmd-traj.py
vmd -e visualization.tcl

tutorial:
jupyter-lab tutorials/pyMBE_tutorial.ipynb

pylint:
pylint pyMBE.py lib/ testsuite/ samples/ maintainer/ visualization/
${PYTHON} -m pylint pyMBE.py lib/ testsuite/ samples/ maintainer/ visualization/
12 changes: 7 additions & 5 deletions samples/Beyer2024/create_paper_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Import pyMBE and other libraries
import pyMBE
from lib import analysis
import os
import os
import sys
import numpy as np
import argparse
import subprocess
Expand Down Expand Up @@ -51,7 +52,7 @@
raise RuntimeError()
pH_range = np.linspace(2, 12, num=21)
for pH in pH_range:
run_command=["python3", script_path, "--sequence", sequence, "--pH", str(pH), "--mode", mode]
run_command=[sys.executable, script_path, "--sequence", sequence, "--pH", str(pH), "--mode", mode]
print(subprocess.list2cmdline(run_command))
subprocess.check_output(run_command)

Expand All @@ -64,21 +65,22 @@

script_path=pmb.get_resource("samples/Beyer2024/globular_protein.py")
pH_range = np.linspace(2, 7, num=11)
run_command_common=[sys.executable, script_path, "--pdb", protein_pdb, "--path_to_cg", path_to_cg, "--mode", mode, "--no_verbose"]

if fig_label == "8a":
protein_pdb = "1f6s"
path_to_cg = f"parameters/globular_proteins/{protein_pdb}.vtf"
for pH in pH_range:

run_command=["python3", script_path, "--pdb", protein_pdb, "--pH", str(pH), "--path_to_cg", path_to_cg, "--mode", mode, "--no_verbose", "--metal_ion_name", "Ca", "--metal_ion_charge", str(2)]
run_command=run_command_common + ["--pH", str(pH), "--metal_ion_name", "Ca", "--metal_ion_charge", str(2)]
print(subprocess.list2cmdline(run_command))
subprocess.check_output(run_command)

elif fig_label == "8b":
protein_pdb = "1beb"
path_to_cg = f"parameters/globular_proteins/{protein_pdb}.vtf"
for pH in pH_range:
run_command=["python3", script_path, "--pdb", protein_pdb, "--pH", str(pH), "--path_to_cg", path_to_cg, "--mode", mode, "--no_verbose"]
run_command=run_command_common + ["--pH", str(pH)]
print(subprocess.list2cmdline(run_command))
subprocess.check_output(run_command)
else:
Expand All @@ -91,7 +93,7 @@
pH_range = np.linspace(1, 13, num=13)
c_salt_res = 0.01 * pmb.units.mol/pmb.units.L
for pH in pH_range:
run_command=["python3", script_path, "--c_salt_res", str(0.01), "--c_mon_sys", str(0.435), "--pH_res", str(pH), "--pKa_value", str(4.0), "--mode", mode]
run_command=[sys.executable, script_path, "--c_salt_res", str(0.01), "--c_mon_sys", str(0.435), "--pH_res", str(pH), "--pKa_value", str(4.0), "--mode", mode]
print(subprocess.list2cmdline(run_command))
subprocess.check_output(run_command)

Expand Down
3 changes: 2 additions & 1 deletion testsuite/cph_ideal_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Import pyMBE and other libraries
import pyMBE
import sys
import subprocess
import numpy as np
import pandas as pd
Expand All @@ -13,7 +14,7 @@
print("*** Constant pH (cpH) implementation tests ***\n")
print("*** Test that our implementation of the cpH method reproduces the Henderson Hasselbalch equation for an ideal polyampholyte ***\n")

run_command = ["python3", script_path, "--test"]
run_command = [sys.executable, script_path, "--test"]
subprocess.check_output(run_command)

data = pd.read_csv(data_path)
Expand Down
13 changes: 7 additions & 6 deletions testsuite/gcmc_tests.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# Import pyMBE and other libraries
import pyMBE
from lib import analysis
import sys
import tempfile
import subprocess
import pyMBE
from lib import analysis
import numpy as np

# Template of the test

def gcmc_test(mode, script_path):
def gcmc_test(script_path, mode):
if mode == "ideal":
print("*** Running test for GCMC of salt solution (ideal). ***")
elif mode == "interacting":
print("*** Running test for GCMC of salt solution (interacting). ***")
with tempfile.TemporaryDirectory() as time_series_path:
for c_salt_res in salt_concentrations:
print(f"c_salt_res = {c_salt_res}")
run_command=["python3", script_path, "--c_salt_res", str(c_salt_res), "--output", time_series_path, "--mode", mode, "--no_verbose"]
run_command=[sys.executable, script_path, "--c_salt_res", str(c_salt_res), "--output", time_series_path, "--mode", mode, "--no_verbose"]
print(subprocess.list2cmdline(run_command))
subprocess.check_output(run_command)
# Analyze all time series
Expand All @@ -37,7 +38,7 @@ def gcmc_test(mode, script_path):
atol=0.0 # absolute tolerance

# Ideal test
gcmc_test("ideal", script_path)
gcmc_test(script_path, "ideal")

# Interacting test
gcmc_test("interacting", script_path)
gcmc_test(script_path, "interacting")
7 changes: 4 additions & 3 deletions testsuite/globular_protein_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Import pyMBE and other libraries
import pyMBE
from lib import analysis
import sys
import tempfile
import subprocess
import numpy as np
Expand All @@ -22,13 +23,13 @@ def run_protein_test(script_path, test_pH_values, protein_pdb, rtol, atol,mode="

print(f"Running tests for {protein_pdb}")
with tempfile.TemporaryDirectory() as time_series_path:

for pH in test_pH_values:
print(f"pH = {pH}")
run_command=["python3", script_path, "--pdb", protein_pdb, "--pH", str(pH), "--path_to_cg", f"parameters/globular_proteins/{protein_pdb}.vtf"]
run_command=[sys.executable, script_path, "--pdb", protein_pdb, "--pH", str(pH),
"--path_to_cg", f"parameters/globular_proteins/{protein_pdb}.vtf",
"--mode", "test", "--no_verbose", "--output", time_series_path]
if protein_pdb == '1f6s':
run_command+=["--metal_ion_name","Ca", "--metal_ion_charge", "2"]
run_command+=["--mode", "test", "--no_verbose", "--output", time_series_path]
print(subprocess.list2cmdline(run_command))
subprocess.check_output(run_command)
# Analyze all time series
Expand Down
5 changes: 3 additions & 2 deletions testsuite/grxmc_ideal_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Import pyMBE and other libraries
import pyMBE
import sys
import subprocess
import numpy as np
import pandas as pd
Expand All @@ -12,7 +13,7 @@
print("*** Grand reaction (G-RxMC) implementation tests ***\n")
print("*** Test that our implementation of the original G-RxMC method reproduces the Henderson-Hasselbalch equation corrected with the Donnan potential (HH+Don) for an ideal mixture of peptides ***")

run_command = ["python3", script_path, "--mode", "standard", "--test"]
run_command = [sys.executable, script_path, "--mode", "standard", "--test"]
subprocess.check_output(run_command)

data = pd.read_csv(data_path)
Expand All @@ -26,7 +27,7 @@

print("*** Test that our implementation of the G-RxMC method with unified ion types reproduces HH+Don for an ideal mixture of peptides ***")

run_command = ["python3", script_path, "--mode", "unified", "--test"]
run_command = [sys.executable, script_path, "--mode", "unified", "--test"]
subprocess.check_output(run_command)

data = pd.read_csv(data_path)
Expand Down
7 changes: 4 additions & 3 deletions testsuite/peptide_tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Import pyMBE and other libraries
import pyMBE
from lib import analysis
import sys
import tempfile
import subprocess
import pyMBE
from lib import analysis
import numpy as np
import pandas as pd

Expand All @@ -24,7 +25,7 @@ def run_peptide_test(script_path,test_pH_values,sequence,rtol,atol,mode="test"):
with tempfile.TemporaryDirectory() as time_series_path:
for pH in test_pH_values:
print(f"pH = {pH}")
run_command=["python3", script_path, "--sequence", sequence, "--pH", str(pH), "--mode", "test", "--no_verbose", "--output", time_series_path]
run_command=[sys.executable, script_path, "--sequence", sequence, "--pH", str(pH), "--mode", "test", "--no_verbose", "--output", time_series_path]
print(subprocess.list2cmdline(run_command))
subprocess.check_output(run_command)
# Analyze all time series
Expand Down
3 changes: 2 additions & 1 deletion testsuite/weak_polyelectrolyte_dialysis_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Import pyMBE and other libraries
import pyMBE
from lib import analysis
import sys
import tempfile
import subprocess
import numpy as np
Expand All @@ -21,7 +22,7 @@
with tempfile.TemporaryDirectory() as time_series_path:
for pH in test_pH_values:
print(f"pH = {pH}")
run_command=["python3", script_path, "--c_salt_res", str(c_salt_res), "--c_mon_sys", str(c_mon_sys), "--pKa_value", str(pKa_value), "--pH_res", str(pH), "--mode", "test", "--output", time_series_path, "--no_verbose"]
run_command=[sys.executable, script_path, "--c_salt_res", str(c_salt_res), "--c_mon_sys", str(c_mon_sys), "--pKa_value", str(pKa_value), "--pH_res", str(pH), "--mode", "test", "--output", time_series_path, "--no_verbose"]
print(subprocess.list2cmdline(run_command))
subprocess.check_output(run_command)
# Analyze all time series
Expand Down

0 comments on commit fa4d652

Please sign in to comment.