Skip to content

Commit

Permalink
updated HPC scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rsexton2 committed Jan 27, 2025
1 parent 92e03df commit 7a0ad41
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 30 deletions.
13 changes: 9 additions & 4 deletions scripts/create_jobs.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
#!/usr/bin/bash
if [ -z "$1" ]; then
echo "Provide cutoff"
exit 1
fi
cutoff=$1

if [[ $1 = "--rerun" ]];
if [[ $2 = "--rerun" ]];
then
echo "submitting rerun jobs"
#./get_rerun_residues.py
IFS=,
read -r -a residues < rerun_residues.csv
read -r -a residues < rerun_residues_$cutoff.csv
else
echo "submitting all jobs"
IFS=,
read -r -a residues < residue_list.csv
read -r -a residues < residue_list_$cutoff.csv
fi


for res in ${residues[@]}; do
sed -r "s/RESIDUE/${res}/g;s/RESID/${res:1}/g" submit_tmp.slu > submit.slu;
sed -r "s/RESIDUE/${res}/g;s/RESID/${res:1}/g;s/CUTOFF/$cutoff/g" submit_tmp.slu > submit.slu;
sbatch submit.slu
done

9 changes: 7 additions & 2 deletions scripts/get_rerun_residues.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from glob import glob
import numpy as np
import os
import sys

if len(sys.argv) < 2:
sys.exit('Provide cutoff')

cutoff = sys.argv[1]
bashCommand = "sacct -n -X --format jobname,jobid -s RUNNING > .running_jobs.txt"
os.system(bashCommand)

Expand All @@ -10,7 +15,7 @@
for line in f:
running.append(line.strip().split()[0])

os.chdir('basicrta-7.0/')
os.chdir(f'basicrta-{cutoff}/')
dirs = np.array(glob('?[0-9]*'))

if len(running) > 0:
Expand All @@ -28,7 +33,7 @@
rerundirs.append(adir)

rerunids = [adir for adir in rerundirs]
with open('../rerun_residues.csv', 'w') as w:
with open(f'../rerun_residues_{cutoff}.csv', 'w') as w:
for res in rerunids:
w.write(f'{res},')

49 changes: 30 additions & 19 deletions scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,39 @@
import MDAnalysis as mda
import pickle

with open('contacts_7.0.pkl', 'rb') as f:
a = pickle.load(f)
if __name__=="__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--contacts', type=str)
args = parser.parse_args()

rg = a.dtype.metadata['ag1'].residues
ids = rg.resids
names = rg.resnames
names = np.array([mda.lib.util.convert_aa_code(name) for name in names])
uniqs = np.unique(a[:, 0]).astype(int)
dirname = args.contacts.strip('.pkl')
cutoff = dirname.split('_')[1]

inds = np.array([np.where(ids==val)[0][0] for val in uniqs])
resids, resnames = ids[inds], names[inds]
residues = np.array([f'{name}{resid}' for name, resid in zip(resnames, resids)])
with open(f'{args.contacts}', 'rb') as f:
a = pickle.load(f)

with open('residue_list.csv', 'w+') as r:
for residue in residues:
r.write(f'{residue},')
rg = a.dtype.metadata['ag1'].residues
ids = rg.resids
names = rg.resnames
names = np.array([mda.lib.util.convert_aa_code(name) for name in names])
uniqs = np.unique(a[:, 0]).astype(int)

inds = np.array([np.where(ids==val)[0][0] for val in uniqs])
resids, resnames = ids[inds], names[inds]
residues = np.array([f'{name}{resid}' for name, resid in zip(resnames, resids)])

with open('residue_list.csv', 'w+') as r:
for residue in residues:
r.write(f'{residue},')

if not os.path.exists('basicrta-7.0'):
os.mkdir('basicrta-7.0')
if not os.path.exists(f'basicrta-{cutoff}'):
os.mkdir(f'basicrta-{cutoff}')

os.chdir('basicrta-7.0')
os.chdir(f'basicrta-{cutoff}')

for residue in residues:
if not os.path.exists(residue):
os.mkdir(residue)

for residue in residues:
if not os.path.exists(residue):
os.mkdir(residue)

16 changes: 14 additions & 2 deletions scripts/status_update.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/usr/bin/bash


if [ -z "$1" ]; then
echo "Provide cutoff"
exit 1
fi
cutoff=$1

sacct -n -X --format jobname,jobid -s RUNNING > .running_jobs.txt
awk -v col1=1 -v col2=2 '{printf "basicrta-7.0/%s/slurm-%s.out \n", $col1, $col2}' < .running_jobs.txt | xargs tail -n 1 | sed 's@[^a-z A-Z0-9.:%|</]@@;s/\].*/\]/'; echo
filenames=`awk -v col1=1 -v col2=2 '{printf "basicrta-%s/%s/slurm_%s.out \n", "'$cutoff'", $col1, $col2}' < .running_jobs.txt`

for file in $filenames; do
if [ -e $file ]; then
echo $file | xargs tail -n 1 | sed 's@[^a-z A-Z0-9.:%|</]@@;s/\].*/\]/'; echo
fi;
done
9 changes: 6 additions & 3 deletions scripts/submit_tmp.slu
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
#SBATCH -N 1
#SBATCH -n 1
#SBATCH --mem=20G
#SBATCH basicrta-7.0/RESIDUE/slurm_${SLURM_JOB_ID}.log

python -m basicrta.gibbs --resid RESID
#SBATCH -o basicrta-7.0/RESIDUE/slurm_%j.out
#SBATCH -t 1-12:00:00
#SBATCH -p general
#SBATCH -q public
#SBATCH --cpus-per-task=1

python -m basicrta.gibbs --contacts contacts_7.0.pkl --resid RESID

0 comments on commit 7a0ad41

Please sign in to comment.