Hello! This is fragment of my snakefile:
SAMPLES=["sample_R1", "sample_R2"]
rule all:
input:
expand("path/to_file/{sample}.tsv"", sample=SAMPLES)
rule one:
input:
R1 = "path/to_file/{sample}.bam",
R2 = "path/to_file/{sample}.bam"
output:
"path/to_file/{sample}.tsv"
shell:
"path/to_file/src.py {input.R1} {input.R2}"
snakemake executing rule one like this:
path/to_file/sample_R1.bam, path/to_file/sample_R1.bam
path/to_file/sample_R2.bam, path/to_file/sample_R2.bam
What I need is:
path/to_file/sample_R1.bam, path/to_file/sample_R2.bam
and store the output in one .tsv file I already try some ways but I have fallen. Can someone give some advises? Thanks in advance.
your outputs (thus rule all input) are problem. If you want to have your final tsv to have sample name, you need to split between sample name and reads. You would understand the issue, if you run following code:
Wherever , bam files (sample_R1.bam, sample_R2.bam) are located, run this code:
To get the sample name in your output, you either modify output name (with in rule) or do wild cards separately for samples and reads. Run this code with
snakemake -nps file.smk
If you prefer OP way, try running following smk with
snakemake -nps file.smk
:I updated my code like your second advice, and a I got an error:
I have rules before rule one so I need to do rather this way. Please help.
Please post the code. without code, it is difficult to trouble shoot. If you have used expand function before '{res}' in your code some where , it needs to be expanded.