Skip to content

Commit

Permalink
BioBB WF protein MD analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
gbayarri committed Jan 17, 2025
1 parent d8db266 commit 40f2541
Show file tree
Hide file tree
Showing 19 changed files with 8,409 additions and 34 deletions.
4 changes: 2 additions & 2 deletions biobb_wf_pmx_tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ The tutorial calculates the **free energy difference** in the folded state of a
## Copyright & Licensing
This software has been developed in the [MMB group](http://mmb.irbbarcelona.org) at the [BSC](http://www.bsc.es/) & [IRB](https://www.irbbarcelona.org/) for the [European BioExcel](http://bioexcel.eu/), funded by the European Commission (EU H2020 [823830](http://cordis.europa.eu/projects/823830), EU H2020 [675728](http://cordis.europa.eu/projects/675728)).

* (c) 2015-2024 [Barcelona Supercomputing Center](https://www.bsc.es/)
* (c) 2015-2024 [Institute for Research in Biomedicine](https://www.irbbarcelona.org/)
* (c) 2015-2025 [Barcelona Supercomputing Center](https://www.bsc.es/)
* (c) 2015-2025 [Institute for Research in Biomedicine](https://www.irbbarcelona.org/)

Licensed under the
[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0), see the file LICENSE for details.
Expand Down
21 changes: 10 additions & 11 deletions biobb_wf_pmx_tutorial/python/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@
import argparse
import os
import zipfile

# biobb common modules
from biobb_common.configuration import settings
from biobb_common.tools import file_utils as fu

# biobb pmx modules
from biobb_pmx.pmxbiobb.pmxmutate import pmxmutate
from biobb_pmx.pmxbiobb.pmxgentop import pmxgentop
from biobb_pmx.pmxbiobb.pmxanalyse import pmxanalyse

# biobb md modules
from biobb_gromacs.gromacs.pdb2gmx import pdb2gmx
from biobb_gromacs.gromacs.make_ndx import make_ndx
from biobb_gromacs.gromacs.grompp import grompp
from biobb_gromacs.gromacs.mdrun import mdrun

# biobb analysis module
from biobb_analysis.gromacs.gmx_trjconv_str_ens import gmx_trjconv_str_ens


Expand All @@ -33,14 +25,15 @@ def main(config, system=None):
dhdl_paths_listA = []
dhdl_paths_listB = []

for ensemble, mutation in conf.properties['mutations'].items():
for ensemble, mutation in conf.properties['global_properties']['mutations'].items():
ensemble_prop = conf.get_prop_dic(prefix=ensemble, global_log=global_log)
ensemble_paths = conf.get_paths_dic(prefix=ensemble)

# Create and launch bb
global_log.info(ensemble+" Step 0: gmx trjconv: Extract snapshots from equilibrium trajectories")
ensemble_paths['step0_trjconv']['input_traj_path'] = conf.properties['input_trajs'][ensemble]['input_traj_path']
ensemble_paths['step0_trjconv']['input_top_path'] = conf.properties['input_trajs'][ensemble]['input_tpr_path']
ensemble_paths['step0_trjconv']['input_traj_path'] = conf.properties['global_properties']['input_trajs'][ensemble]['input_traj_path']
ensemble_paths['step0_trjconv']['input_top_path'] = conf.properties['global_properties']['input_trajs'][ensemble]['input_tpr_path']

gmx_trjconv_str_ens(**ensemble_paths["step0_trjconv"], properties=ensemble_prop["step0_trjconv"])

with zipfile.ZipFile(ensemble_paths["step0_trjconv"]["output_str_ens_path"], 'r') as zip_f:
Expand All @@ -56,18 +49,21 @@ def main(config, system=None):
global_log.info("Step 1: pmx mutate: Generate Hybrid Structure")
paths['step1_pmx_mutate']['input_structure_path'] = pdb_path
prop['step1_pmx_mutate']['mutation_list'] = mutation
prop['step1_pmx_mutate']['gmx_lib'] = os.getenv('CONDA_PREFIX') + '/lib/python3.10/site-packages/pmx/data/mutff'
pmxmutate(**paths["step1_pmx_mutate"], properties=prop["step1_pmx_mutate"])

# Step 2: gmx pdb2gmx: Generate Topology
# From pmx tutorial:
# gmx pdb2gmx -f mut.pdb -ff amber99sb-star-ildn-mut -water tip3p -o pdb2gmx.pdb
global_log.info("Step 2: gmx pdb2gmx: Generate Topology")
prop['step2_gmx_pdb2gmx']['gmx_lib'] = os.getenv('CONDA_PREFIX') + '/lib/python3.10/site-packages/pmx/data/mutff'
pdb2gmx(**paths["step2_gmx_pdb2gmx"], properties=prop["step2_gmx_pdb2gmx"])

# Step 3: pmx gentop: Generate Hybrid Topology
# From pmx tutorial:
# python generate_hybrid_topology.py -itp topol_Protein.itp -o topol_Protein.itp -ff amber99sb-star-ildn-mut
global_log.info("Step 3: pmx gentop: Generate Hybrid Topology")
prop['step3_pmx_gentop']['gmx_lib'] = os.getenv('CONDA_PREFIX') + '/lib/python3.10/site-packages/pmx/data/mutff'
pmxgentop(**paths["step3_pmx_gentop"], properties=prop["step3_pmx_gentop"])

# Step 4: gmx make_ndx: Generate Gromacs Index File to select atoms to freeze
Expand All @@ -88,6 +84,7 @@ def main(config, system=None):
# From pmx tutorial:
# gmx grompp -c pdb2gmx.pdb -p topol.top -f ../../mdp/em_FREEZE.mdp -o em.tpr -n ../index.ndx
global_log.info("Step 5: gmx grompp: Creating portable binary run file for energy minimization")
prop['step5_gmx_grompp']['gmx_lib'] = os.getenv('CONDA_PREFIX') + '/lib/python3.10/site-packages/pmx/data/mutff'
grompp(**paths["step5_gmx_grompp"], properties=prop["step5_gmx_grompp"])

# Step 6: gmx mdrun: Running energy minimization
Expand All @@ -100,6 +97,7 @@ def main(config, system=None):
# From pmx tutorial:
# gmx grompp -c emout.gro -p topol.top -f ../../mdp/eq_20ps.mdp -o eq_20ps.tpr -maxwarn 1
global_log.info(ensemble+" Step 7: gmx grompp: Creating portable binary run file for system equilibration")
prop['step7_gmx_grompp']['gmx_lib'] = os.getenv('CONDA_PREFIX') + '/lib/python3.10/site-packages/pmx/data/mutff'
grompp(**paths["step7_gmx_grompp"], properties=prop["step7_gmx_grompp"])

# Step 8: gmx mdrun: Running system equilibration
Expand All @@ -112,6 +110,7 @@ def main(config, system=None):
# From pmx tutorial:
# gmx grompp -c eqout.gro -p topol.top -f ../../mdp/ti.mdp -o ti.tpr -maxwarn 1
global_log.info(ensemble+" Step 9: Creating portable binary run file for thermodynamic integration (ti)")
prop['step9_gmx_grompp']['gmx_lib'] = os.getenv('CONDA_PREFIX') + '/lib/python3.10/site-packages/pmx/data/mutff'
grompp(**paths["step9_gmx_grompp"], properties=prop["step9_gmx_grompp"])

# Step 10: gmx mdrun: Running thermodynamic integration
Expand Down
26 changes: 12 additions & 14 deletions biobb_wf_pmx_tutorial/python/workflow.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
global_properties:
working_dir_path: biobb_wf_pmx_tutorial
can_write_console_log: False

mutations:
stateA: 10Ala
stateB: 10Ile

input_trajs:
stateA:
input_tpr_path: file:pmx_tutorial/stateA.tpr
input_traj_path: file:pmx_tutorial/stateA_1ns.xtc
stateB:
input_tpr_path: file:pmx_tutorial/stateB.tpr
input_traj_path: file:pmx_tutorial/stateB_1ns.xtc
mutations:
stateA: 10Ala
stateB: 10Ile
input_trajs:
stateA:
input_tpr_path: pmx_tutorial/stateA.tpr
input_traj_path: pmx_tutorial/stateA_1ns.xtc
stateB:
input_tpr_path: pmx_tutorial/stateB.tpr
input_traj_path: pmx_tutorial/stateB_1ns.xtc

step0_trjconv:
paths:
Expand Down Expand Up @@ -137,8 +135,8 @@ step10_gmx_mdrun:

step11_pmx_analyse:
paths:
input_a_xvg_zip_path: dhdlA.zip
input_b_xvg_zip_path: dhdlB.zip
input_a_xvg_zip_path: file:dhdlA.zip
input_b_xvg_zip_path: file:dhdlB.zip
output_result_path: pmx.txt
output_work_plot_path: pmx.plots.png
properties:
Expand Down
4 changes: 2 additions & 2 deletions biobb_wf_protein_md_analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ This workflow computes a set of Quality Control (QC) analyses on top of an uploa
## Copyright & Licensing
This software has been developed in the [MMB group](http://mmb.irbbarcelona.org) at the [BSC](http://www.bsc.es/) & [IRB](https://www.irbbarcelona.org/) for the [European BioExcel](http://bioexcel.eu/), funded by the European Commission (EU H2020 [823830](http://cordis.europa.eu/projects/823830), EU H2020 [675728](http://cordis.europa.eu/projects/675728)).

* (c) 2015-2024 [Barcelona Supercomputing Center](https://www.bsc.es/)
* (c) 2015-2024 [Institute for Research in Biomedicine](https://www.irbbarcelona.org/)
* (c) 2015-2025 [Barcelona Supercomputing Center](https://www.bsc.es/)
* (c) 2015-2025 [Institute for Research in Biomedicine](https://www.irbbarcelona.org/)

Licensed under the
[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0), see the file LICENSE for details.
Expand Down
13 changes: 8 additions & 5 deletions biobb_wf_protein_md_analysis/python/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import argparse
import csv
import json
import shutil
from Bio.PDB.PDBParser import PDBParser
from Bio.PDB.PDBIO import PDBIO
from biobb_common.configuration import settings
Expand All @@ -16,6 +15,7 @@
from biobb_analysis.ambertools.cpptraj_convert import cpptraj_convert
from biobb_analysis.gromacs.gmx_cluster import gmx_cluster


def getBfactorsList(input):
file = open(input)
csv_reader = csv.reader(file)
Expand All @@ -31,6 +31,7 @@ def getBfactorsList(input):

return bfactors


def saveBfactor(input, output, bfactors):
# load input into BioPython structure
structure = PDBParser(QUIET=True).get_structure('structure', input)
Expand All @@ -43,9 +44,10 @@ def saveBfactor(input, output, bfactors):

# save the structure
io = PDBIO()
io.set_structure(structure)
io.set_structure(structure)
io.save(output)


def saveClusters(input, output):
file = open(input)
csv_reader = csv.reader(file)
Expand All @@ -54,9 +56,9 @@ def saveClusters(input, output):
start = False
for row in csv_reader:

if start:
if start:
col = row[0].split('|')
if len(col[0].strip()):
if len(col[0].strip()):
clusters.append({
'cluster': col[0].strip(),
'population': col[1].strip().split()[0]
Expand All @@ -68,6 +70,7 @@ def saveClusters(input, output):
with open(output, 'w') as outfile:
json.dump(clusters, outfile)


def main(config, system=None):
start_time = time.time()
conf = settings.ConfReader(config, system)
Expand Down Expand Up @@ -117,10 +120,10 @@ def main(config, system=None):
global_log.info('Elapsed time: %.1f minutes' % (elapsed_time/60))
global_log.info('')


if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Protein MD Analysis pipeline using BioExcel Building Blocks")
parser.add_argument('--config', required=True)
parser.add_argument('--system', required=False)
args = parser.parse_args()
main(args.config, args.system)

Loading

0 comments on commit 40f2541

Please sign in to comment.