'My Snakemake code is deleting the source directory after moving files

I have a snakemake script which processes samples from a source folder (containing raw data). So in my last rule I have written a code which checks if the final file exist or not, if it exist it should move the main file from the source folder to other folder(folder with the name of sample). But the thing is after the rule is executed, it automatically deletes the source folder. How can i prevent this. I have written it in Python code.

rule movingData:
    input:
        file = config["ResultDir"]+"{sample}/Annotation/{sample}_FINAL.csv",
        first = config["SampleDir"]+"{sample}_R1.fastq.gz",
        second = config["SampleDir"]+"{sample}_R2.fastq.gz"
    output:
         temporary(touch(config["ResultDir"]+"{sample}/RawData/file.txt"))
    run:
        if os.path.exists(input.file):
            for sample in rawSAMPLES:
                os.rename(input.first,f'{config["ResultDir"]}{sample}/RawData/{sample}_R1.fastq.gz')
                os.rename(input.second,f'{config["ResultDir"]}{sample}/RawData/{sample}_R2.fastq.gz')

Same thing happens when I did it in shell.

rule movingData:
    input:
        file = config["ResultDir"]+"{sample}/Annotation/{sample}_FINAL.csv",
        first = config["SampleDir"]+"{sample}_R1.fastq.gz",
        second = config["SampleDir"]+"{sample}_R2.fastq.gz"
    output:
        temporary(touch(config["ResultDir"]+"{sample}/RawData/file.txt"))
    params: directory(config["ResultDir"]+"{sample}/RawData/")
    shell:
        '''
        [[ -f {input.file} ]] && mv {input.first} {input.second} {params}
        '''


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source