From d5bf512b797f878ad0121aa092d2117c4e1bf31e Mon Sep 17 00:00:00 2001 From: Sam Horsfield Date: Tue, 23 Apr 2024 14:35:07 +0100 Subject: [PATCH] scripts/create_symlink.py --- scripts/create_symlink.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/create_symlink.py b/scripts/create_symlink.py index dbd64b4..532a248 100644 --- a/scripts/create_symlink.py +++ b/scripts/create_symlink.py @@ -1,6 +1,7 @@ import glob from Bio import SeqIO import os +import shutil # inputdir and outputdir need to be without trailing "/" @@ -14,4 +15,14 @@ def symlink(list_of_dirs, file_ext, outputdir): filename = file.split("/")[-1] os.symlink(file, outputdir + "/" + filename) -symlink(snakemake.input.indir, snakemake.params.file_ext, snakemake.output.outputdir) +def copy(list_of_dirs, file_ext, outputdir): + try: + os.mkdir(outputdir) + except OSError: + pass + for ann_dirs in list_of_dirs: + file = glob.glob(ann_dirs + "/*." + file_ext)[0] + filename = file.split("/")[-1] + shutil.copyfile(file, outputdir + "/" + filename) + +copy(snakemake.input.indir, snakemake.params.file_ext, snakemake.output.outputdir)