From fbb1fcf3f4a3f86afb67dd0940d4d66da7487ecf Mon Sep 17 00:00:00 2001 From: hotwa Date: Tue, 9 Jan 2024 13:18:23 +0800 Subject: [PATCH] update --- gentop.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gentop.py b/gentop.py index f60f014..bfa4df4 100644 --- a/gentop.py +++ b/gentop.py @@ -19,8 +19,13 @@ def generate_gmx_top_files(directory, num_cores, forcefield="amber99sb-ildn", wa # Iterate over each PDB file and execute the GROMACS command for pdb_file in pdb_files: name = pdb_file.stem # Extract the name without the '.pdb' extension + parent = pdb_file.parent output_gro = f"{name}.gro" - topol_file = "topol.top" + topol_file = f"{name}_topol.top" + + # Check if topol_file already exists, and if so, skip this task + if Path(topol_file).exists(): + continue # Construct the command cmd = [ @@ -35,7 +40,7 @@ def generate_gmx_top_files(directory, num_cores, forcefield="amber99sb-ildn", wa ] # Run the command and capture the standard error (stderr) to a log file - log_file = pdb_file.absolute().parent.joinpath(f"{name}_gentop.log") + log_file = parent.joinpath(f"{name}_topol.log") with open(log_file, "w") as log: subprocess.run(cmd, check=True, cwd=directory, stderr=log)