Open ggotthar opened 7 years ago
Hi ggothar, Sorry for the late answer, but I am on holidays. Thank you for your interest in the project and code donation. I have edited your post a little bit to make code viewing more clean. I am also attaching diff from your code, which will make it easier to view your changes. At the moment plugin is supporting Microsoft Windows via Cygwin compiled GROMACS: https://pymolwiki.org/index.php/GROMACS_Plugin#Windows.2FCygwin , but using Debian GROMACS directly sounds like interesting option. At the moment I feel that adding proper execution command to "gmxExes" list for WSL GROMACS is better option than modifying every "executeAndMonitorSubprocess" call. I will investigate on this issue further once I am back from the holidays. Again thank you for your input. Best regards, Tomek
Diff:
diff -Naur a/pymol_plugin_dynamics.py b/pymol_plugin_dynamics.py
--- a/pymol_plugin_dynamics.py 2017-06-27 13:14:09.716275000 +0200
+++ b/pymol_plugin_dynamics.py 2017-06-27 17:50:08.754529824 +0200
@@ -1,7 +1,7 @@
#!/usr/bin/env python2
#-*- coding: utf-8 -*-
-##This software (including its Debian packaging) is available to you under the terms of the GPL-3, see "/usr/share/common-licenses/GPL-3".
+##This software (including its Debian packaging) is available to you under the terms of the GPL-3, see "/usr/share/common-lic enses/GPL-3".
##Software is created and maintained by Laboratory of Biomolecular Systems Simulation at University of Gdansk.
##Contributors:
##- Tomasz Makarewicz (btchtm@ug.edu.pl)
@@ -22,6 +22,9 @@
import tkSimpleDialog, tkMessageBox, tkFileDialog, Pmw
##Import libraries from PyMOL specific work.
from pymol import cmd, stored, cgo
+from os.path import expanduser
+
+
##Check for ProDy
try:
@@ -54,7 +57,7 @@
self.version = gmxVersion
self.command = gmxExe
- # Track current directiry and switch to dynamics_dir before invoking gmx...
+ # Track current directory and switch to dynamics_dir before invoking gmx...
current_dir = os.getcwd()
os.chdir(dynamics_dir)
@@ -152,7 +155,7 @@
gmxStdoutFilePath = "test_gromacs.txt"
- cmd = self.command + " pdb2gmx -f test_gromacs.pdb -o test_gromacs.gro -p test_gromacs.top"
+ cmd =self.command + " pdb2gmx -f test_gromacs.pdb -o test_gromacs.gro -p test_gromacs.top"
executeSubprocess(cmd, gmxStdinFilePath, gmxStdoutFilePath)
lista_gromacs = readTextLines(gmxStdoutFilePath)
@@ -190,7 +193,7 @@
fo.write( "q")
fo.close()
- cmd = self.command+" make_ndx -f "+project_name+".pdb -o index.ndx"
+ cmd = self.command+" make_ndx -f "+project_name+".pdb -o index.ndx"
executeSubprocess(cmd, "gromacs_stdin.txt", "restraints.log")
index_list = readTextLines("restraints.log")
@@ -284,7 +287,7 @@
fo.close()
command = gromacs.command +" pdb2gmx -f " + project_name + ".pdb -o " + project_name + ".gro -p " + project_name + ".top " + hh
- executeAndMonitorSubprocess(command, 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
if os.path.isfile(file_path+".gro") == True:
status = ["ok", ""]
@@ -293,7 +296,7 @@
status_update(status)
command = gromacs.command+" pdb2gmx -ignh -f "+project_name+".pdb -o "+project_name+".gro -p "+project_name+".top "+hh
- executeAndMonitorSubprocess(command, 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
if os.path.isfile(file_path+".gro") == True and stop == 0:
status = ["ok", "Calculated topology using Force fields"]
@@ -312,7 +315,7 @@
pass
command = gromacs.command+" x2top -f "+project_name+".pdb -o "+project_name+".top"
- executeAndMonitorSubprocess(command, None, 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", None, 'log1.txt', 'log.txt')
if os.path.isfile(file_path+".top") == True and stop == 0:
status = ["ok", "Calculating structure using trjconv."]
@@ -326,7 +329,7 @@
fo.close()
command = gromacs.command+" trjconv -f "+project_name+".pdb -s "+project_name+".pdb -o "+project_name+".gro"
- executeAndMonitorSubprocess(command, 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
if os.path.isfile(file_path+".gro") == True and stop == 0:
status = ["ok", "Calculated structure using trjconv."]
@@ -349,7 +352,7 @@
status_update(status)
command = gromacs.command+" editconf -f "+project_name+".gro -o "+project_name+"1.gro -c "+box_type+distance+density
- executeAndMonitorSubprocess(command, None, 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", None, 'log1.txt', 'log.txt')
water_name = gromacs.water_list[self.water-1][1][4:8].lower()
print water_name
@@ -365,7 +368,7 @@
status = ["ok", "Adding Water Box"]
status_update(status)
- executeAndMonitorSubprocess(command, None, 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", None, 'log1.txt', 'log.txt')
if os.path.isfile(file_path+"1.gro") == True and stop == 0:
status = ["ok", "Water Box Added"]
@@ -388,7 +391,7 @@
command = gromacs.command+" grompp -f em -c "+project_name+"_solv.gro -o "+project_name+"_ions.tpr -p "+project_name+".top"
status_update(status)
- executeAndMonitorSubprocess(command, None, 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", None, 'log1.txt', 'log.txt')
fo = open("gromacs_stdin.txt", "w")
fo.write( "13")
@@ -398,7 +401,7 @@
status_update(status)
command = gromacs.command+" genion -s "+project_name+"_ions.tpr -o "+project_name+"_b4em.gro "+positive+negative+salt+neu+" -p "+project_name+".top"
- executeAndMonitorSubprocess(command, 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
if os.path.isfile(file_path+"_b4em.gro") == True and stop == 0:
status = ["ok", "Ions added successfully"]
@@ -425,10 +428,10 @@
status_update(status)
command = gromacs.command+" grompp -f em -c "+project_name+"_b4em -p "+project_name+" -o "+project_name+"_em"
- executeAndMonitorSubprocess(command, None, 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", None, 'log1.txt', 'log.txt')
command = gromacs.command+" mdrun -nice 4 -s "+project_name+"_em -o "+project_name+"_em -c "+project_name+"_b4pr -v"
- executeAndMonitorSubprocess(command, None, 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", None, 'log1.txt', 'log.txt')
if os.path.isfile(file_path+"_em.tpr") == True and stop == 0:
status = ["ok", "Energy Minimized"]
@@ -449,10 +452,10 @@
status_update(status)
command = gromacs.command+" grompp -f pr -c "+project_name+"_b4pr -r "+project_name+"_b4pr -p "+project_name+" -o "+project_name+"_pr"
- executeAndMonitorSubprocess(command, None, 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", None, 'log1.txt', 'log.txt')
command = gromacs.command+" mdrun -nice 4 -s "+project_name+"_pr -o "+project_name+"_pr -c "+project_name+"_b4md -v"
- executeAndMonitorSubprocess(command, None, 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", None, 'log1.txt', 'log.txt')
if os.path.isfile(file_path+"_pr.tpr") == True and stop == 0:
status = ["ok", "Position Restrained MD finished"]
@@ -475,7 +478,7 @@
status_update(status)
command = gromacs.command+" genrestr -f "+project_name+".pdb -o posre_2.itp -n index_dynamics.ndx"
- executeAndMonitorSubprocess(command, 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
if os.path.isfile("posre_2.itp") == True and stop == 0:
status = ["ok", "Added Restraints"]
@@ -507,10 +510,10 @@
status_update(status)
command = gromacs.command+" grompp -f md -c "+project_name+"_b4md -p "+project_name+" -o "+project_name+"_md"
- executeAndMonitorSubprocess(command, None, 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", None, 'log1.txt', 'log.txt')
command = gromacs.command+" mdrun -nice 4 -s "+project_name+"_md -o "+project_name+"_md -c "+project_name+"_after_md -v"
- executeAndMonitorSubprocess(command, None, 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", None, 'log1.txt', 'log.txt')
if os.path.isfile(file_path+"_md.tpr") == True and stop == 0:
status = ["ok", "Molecular Dynamics Simulation finished"]
@@ -535,7 +538,7 @@
status_update(status)
command = gromacs.command+" trjconv -f "+project_name+"_md.trr -s "+project_name+"_md.tpr -o "+project_name+"_multimodel.pdb"
- executeAndMonitorSubprocess(command, 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
+ executeAndMonitorSubprocess("bash -lic '" + command + "'", 'gromacs_stdin.txt', 'log1.txt', 'log.txt')
if os.path.isfile(file_path+"_multimodel.pdb") == True and stop == 0:
status = ["ok", "Finished!"]
@@ -910,7 +913,7 @@
project_name = "nothing"
- homeDir = os.getenv("HOME")
+ homeDir = expanduser("~")
gmxHomeDirPath = os.path.abspath(homeDir)
dynamics_dir = os.path.join(gmxHomeDirPath, '.dynamics', '')
@@ -937,7 +940,7 @@
print "Running command: " + command + "; STDIN: " + stdinMsg + "; STDOUT: " + stdoutMsg
- returnCode = subprocess.call(command, stdin=stdinFile, stdout=stdoutFile, stderr=subprocess.STDOUT, shell=True)
+ returnCode = subprocess.call("bash -lic '" + command + " '", stdin=stdinFile, stdout=stdoutFile, stderr=subprocess.STDOUT, shell=True)
if stdinFilePath:
stdinFile.close()
@@ -972,7 +975,7 @@
print "Running command: " + command + "; STDIN: " + stdinMsg + "; STDOUT: " + stdoutMsg
- gmx = subprocess.Popen(command, stdin=stdinFile, stdout=stdoutFile, stderr=subprocess.STDOUT, shell=True)
+ gmx = subprocess.Popen("bash -lic '" + command + " '", stdin=stdinFile, stdout=stdoutFile, stderr=subprocess.STDOUT, shell=True)
while gmx.poll() is None:
if stop == 1:
gmx.kill()
@@ -1042,7 +1045,7 @@
error = ""
# Make sure HOME environment variable is defined before setting up directories...
- homeDir = os.getenv("HOME")
+ homeDir = expanduser("~")
if homeDir:
os.chdir(homeDir)
else:
@@ -2857,7 +2860,7 @@
##Text for "Help"
def help_option():
help_message = """This is the dynamics PyMOL Plugin.
-This software (including its Debian packaging) is available to you under the terms of the GPL-3, see "/usr/share/common-licenses/GPL-3".
+This software (including its Debian packaging) is available to you under the terms of the GPL-3, see "/usr/share/common-lic enses/GPL-3".
Software is created and maintained by Laboratory of Biomolecular Systems Simulation at University of Gdansk.
Contributors:
- Tomasz Makarewicz (btchtm@ug.edu.pl)
Hello,
The last Windows 10 creators update has enabled the possibility use bash / linux system on windows. I have probe the possibility to use your dynamics plugin on a windows compiled pymol and a debian WSL compiled gromacs. Interestingly, with only few adaption, I was able to install the plugin on the Windows Pymol. The first one was to adapt the file system checking for directory creation:
from os.path import expanduser
def setGromacsDynamicsAndProjectDirs(): global project_name, dynamics_dir, project_dir
Default folders are then created.
The second step is to allow the script to start executables through the WSL bash. To do this, a simple way is to call "bash -lic '" + command + " '" when the script start a command. With this, it's starting the command, but the parameters are not injected.
So, I was wondering if you have a good solution to pipe command and parameters for the job (result in stdin: is not a tty). I feel it should not be too complex but I don't have enough experience in coding to find a solution. If you have any idea, I would be very interested. Many thanks, All the best,
G.
Below is the modified plugin code.