47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
import os
|
|
import re
|
|
import argparse
|
|
|
|
# Natural sort
|
|
def natural_key(string_):
|
|
return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_)]
|
|
|
|
|
|
# Return absolute path from relative or absolute path
|
|
def abs_path(path):
|
|
abs_path = os.path.abspath(path)
|
|
return abs_path
|
|
|
|
|
|
# Sanitize user input paths
|
|
def san_path(path):
|
|
san_path = os.path.normpath(path)
|
|
return san_path
|
|
|
|
|
|
# Argument parser for run_simulations.py
|
|
def sim_parser(defaults):
|
|
# Use default settings from run_simulation.py to generate argument parser
|
|
parser = argparse.ArgumentParser()
|
|
for _arg, _val in defaults.items():
|
|
parser.add_argument(f'--{_arg}', type=type(_val[0]), default=_val[0], help=_val[1])
|
|
args_dict = vars(parser.parse_args())
|
|
return args_dict
|
|
|
|
|
|
# Argument parser for run_analysis.py
|
|
def analysis_parser():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--steps', type=int,
|
|
help='Number of timesteps to run the simulation')
|
|
parser.add_argument('--jobs_path', type=str, nargs='+', action='append',
|
|
help='Directory path containing the jobs to be run')
|
|
parser.add_argument('--namd_params', type=str,
|
|
help='Optional parameters to send to namd')
|
|
parser.add_argument('--ffs_path', type=str,
|
|
help='Location of the forcefield files')
|
|
parser.add_argument('--namd2_bin', type=str,
|
|
help='Location of the namd2 executable')
|
|
args = parser.parse_args()
|
|
return args
|