Skip to content

Commit

Permalink
Fixed consective HH commands, able to use file pathing across files
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-mae committed Aug 7, 2023
1 parent 515c3be commit 06b0690
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 119 deletions.
8 changes: 2 additions & 6 deletions holebash.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#!/bin/bash

username=$(whoami)
folder_dir=$(find /home/$username -type d -name "HH-Results" ! -path "/home/*/*.*")
logs_folder="$folder_dir/logs-folder"
inp_folder="$folder_dir/inp-folder"
for inp_file in $inp_folder/*;
for inp_file in $1/HH-Results/inp-folder/*;
do
full_filename=$(basename $inp_file)
file="${full_filename%.*}"

hole < $inp_file >> "$logs_folder/$file.log"
hole < $inp_file >> "$1/HH-Results/logs-folder/$file.log"
done
138 changes: 54 additions & 84 deletions holehelper.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace eval ::HOLEHelper:: {
variable output_dir
}


proc holehelper_usage {} {
vmdcon -info "Usage: holehelper <pdbfile> <psffile> <dcdfolder> <dcdstep> <molsel> <wrap> \
<cvec> <radtype> <cp> <endrad> <outputdir>"
Expand Down Expand Up @@ -113,7 +112,7 @@ proc holehelper_core {args} {
set outputdirbashpath [exec find /home/$user -type d -name "${outputdir}" ! -path "/home/*/*.*"]

if {$wrap != "no"} {
pbc wrap -all -sel "${molesel}" -centersel "${wrap}" \
pbc wrap -sel "${molesel}" -all -centersel "${wrap}" \
-compound fragment -center com
}

Expand Down Expand Up @@ -147,6 +146,7 @@ proc holehelper_core {args} {
mol addfile $dcdfiles type dcd step $step_size waitfor -1
}
}
set top_mol [molinfo top]
cd $outputdirbashpath
file mkdir HH-Results
cd $outputdirbashpath/HH-Results
Expand Down Expand Up @@ -186,11 +186,25 @@ proc holehelper_core {args} {
}

cd $user_holepath
exec sh holebash.sh
exec python3 sphcleaner.py
source sameatomcount.tcl

exec sh holebash.sh "${outputdirbashpath}"
exec python3 sphcleaner.py ${outputdirbashpath}
cd $outputdirbashpath/HH-Results/sph-folder
set sphfilelist [lsort [glob *.sph]]

foreach sph $sphfilelist {
mol new $sph type pdb
set real_atom_count [molinfo top get numatoms]
set moleculeid [molinfo top]
set fake_atom_count 1000
set atom_count_diff [expr $fake_atom_count - $real_atom_count]
set outfile [open $sph a]
for { set f 0 } {$f < $atom_count_diff } { incr f} {
puts $outfile "ATOM 1 QSS SPH S-888"
}
close $outfile
mol delete $moleculeid
}

set sphfilelist [lsort [glob *.sph]]
mol new [lindex $sphfilelist 0] type pdb
set top_num [molinfo top]
Expand All @@ -200,9 +214,13 @@ proc holehelper_core {args} {
for {set f 1} {$f < $frame_nums} {incr f} {
mol addfile [lindex $sphfilelist $f] type pdb
}
cd /home/$user
mol top $top_mol


}


proc ::HOLEHelper::holehelper {} {
variable w
variable hh_path
Expand Down Expand Up @@ -388,9 +406,7 @@ proc ::HOLEHelper::holehelper {} {

pack [button $w.traj -text "Run HOLE2 on Trajectory" -command ::HOLEHelper::run_hole2_traj] \
-side top -pady 5 -padx 3 -fill x -anchor w

pack [button $w.loaded -text "Run HOLE2 On Top Mol" -command ::HOLEHelper::loaded_hole] \
-side top -pady 5 -padx 3 -fill x -anchor w

#-------------------------------------------------------------------------
}
proc ::HOLEHelper::run_hole2_single {} {
Expand All @@ -415,6 +431,9 @@ proc ::HOLEHelper::run_hole2_single {} {
$primarycvec_y $primarycvec_z $primarycpnt_x $primarycpnt_y $primarycpnt_z \
$endrad $output_dir


set top_mol [molinfo top]

cd $output_dir
file mkdir HH-Results
cd $output_dir/HH-Results
Expand Down Expand Up @@ -451,6 +470,7 @@ proc ::HOLEHelper::run_hole2_single {} {
cd $hh_path
exec sh holebash.sh


cd $output_dir/HH-Results/sph-folder
set sphfilelist [lsort [glob *.sph]]
mol new [lindex $sphfilelist 0] type pdb
Expand All @@ -459,8 +479,15 @@ proc ::HOLEHelper::run_hole2_single {} {
set sel [atomselect top "all"]
$sel set radius [$sel get beta]

cd /home/$user
mol top $top_mol

}

# pbc wrap -all -sel "segname 12 13 14 15 16 17" -centersel "segname 12" -compound fragment -center com
# pbc wrap -all -sel "segname 0 1 2 3 4 5" -centersel "segname 0" -compound fragment -center com
#pbc wrap -all -sel "segname 6 7 8 9 10 11" -centersel "segname 11" -compound fragment -center com

proc ::HOLEHelper::run_hole2_traj {} {
variable user
variable hh_path
Expand All @@ -480,6 +507,8 @@ proc ::HOLEHelper::run_hole2_traj {} {
$primarycvec_y $primarycvec_z $primarycpnt_x $primarycpnt_y $primarycpnt_z \
$endrad $output_dir

set top_mol [molinfo top]

cd $output_dir
file mkdir HH-Results
cd $output_dir/HH-Results
Expand Down Expand Up @@ -524,89 +553,28 @@ proc ::HOLEHelper::run_hole2_traj {} {
close $outfile
}


cd $hh_path
exec sh holebash.sh
exec python3 sphcleaner.py
source sameatomcount.tcl
exec sh holebash.sh "${output_dir}"
exec python3 sphcleaner.py ${output_dir}

cd $output_dir/HH-Results/sph-folder
set sphfilelist [lsort [glob *.sph]]
mol new [lindex $sphfilelist 0] type pdb
set top_num [molinfo top]
mol modstyle 0 $top_num VDW
set sel [atomselect top "all"]
$sel set radius [$sel get beta]
for {set f 1} {$f < $frame_nums} {incr f} {
mol addfile [lindex $sphfilelist $f] type pdb
}
}

proc ::HOLEHelper::loaded_hole {} {
variable user
variable primarypdb
variable wrapping_filler ""
variable hh_path
variable primarycvec_x
variable primarycvec_y
variable primarycvec_z
variable radius
variable endrad
variable primarycpnt_x
variable primarycpnt_y
variable primarycpnt_z
variable output_dir

set molecule_sel_lst [molinfo top get selection]
set cleaned_sel [lindex $molecule_sel_lst 0]
set final_mol_sel [atomselect top "${cleaned_sel}"]

error_checker $cleaned_sel $wrapping_filler $primarycvec_x \
$primarycvec_y $primarycvec_z $primarycpnt_x $primarycpnt_y $primarycpnt_z \
$endrad $output_dir

cd $output_dir
file mkdir HH-Results
cd $output_dir/HH-Results
file mkdir pdb-folder
file mkdir inp-folder
file mkdir sph-folder
file mkdir logs-folder
set frame_nums [molinfo top get numframes]

set com [measure center $final_mol_sel]
set com_x [lindex $com 0]
set com_y [lindex $com 1]
set com_z [lindex $com 2]

for { set f 0 } { $f < $frame_nums } { incr f} {


# Writing out the pdbs

cd $output_dir/HH-Results/pdb-folder
animate write pdb "HoleHelper-PDB-${f}.pdb" beg $f end $f waitfor -1 sel $final_mol_sel

# Writing the inp files for the bash script to read

cd ../inp-folder
set outfile [open "HoleHelper-INP-${f}.inp" w+]
puts $outfile "coord ${output_dir}/HH-Results/pdb-folder/HoleHelper-PDB-${f}.pdb"
puts $outfile "radius ${hh_path}/rad/${radius}.rad"
puts $outfile "sphpdb ${output_dir}/HH-Results/sph-folder/HoleHelper-SPH-${f}.sph"
puts $outfile "cvect ${primarycvec_x} ${primarycvec_y} ${primarycvec_z}"
if {($primarycpnt_x != "") && ($primarycpnt_x != "") && ($primarycpnt_x != "")} {
puts $outfile "cpoint ${primarycpnt_x} ${primarycpnt_y} ${primarycpnt_z}"
}
if {$endrad != ""} {
puts $outfile "endrad ${endrad}"
foreach sph $sphfilelist {
mol new $sph type pdb
set real_atom_count [molinfo top get numatoms]
set moleculeid [molinfo top]
set fake_atom_count 1000
set atom_count_diff [expr $fake_atom_count - $real_atom_count]
set outfile [open $sph a]
for { set f 0 } {$f < $atom_count_diff } { incr f} {
puts $outfile "ATOM 1 QSS SPH S-888"
}
close $outfile
mol delete $moleculeid
}

cd $hh_path
exec sh holebash.sh
exec python3 sphcleaner.py
source sameatomcount.tcl
cd $output_dir/HH-Results/sph-folder
set sphfilelist [lsort [glob *.sph]]
mol new [lindex $sphfilelist 0] type pdb
Expand All @@ -617,7 +585,9 @@ proc ::HOLEHelper::loaded_hole {} {
for {set f 1} {$f < $frame_nums} {incr f} {
mol addfile [lindex $sphfilelist $f] type pdb
}

cd /home/$user
mol top $top_mol

}

proc ::HOLEHelper::error_checker {molsel pbccond cvx cvy cvz cpx cpy cpz ed outdir} {
Expand Down
20 changes: 0 additions & 20 deletions sameatomcount.tcl

This file was deleted.

14 changes: 5 additions & 9 deletions sphcleaner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import glob
import subprocess
import sys
import os

def readsphfile(sphfile):
'''
Expand All @@ -22,14 +23,9 @@ def readsphfile(sphfile):
fi.close()

def main():
user_name = subprocess.run(['whoami'],shell=True, capture_output=True,text=True)
readable_user_name = user_name.stdout
cleaned_user_name = readable_user_name.strip()
cli_func = subprocess.run([f'find /home/{cleaned_user_name} -type d -name "HH-Results" ! -path "/home/*/*.*"'],shell=True, capture_output=True,text=True)
sph_path = cli_func.stdout
sph_path = sph_path.strip()
sph_path += "/sph-folder/"
holelist = sorted(glob.glob(f'{sph_path}*.sph'))

os.chdir(f'{sys.argv[1]}/HH-Results/sph-folder')
holelist = sorted(glob.glob('*.sph'))

for sphfile in holelist:
readsphfile(sphfile)
Expand Down

0 comments on commit 06b0690

Please sign in to comment.