Skip to content

Commit 80a298b

Browse files
committed
refactor(exampe): simplify & modularize Makefile for example
1 parent 3c7fa5b commit 80a298b

File tree

5 files changed

+228
-258
lines changed

5 files changed

+228
-258
lines changed
Lines changed: 15 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,23 @@
1-
IMAGE = ghcr.io/lbt-cnrs/biospring
2-
PDB2SPN = pdb2spn
3-
BIOSPRING = biospring
1+
BASE_MK := $(shell echo $(PWD) | sed -E 's|(.*example).*|\1/base.mk|')
42

5-
BS_DATA_DIR = /biospring/share/biospring/data
6-
FORCEFIELD_DIR = $(BS_DATA_DIR)/forcefield
7-
REDUCERULES_DIR = $(BS_DATA_DIR)/reducerules
3+
# Inclure base.mk si trouvé
4+
ifneq ($(wildcard $(BASE_MK)),)
5+
include $(BASE_MK)
6+
# $(info Included: $(BASE_MK))
7+
endif
88

9-
10-
# PDB2SPN INPUTS
11-
FF = $(FORCEFIELD_DIR)/amber.ff
12-
GRP = $(REDUCERULES_DIR)/amber.grp
9+
# RAW PDB INPUT
1310
RAW_PDB = ../model_in_membrane.pdb
1411

15-
# PDB2SPN OUTPUTS
16-
CDL = model.cdl
17-
PDB = model.pdb
18-
NC = model.nc # USED AS BIOSPRING INPUT
19-
20-
# BIOSPRING INPUT PARAMETERS
21-
MSP = param.msp
22-
23-
24-
# PDB2SPN TOOL
25-
# INPUT: model_in_membrane.pdb (1BXW.pdb positioned in the membrane)
26-
# OUTPUT:
27-
# - model.cdl: Readable NetCDF file of the structure, used to verify the
28-
# structure informations
29-
#
30-
# - model.nc: Binary NetCDF file of the structure, used as BIOSPRING input
31-
# and as input structure for visualization tools like UnityMol
32-
# (in "BioSpring" version of UnityMol - March 2025)
33-
#
34-
# - model.pdb: PDB file of the structure, used as input structure for
35-
# visualization tools (like UnityMol or VMD) and to determine the
36-
# insertion vector particle pair (see doc/MSP_Options.md)
37-
pdb2spn:
38-
@echo "Copy PDB input for Martinize"
39-
cp $(RAW_PDB) .
40-
@echo "Run pdb2spn"
41-
docker run --rm --init -v $(PWD):/data $(IMAGE) \
42-
$(PDB2SPN) -s model_in_membrane.pdb \
43-
-o ${CDL} ${NC} $(PDB) \
44-
--grp $(GRP) \
45-
--ff $(FF) \
46-
--cutoff 4.0 \
47-
--stiffness 30.0
48-
rm $(notdir $(RAW_PDB))
49-
50-
51-
clean:
52-
rm -f \#*#
53-
rm -f model.cdl model.nc model.pdb
54-
55-
pause:
56-
@read -p "Press enter to continue..." key
57-
58-
# Run the docker image in interactive mode if you need to run the tools manually
59-
interactive:
60-
docker run --rm -it -v $(PWD):/data $(IMAGE)
12+
# PDB2SPN INPUTS
13+
FF = $(BS_DATA_DIR)/forcefield/amber.ff
14+
GRP = $(BS_DATA_DIR)/reducerules/amber.grp
15+
CUTOFF = 5.0
16+
STIFFNESS = 30.0
6117

6218
# Prepare the input files for the simulation
6319
prep : pdb2spn
6420

65-
# Run the BioSpring simulation
66-
# NOTE: The option --sasa-classifier biospring is important to use IMPALA
67-
# to at least compute once the particles surface areas. Otherwire you'll
68-
# have a warning message like "!! WARNING: freesasa_classifier_radius:
69-
# radius not found fo res: ARG name: RBB"
70-
#
71-
# NOTE2: By launching biospring, all the parameters used are displayed in the
72-
# terminal. You can modify the parameters in the MSP file as you wish
73-
# and restart biospring or tune certain parameters from UnityMol during
74-
# an interactive simulation (for example IMPALA scale or Input Force, or
75-
# even viscosity).
76-
run :
77-
@echo "Run BioSpring"
78-
docker run --network host --rm --init -v $(PWD):/data $(IMAGE) \
79-
$(BIOSPRING) -s $(NC) \
80-
-c $(MSP) \
81-
--wait --port 3000 \
82-
--sasa-classifier biospring
21+
# ------------------------------------------------------------------------------
22+
# Usage: run the command make usage
23+
# ------------------------------------------------------------------------------
Lines changed: 15 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,23 @@
1-
IMAGE = ghcr.io/lbt-cnrs/biospring
2-
PDB2SPN = pdb2spn
3-
BIOSPRING = biospring
1+
BASE_MK := $(shell echo $(PWD) | sed -E 's|(.*example).*|\1/base.mk|')
42

5-
BS_DATA_DIR = /biospring/share/biospring/data
6-
FORCEFIELD_DIR = $(BS_DATA_DIR)/forcefield
7-
REDUCERULES_DIR = $(BS_DATA_DIR)/reducerules
3+
# Inclure base.mk si trouvé
4+
ifneq ($(wildcard $(BASE_MK)),)
5+
include $(BASE_MK)
6+
# $(info Included: $(BASE_MK))
7+
endif
88

9-
10-
# PDB2SPN INPUTS
11-
FF = $(FORCEFIELD_DIR)/CAallresBaaden.ff
12-
GRP = $(REDUCERULES_DIR)/CAallresBaaden.grp
9+
# RAW PDB INPUT
1310
RAW_PDB = ../model_in_membrane.pdb
1411

15-
# PDB2SPN OUTPUTS
16-
CDL = model.cdl
17-
PDB = model.pdb
18-
NC = model.nc # USED AS BIOSPRING INPUT
19-
20-
# BIOSPRING INPUT PARAMETERS
21-
MSP = param.msp
22-
23-
24-
# PDB2SPN TOOL
25-
# INPUT: model_in_membrane.pdb (1BXW.pdb positioned in the membrane)
26-
# OUTPUT:
27-
# - model.cdl: Readable NetCDF file of the structure, used to verify the
28-
# structure informations
29-
#
30-
# - model.nc: Binary NetCDF file of the structure, used as BIOSPRING input
31-
# and as input structure for visualization tools like UnityMol
32-
# (in "BioSpring" version of UnityMol - March 2025)
33-
#
34-
# - model.pdb: PDB file of the structure, used as input structure for
35-
# visualization tools (like UnityMol or VMD) and to determine the
36-
# insertion vector particle pair (see doc/MSP_Options.md)
37-
pdb2spn:
38-
@echo "Copy PDB input for Martinize"
39-
cp $(RAW_PDB) .
40-
@echo "Run pdb2spn"
41-
docker run --rm --init -v $(PWD):/data $(IMAGE) \
42-
$(PDB2SPN) -s model_in_membrane.pdb \
43-
-o ${CDL} ${NC} $(PDB) \
44-
--grp $(GRP) \
45-
--ff $(FF) \
46-
--cutoff 9.0 \
47-
--stiffness 30.0
48-
rm $(notdir $(RAW_PDB))
49-
50-
51-
clean:
52-
rm -f \#*#
53-
rm -f model.cdl model.nc model.pdb
54-
55-
pause:
56-
@read -p "Press enter to continue..." key
57-
58-
# Run the docker image in interactive mode if you need to run the tools manually
59-
interactive:
60-
docker run --rm -it -v $(PWD):/data $(IMAGE)
12+
# PDB2SPN INPUTS
13+
FF = $(BS_DATA_DIR)/forcefield/CAallresBaaden.ff
14+
GRP = $(BS_DATA_DIR)/reducerules/CAallresBaaden.grp
15+
CUTOFF = 9.0
16+
STIFFNESS = 30.0
6117

6218
# Prepare the input files for the simulation
6319
prep : pdb2spn
6420

65-
# Run the BioSpring simulation
66-
# NOTE: The option --sasa-classifier biospring is important to use IMPALA
67-
# to at least compute once the particles surface areas. Otherwire you'll
68-
# have a warning message like "!! WARNING: freesasa_classifier_radius:
69-
# radius not found fo res: ARG name: RBB"
70-
#
71-
# NOTE2: By launching biospring, all the parameters used are displayed in the
72-
# terminal. You can modify the parameters in the MSP file as you wish
73-
# and restart biospring or tune certain parameters from UnityMol during
74-
# an interactive simulation (for example IMPALA scale or Input Force, or
75-
# even viscosity).
76-
run :
77-
@echo "Run BioSpring"
78-
docker run --network host --rm --init -v $(PWD):/data $(IMAGE) \
79-
$(BIOSPRING) -s $(NC) \
80-
-c $(MSP) \
81-
--wait --port 3000 \
82-
--sasa-classifier biospring
21+
# ------------------------------------------------------------------------------
22+
# Usage: run the command make usage
23+
# ------------------------------------------------------------------------------
Lines changed: 15 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,23 @@
1-
RED = \033[0;31m
2-
GREEN = \033[0;32m
3-
YELLOW = \033[0;33m
4-
BLUE = \033[0;34m
5-
RESET = \033[0m
6-
# ---------------------------------------------------------------------
1+
BASE_MK := $(shell echo $(PWD) | sed -E 's|(.*example).*|\1/base.mk|')
72

8-
IMAGE = ghcr.io/lbt-cnrs/biospring
9-
PDB2SPN = pdb2spn
10-
BIOSPRING = biospring
11-
MARTINIZE = martinize2
3+
# Inclure base.mk si trouvé
4+
ifneq ($(wildcard $(BASE_MK)),)
5+
include $(BASE_MK)
6+
# $(info Included: $(BASE_MK))
7+
endif
128

13-
BS_DATA_DIR = /biospring/share/biospring/data
14-
FORCEFIELD_DIR = $(BS_DATA_DIR)/martini/forcefield
15-
REDUCERULES_DIR = $(BS_DATA_DIR)/martini/reducerules
16-
17-
# PDB2SPN INPUTS
18-
FF = $(FORCEFIELD_DIR)/martini_octanol.ff
19-
GRP = $(REDUCERULES_DIR)/martini.grp
9+
# RAW PDB INPUT
2010
RAW_PDB = ../model_in_membrane.pdb
2111

22-
# PDB2SPN OUTPUTS
23-
CDL = model.cdl
24-
PDB = model.pdb
25-
NC = model.nc # USED AS BIOSPRING INPUT
26-
27-
# BIOSPRING INPUT PARAMETERS
28-
MSP = param.msp
29-
30-
# MARTINIZE TOOL
31-
# INPUT: model_in_membrane.pdb (1BXW.pdb positioned in the membrane)
32-
# OUTPUT: pdb2spn_input_cg.pdb (PDB2SPN INPUT)
33-
martinize:
34-
@echo "Copy PDB input for Martinize"
35-
cp $(RAW_PDB) .
36-
@echo "Run Martinize"
37-
docker run --rm -v $(PWD):/data $(IMAGE) \
38-
$(MARTINIZE) -f model_in_membrane.pdb \
39-
-x pdb2spn_input_cg.pdb \
40-
-ff martini30b32 \
41-
-resid input \
42-
-ignh
43-
rm $(notdir $(RAW_PDB))
44-
45-
# PDB2SPN TOOL
46-
# INPUT: pdb2spn_input_cg.pdb (Martinize output, CG PDB file)
47-
# OUTPUT:
48-
# - model.cdl: Readable NetCDF file of the structure, used to verify the
49-
# structure informations
50-
#
51-
# - model.nc: Binary NetCDF file of the structure, used as BIOSPRING input
52-
# and as input structure for visualization tools like UnityMol
53-
# (in "BioSpring" version of UnityMol - March 2025)
54-
#
55-
# - model.pdb: PDB file of the structure, used as input structure for
56-
# visualization tools (like UnityMol or VMD) and to determine the
57-
# insertion vector particle pair (see doc/MSP_Options.md)
58-
pdb2spn:
59-
@echo "Run pdb2spn"
60-
docker run --rm --init -v $(PWD):/data $(IMAGE) \
61-
$(PDB2SPN) -s pdb2spn_input_cg.pdb \
62-
-o ${CDL} ${NC} $(PDB) \
63-
--ff $(FF) \
64-
--grp $(GRP) \
65-
--cutoff 5.0 \
66-
--stiffness 30.0
67-
68-
69-
clean:
70-
rm -f \#*#
71-
rm -f pdb2spn_input_cg.pdb
72-
rm -f model.cdl model.nc model.pdb
73-
74-
pause:
75-
@read -p "Press enter to continue..." key
76-
77-
# Run the docker image in interactive mode if you need to run the tools manually
78-
interactive:
79-
docker run --rm -it -v $(PWD):/data $(IMAGE)
12+
# PDB2SPN INPUTS
13+
FF = $(BS_DATA_DIR)/martini/forcefield/martini_octanol.ff
14+
GRP = $(BS_DATA_DIR)/martini/reducerules/martini.grp
15+
CUTOFF = 5.0
16+
STIFFNESS = 30.0
8017

8118
# Prepare the input files for the simulation
8219
prep : martinize pause pdb2spn
8320

84-
# Run the BioSpring simulation
85-
# NOTE: The option --sasa-classifier biospring is important to use IMPALA
86-
# to at least compute once the particles surface areas. Otherwire you'll
87-
# have a warning message like "!! WARNING: freesasa_classifier_radius:
88-
# radius not found fo res: ARG name: RBB"
89-
#
90-
# NOTE2: By launching biospring, all the parameters used are displayed in the
91-
# terminal. You can modify the parameters in the MSP file as you wish
92-
# and restart biospring or tune certain parameters from UnityMol during
93-
# an interactive simulation (for example IMPALA scale or Input Force, or
94-
# even viscosity).
95-
run :
96-
@echo "Run BioSpring"
97-
docker run --network host --rm --init -v $(PWD):/data $(IMAGE) \
98-
$(BIOSPRING) -s $(NC) \
99-
-c $(MSP) \
100-
--wait --port 3000 \
101-
--sasa-classifier biospring
102-
103-
expose_data:
104-
@echo "Host machine: $(GREEN)$(shell hostname)$(RESET)"
105-
@echo "On the client side, you can retrive the data with the following command:"
106-
@echo "\n $(GREEN)make get_data HOSTNAME=$(shell hostname)$(RESET)\n"
107-
@docker run --network host --rm --init -v $(PWD):/data $(IMAGE) python -m http.server 4000 --directory /data
108-
109-
get_data :
110-
@if [ -z "$(HOSTNAME)" ]; then \
111-
echo "$(RED)Usage: make get_data HOSTNAME=<hostname>$(RESET)"; \
112-
exit 1; \
113-
fi
114-
115-
@echo "$(GREEN)Retrieving data from http://$(HOSTNAME):4000/model.* ...$(RESET)"
116-
@wget -q -r -np -nH --accept-regex='model.*' http://$(HOSTNAME):4000/
117-
@rm index.html
118-
21+
# ------------------------------------------------------------------------------
22+
# Usage: run the command make usage
23+
# ------------------------------------------------------------------------------

example/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Usage:
2+
3+
## Step 1: Server side
4+
- `make prep`
5+
- `make expose_data`
6+
7+
## Step 2: Client side
8+
- `make get_data`
9+
10+
## Step 3: Server side
11+
- CTRL + C to stop the server exposing the data
12+
- `make run` / `make run_now`
13+
- Check the line in the shell and note the `HOSTNAME` and `PORT`:
14+
```bash
15+
MDDriver > Interactive MD bind to /[HOSTNAME]/[PORT]
16+
```
17+
18+
## Step 4: Client side
19+
- Open `model.nc` or `model.pdb` in VMD or UnityMol
20+
- Connect to the server using the `HOSTNAME` and `PORT`
21+
22+
## Step 5: Server side
23+
- CTRL + C to stop the server running the simulation
24+
- `make clean`

0 commit comments

Comments
 (0)