diff --git a/gentop.py b/gentop.py index bfa4df4..4a646d2 100644 --- a/gentop.py +++ b/gentop.py @@ -41,8 +41,11 @@ 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 = parent.joinpath(f"{name}_topol.log") - with open(log_file, "w") as log: - subprocess.run(cmd, check=True, cwd=directory, stderr=log) + try: + with open(log_file, "w") as log: + subprocess.run(cmd, check=True, cwd=directory, stderr=log) + except subprocess.CalledProcessError as e: + print(f"Error processing {pdb_file.name}: {e}") # Example usage directory = "pdb_top" # Replace with your actual directory path