1

I have a rule that needs to take 2 samples and combine them. This is how my samples look like in my config file:

samples:
    group1:
        sra1: 
            sample: "SRR14724462"
            cell_line: "NA24385"
            exome_bedfile: "/bedfiles/truseq.sorted.bed"
        sra2: 
            sample: "SRR14724472"
            cell_line: "NA24385"
            exome_bedfile: "/bedfiles/idt.sorted.bed"
    group2:
        sra1: 
            sample: "SRR14724463"
            cell_line: "NA12878"
            exome_bedfile: "/bedfiles/truseq.sorted.bed"
        sra2:
            sample: "SRR14724473"
            cell_line: "NA12878"
            exome_bedfile: "/bedfiles/idt.sorted.bed"

Essentially I want to combine group1 sra1 together, and group2 sra2 together, into these combinations: SRR14724462 and SRR14724463 SRR14724472 and SRR14724473

This is my rule and rule all:

rule combine:       
    output:
        r1 = TRIMMED_DIR + "/{sample1}_{sample2}_R1.fastq",
        r2 = TRIMMED_DIR + "/{sample1}_{sample2}_R2.fastq"
    params:
        trimmed_dir = TRIMMED_DIR,
        a = "{sample1}", 
        b = "{sample2}"
    shell: 
        cd {params.trimmed_dir}
        /combine.sh {params.a}_R1_trimmed.fastq {params.a}_R2_trimmed.fastq {params.b}_R1_trimmed.fastq {params.b}_R2_trimmed.fastq

rule all:
     expand(TRIMMED_DIR + "/{sample1}_{sample2}_R1.fastq", sample1=list_a, sample2=list_b),
     expand(TRIMMED_DIR + "/{sample1}_{sample2}_R2.fastq", sample1=list_a, sample2=list_b)

This works EXCEPT it does these combinations: SRR14724462 and SRR14724463 SRR14724462 and SRR14724473 SRR14724472 and SRR14724463 SRR14724472 and SRR14724473

I only want these combinations: SRR14724462 and SRR14724463 SRR14724472 and SRR14724473

Note: Not shown is how i got list_a and list_b, but essentially they are: list_a = ['SRR14724462', 'SRR14724472'] list_b = ['SRR14724463', 'SRR14724473']

David Ansermot
  • 6,052
  • 8
  • 47
  • 82
  • The way `expand` behaves can trip people up a bit - I've tried to put together an overview of how to create lists of input files when default `expand` doesn't do what you need: https://stackoverflow.com/q/74400966/15704972 Does that help? – KeyboardCat Nov 11 '22 at 14:26
  • Wow this was such an easy fix. Thank you so much! – Hannele Padre Nov 11 '22 at 23:33
  • @HannelePadre if you found a solution you can post it as an answer and accept it. – dariober Nov 14 '22 at 10:06

0 Answers0