diff --git a/CLIP/iCLIP.snakefile b/CLIP/iCLIP.snakefile
index 9e9dfec2ab87a0950dddbd68ce341fc2cef75304..dcde8f800870784817cf0487fa95ffb38c11bcd8 100644
--- a/CLIP/iCLIP.snakefile
+++ b/CLIP/iCLIP.snakefile
@@ -623,9 +623,12 @@ bam2bigwig.sh: bedGraphToBigWig failed
onsuccess:
- print("iCLIP data pre-processing finished.")
+ print("iCLIP data analysis finished.")
cleanup_and_backup(output_dir, config)
onerror:
- print("iCLIP data pre-processing failed.")
+ shell(f"rm -rf {output_dir}_err")
+ shell(f"cp -rp {output_dir} {output_dir}_err")
+ cleanup_and_backup(output_dir + "_err", config)
+ print("iCLIP data analysis failed.")
diff --git a/PRO-seq/PRO-seq.snakefile b/PRO-seq/PRO-seq.snakefile
index b2b24fe3a9961b63bcf3782f5f62f1b0a40c7942..12b1075591cce4d05171d2efa2ed91687f95d2db 100644
--- a/PRO-seq/PRO-seq.snakefile
+++ b/PRO-seq/PRO-seq.snakefile
@@ -1537,5 +1537,8 @@ onsuccess:
cleanup_and_backup(output_dir, config)
onerror:
+ shell(f"rm -rf {output_dir}_err")
+ shell(f"cp -rp {output_dir} {output_dir}_err")
+ cleanup_and_backup(output_dir + "_err", config)
print("PRO-seq analysis failed.")
diff --git a/small_RNA-seq/small_RNA-seq.snakefile b/small_RNA-seq/small_RNA-seq.snakefile
index 43b6dd759a4305cec0c8c164d4f3257c6837b37d..81041c235304c0ffb67617b7a2f637407ab228d9 100644
--- a/small_RNA-seq/small_RNA-seq.snakefile
+++ b/small_RNA-seq/small_RNA-seq.snakefile
@@ -3865,20 +3865,11 @@ def try_to_cluster_genes(counts_data):
onsuccess:
print("small RNA-seq analysis finished.")
cleanup_and_backup(output_dir, config)
- # print("removing metadata")
- # # https://stackoverflow.com/a/45614282/1878788
- # rmtree(".snakemake/metadata")
- # if config.get("backup", {}):
- # user = config["backup"]["user"]
- # if user == "USER":
- # user = os.environ[user]
- # host = config["backup"]["host"]
- # # If no dest_dir, we assume the directory structure
- # # is the same on the destination host
- # dest_dir = config["backup"].get("dest_dir", os.getcwd())
- # print(f"backuping results to {user}@{host}:{dest_dir}")
- # shell(f"rsync -vaP {output_dir} {user}@{host}:{dest_dir}")
+
onerror:
+ shell(f"rm -rf {output_dir}_err")
+ shell(f"cp -rp {output_dir} {output_dir}_err")
+ cleanup_and_backup(output_dir + "_err", config)
print("small RNA-seq analysis failed.")