Snakemake Error with MissingOutputException

Viewed 59

I am trying to run STAR with snakemake in a server, My smk file is that one :

import pandas as pd

configfile: 'config.yaml'

#Read sample to batch dataframe mapping batch to sample (here with zip)
sample_to_batch = pd.read_csv("/mnt/DataArray1/users/zisis/STAR_mapping/snakemake_STAR_index/all_samples_test.csv", sep = '\t')

#rule spcifying output
rule all_STAR:
    input:
        #expand("{sample}/Aligned.sortedByCoord.out.bam", sample = sample_to_batch['sample'])
        expand(config['path_to_output']+"{sample}/Aligned.sortedByCoord.out.bam", sample = sample_to_batch['sample'])

rule STAR_align:
    #specify input fastq files
    input:
        fq1 = config['path_to_output']+"{sample}_1.fastq.gz",
        fq2 = config['path_to_output']+"{sample}_2.fastq.gz"
    params:
        #location of indexed genome andl location to save the ouput
        genome = directory(config['path_to_reference']+config['ref_assembly']+".STAR_index"),
        prefix_outdir = directory(config['path_to_output']+"{sample}/")
    threads: 12
    output:
        config['path_to_output']+"{sample}/Aligned.sortedByCoord.out.bam"
    log:
        config['path_to_output']+"logs/{sample}.log"
    message:
        "--- Mapping STAR---"
    shell:
        """
        STAR --runThreadN {threads} \
        --readFilesCommand zcat \
        --readFilesIn {input} \
        --genomeDir {params.genome} \
        --outSAMtype BAM SortedByCoordinate \
        --outSAMunmapped Within \
        --outSAMattributes Standard
        """

While STAR starts normally at the end i have this error:

Waiting at most 5 seconds for missing files.
MissingOutputException in line 14 of /mnt/DataArray1/users/zisis/STAR_mapping/snakemake/STAR_snakefile_align.smk:
Job Missing files after 5 seconds:
/mnt/DataArray1/users/zisis/STAR_mapping/snakemake/001_T1/Aligned.sortedByCoord.out.bam
This might be due to filesystem latency. If that is the case, consider to increase the wait time with --latency-wait.
Job id: 1 completed successfully, but some output files are missing. 1
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message

I tried --latency-wait but is not working. In order to execute snake make i run the command

users/zisis/STAR_mapping/snakemake_STAR_index$ snakemake --snakefile STAR_new_snakefile.smk --cores all --printshellcmds

Technically i am in my directory with full access and permissions Do you think that this is happening due to strange rights in the execution of snakemake or when it tries to create directories ? It creates the directory and the files but i can see that there is a files Aligned.sortedByCoord.out.bamAligned.sortedByCoord.out.bam .

IS this the problem ?

1 Answers

I think your STAR command does not have the option that says which file and directory to write to, presumably it is writing the default filename to the current directory. Try something like:

rule STAR_align:
    input: ...
    output: ...
    ...
    shell:
        r"""
        outprefix=`dirname {output}`

        STAR --outFileNamePrefix $outprefix \
            --runThreadN {threads} \
            etc...
        """

I am runing the command from my directory in which i am sudo user

I don't think that is the problem but it is strongly recommended to work as regular user and use sudo only in special circumstances (e.g. installing system-wide programs but if you use conda you shouldn't need that).

Related