Skip to content

Commit

Permalink
Added an argparser for sbatch scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkastner committed Jan 6, 2024
1 parent 2355ebd commit 3f39588
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 24 deletions.
20 changes: 20 additions & 0 deletions demo/jobs.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/1/2_analysis/1_cluster/c0-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/1/2_analysis/1_cluster/c1-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/1/2_analysis/1_cluster/c2-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/1/2_analysis/1_cluster/c3-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/2/2_analysis/1_cluster/c0-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/2/2_analysis/1_cluster/c1-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/2/2_analysis/1_cluster/c2-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/2/2_analysis/1_cluster/c3-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/3/2_analysis/1_cluster/c0-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/3/2_analysis/1_cluster/c1-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/3/2_analysis/1_cluster/c2-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/3/2_analysis/1_cluster/c3-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/4/2_analysis/1_cluster/c0-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/4/2_analysis/1_cluster/c1-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/4/2_analysis/1_cluster/c2-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/4/2_analysis/1_cluster/c3-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/5/2_analysis/1_cluster/c0-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/5/2_analysis/1_cluster/c1-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/5/2_analysis/1_cluster/c2-opt/
/home/kastner/projects/mimochromes/mc6/2_oxo/3_md/5/2_analysis/1_cluster/c3-opt/
24 changes: 24 additions & 0 deletions demo/jobscript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#$ -S /bin/bash # Specifies interpreting shell for the job
#$ -N pyEF # Identifier for the job
#$ -l h_rt=48:00:00 # Specify maximum runtime
#$ -l h_rss=40G # Specify requested memory
#$ -q gpusnew # Specify which queue to submit the job to
#$ -l gpus=1 # Always set to 1 no matter how many gpus are used.
#$ -pe smp 2 # Number of parallel processes to run (defines how many GPUs)
# -fin job_paths.in
# -fin metal_indices.in

export OMP_NUM_THREADS=2 # Number of threads to be spawned (needs to be the same as -smp)
source ~/.bashrc
conda activate molsimp

# --geom Whether to perform a geometry check
# --esp Whether to perform ESP analysis
# --jobs_file Paths to all the QM jobs
# --metals_file The indices of the metals for each job

RUN="/home/kastner/packages/pyEF/pyef/run.py"
JOBS="/home/kastner/packages/pyEF/demo/jobs.in"
METALS="/home/kastner/packages/pyEF/demo/metals.in"
python $RUN --geom --esp --jobs_file $JOBS --metals_file $METALS > pyEF.log

20 changes: 20 additions & 0 deletions demo/metals.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
486
486
486
486
486
486
486
486
486
486
486
486
486
486
486
486
486
486
486
486
18 changes: 0 additions & 18 deletions pyef/jobscript.sh

This file was deleted.

27 changes: 21 additions & 6 deletions pyef/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import os
import sys
import pyef
import argparse
from pyef.analysis import Electrostatics
from pyef.geometry import ErrorAnalysis

Expand Down Expand Up @@ -55,11 +58,23 @@ def main(jobs, geom_flag, esp_flag, metal_indices):
# Method to Compute Efield Projections on bonds connected to the atom specified by index in metal_indices
dataObject.getEFieldData(Efield_data_filename)

def read_file_lines(file_path):
"""Reads in auxiliary files containing job information"""
with open(file_path, 'r') as file:
return [line.strip() for line in file.readlines()]

if __name__ == "__main__":
geom_flag = False # Perform a geometry check
esp_flag = False # Perform analysis of electrostatics
jobs = ['/home/kastner/DavidMimichrome/mc6_1_2best_c0opt', '/home/kastner/DavidMimichrome/mc6_2_6best_c0opt']
metal_indices = [486, 486]
main(jobs, geom_flag, esp_flag, metal_indices)
# Example: python run.py --geom --esp --jobs_file path/to/jobs.in --metals_file path/to/metals.in > pyEF.log
parser = argparse.ArgumentParser(description="Script Description")
parser.add_argument("--geom", action="store_true", help="Perform a geometry check")
parser.add_argument("--esp", action="store_true", help="Perform analysis of electrostatics")
parser.add_argument("--jobs_file", required=True, help="Path to file containing job paths")
parser.add_argument("--metals_file", required=True, help="Path to file containing metal indices")

args = parser.parse_args()
geom_flag = args.geom
esp_flag = args.esp
jobs = read_file_lines(args.jobs_file)
metal_indices = [int(idx) for idx in read_file_lines(args.metals_file)]

# /home/kastner/DavidMimichrome/mc6_1_2best_c0opt, /home/kastner/DavidMimichrome/mc6_2_6best_c0opt
main(jobs, geom_flag, esp_flag, metal_indices)

0 comments on commit 3f39588

Please sign in to comment.