Skip to content

Commit

Permalink
Update tma_py3.py
Browse files Browse the repository at this point in the history
  • Loading branch information
avimanyu786 committed Jan 30, 2021
1 parent 12d6989 commit b5f7468
Showing 1 changed file with 86 additions and 34 deletions.
120 changes: 86 additions & 34 deletions tma_py3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# TrajectoryMergeAssist v2.1
# A python3 based GUI tool that helps in merging two trajectories on Desmond MD

Expand Down Expand Up @@ -32,25 +34,49 @@ def __init__(self, parent):

def initialize(self):
self.grid()
button = tkinter.Button(self, text='Browse Desmond "-out.cms" file', command=self.AskDesmondInputFile)
button = tkinter.Button(
self,
text='Browse Desmond "-out.cms" file',
command=self.AskDesmondInputFile,
)
button.grid(column=0, row=1)

button2 = tkinter.Button(self, text='Choose Desmond Trajectory 1', command=self.AskDesmondTrajectory1)
button2 = tkinter.Button(
self, text="Choose Desmond Trajectory 1", command=self.AskDesmondTrajectory1
)
button2.grid(column=0, row=2)

button3 = tkinter.Button(self, text='Choose Desmond Trajectory 2', command=self.AskDesmondTrajectory2)
button3 = tkinter.Button(
self, text="Choose Desmond Trajectory 2", command=self.AskDesmondTrajectory2
)
button3.grid(column=0, row=3)

button4 = tkinter.Button(self, text='Merge Desmond Trajectories', command=self.MergeDesmondTrajectories)
button4 = tkinter.Button(
self,
text="Merge Desmond Trajectories",
command=self.MergeDesmondTrajectories,
)
button4.grid(column=0, row=4)

button5 = tkinter.Button(self, text='Browse GROMACS Trajectory 1 ".xtc" file', command=self.AskGROMACSTrajectory1)
button5 = tkinter.Button(
self,
text='Browse GROMACS Trajectory 1 ".xtc" file',
command=self.AskGROMACSTrajectory1,
)
button5.grid(column=1, row=1)

button6 = tkinter.Button(self, text='Browse GROMACS Trajectory 1 ".xtc" file', command=self.AskGROMACSTrajectory2)
button6 = tkinter.Button(
self,
text='Browse GROMACS Trajectory 1 ".xtc" file',
command=self.AskGROMACSTrajectory2,
)
button6.grid(column=1, row=2)

button7 = tkinter.Button(self, text='Merge GROMACS Trajectories', command=self.MergeGROMACSTrajectories)
button7 = tkinter.Button(
self,
text="Merge GROMACS Trajectories",
command=self.MergeGROMACSTrajectories,
)
button7.grid(column=1, row=3)

self.grid_columnconfigure(0, weight=1)
Expand All @@ -61,19 +87,25 @@ def initialize(self):
def AskDesmondInputFile(self):

global cms
cms = tkinter.filedialog.askopenfilename(parent=root, initialdir="pwd", title='Choose Desmond "-out.cms" file')
cms = tkinter.filedialog.askopenfilename(
parent=root, initialdir="pwd", title='Choose Desmond "-out.cms" file'
)
if len(cms) > 0:
print("%s selected" % cms)

def AskDesmondTrajectory1(self):
global in1_trj
in1_trj = tkinter.filedialog.askdirectory(parent=root, initialdir="pwd", title='Please Select Desmond Trajectory 1')
in1_trj = tkinter.filedialog.askdirectory(
parent=root, initialdir="pwd", title="Please Select Desmond Trajectory 1"
)
if len(in1_trj) > 0:
print("You chose %s" % in1_trj)

def AskDesmondTrajectory2(self):
global in2_trj
in2_trj = tkinter.filedialog.askdirectory(parent=root, initialdir="pwd", title='Please Select Desmond Trajectory 2')
in2_trj = tkinter.filedialog.askdirectory(
parent=root, initialdir="pwd", title="Please Select Desmond Trajectory 2"
)
if len(in2_trj) > 0:
print("You chose %s" % in2_trj)

Expand All @@ -84,7 +116,9 @@ def MergeDesmondTrajectories(self):
os.system("echo You are using Desmond MD via $SCHRODINGER")
print("\t")
else:
print("Desmond MD not installed or $SCHRODINGER path not set correctly. Exiting...")
print(
"Desmond MD not installed or $SCHRODINGER path not set correctly. Exiting..."
)
exit()

print("-------------------------------------------------------------")
Expand All @@ -94,17 +128,25 @@ def MergeDesmondTrajectories(self):
# For Desmond Version >= 2018.1 https://www.schrodinger.com/kb/282357

if os.path.exists(os.path.expandvars("$SCHRODINGER/internal/bin/trj_merge.py")):
os.system("$SCHRODINGER/run trj_merge.py %s %s %s -o NewMergedTrajectory" % (
cms, in1_trj, in2_trj))
os.system(
"$SCHRODINGER/run trj_merge.py %s %s %s -o NewMergedTrajectory"
% (cms, in1_trj, in2_trj)
)
os.system("mv NewMergedTrajectory.cms NewMergedTrajectory-out.cms")

else: # For Desmond Version < 2018.1 https://www.schrodinger.com/kb/90
os.system("$SCHRODINGER/run -FROM desmond manipulate_trj.py %s NewMergedTrajectory %s %s" % (
cms, in1_trj, in2_trj))

else:

# For Desmond Version < 2018.1 https://www.schrodinger.com/kb/90

os.system(
"$SCHRODINGER/run -FROM desmond manipulate_trj.py %s NewMergedTrajectory %s %s"
% (cms, in1_trj, in2_trj)
)

if os.path.exists("NewMergedTrajectory-out.cms"):
print("...Done!")
print("Check your current working directory for new merged trajectory and -out.cms file.")
print(
"Check your current working directory for new merged trajectory and -out.cms file."
)
print("Thank you for using TrajectoryMergeAssist.")
print("\t")
else:
Expand All @@ -116,39 +158,48 @@ def MergeDesmondTrajectories(self):
def AskGROMACSTrajectory1(self):

global xtc1
xtc1 = tkinter.filedialog.askopenfilename(parent=root, initialdir="pwd", title='Please Select GROMACS Trajectory 1 .xtc file')
xtc1 = tkinter.filedialog.askopenfilename(
parent=root,
initialdir="pwd",
title="Please Select GROMACS Trajectory 1 .xtc file",
)
if len(xtc1) > 0:
print("%s selected" % xtc1)

def AskGROMACSTrajectory2(self):

global xtc2
xtc2 = tkinter.filedialog.askopenfilename(parent=root, initialdir="pwd", title='Please Select GROMACS Trajectory 2 .xtc file')
xtc2 = tkinter.filedialog.askopenfilename(
parent=root,
initialdir="pwd",
title="Please Select GROMACS Trajectory 2 .xtc file",
)
if len(xtc2) > 0:
print("%s selected" % xtc2)

def MergeGROMACSTrajectories(self):

if os.path.exists("/usr/local/gromacs"):
print("You are using GROMACS via /usr/local/gromacs")
elif os.path.exists("/usr/share/gromacs"):
print("You are using GROMACS via /usr/share/gromacs")
else:
print("Default GROMACS installation not found. Exiting.")
exit()
print("You are using GROMACS via /usr/local/gromacs")
elif os.path.exists("/usr/share/gromacs"):
print("You are using GROMACS via /usr/share/gromacs")
else:
print("Default GROMACS installation not found. Exiting.")
exit()

print("---------------------------------------------------------")
print("Merging both trajectories into one and generating .xtc...")
print("---------------------------------------------------------")

# For GROMACS 2019.1 http://manual.gromacs.org/current/onlinehelp/gmx-trjcat.html
# For GROMACS 2019.1 http://manual.gromacs.org/current/onlinehelp/gmx-trjcat.html

os.system("gmx trjcat -f %s %s -o NewMergedTrajectory.xtc" % (xtc1, xtc2))

os.system("gmx trjcat -f %s %s -o NewMergedTrajectory.xtc" % (
xtc1, xtc2))

if os.path.exists("NewMergedTrajectory.xtc"):
print("...Done!")
print("Check your current working directory for new merged trajectory (.xtc) file.")
print(
"Check your current working directory for new merged trajectory (.xtc) file."
)
print("Thank you for using TrajectoryMergeAssist.")
print("\t")
else:
Expand All @@ -158,8 +209,9 @@ def MergeGROMACSTrajectories(self):
exit()



if __name__ == "__main__":
app = MergeMDs(None)
app.title('TrajectoryMergeAssist v2.1: Merge Molecular Dynamics Extended Trajectories')
app.title(
"TrajectoryMergeAssist v2.1: Merge Molecular Dynamics Extended Trajectories"
)
app.mainloop()

0 comments on commit b5f7468

Please sign in to comment.