How to select all files from one sample?

对着背影说爱祢 提交于 2019-12-02 00:22:43

If you just want all the files in the directory, you can use a lambda function

from glob import glob

rule MarkDup:
    input:
        lambda wcs: glob('Outputs/MergeBamAlignment/%s*.bam' % wcs.samples)
    output:
        bam="Outputs/MarkDuplicates/{samples}_markedDuplicates.bam",
        metrics="Outputs/MarkDuplicates/{samples}_markedDuplicates.metrics"
    shell:
        ...

Just be aware that this approach can't do any checking for missing files, since it will always report that the files needed are the files that are present. If you do need confirmation that the upstream rule has been executed, you can have the previous rule touch a flag, which you then require as input to this rule (though you don't actually use the file for anything other than enforcing execution order).

If I understand correctly, zip needs to be applied only to {lane} and {flowcells} and not to {samples}. In that case, use two expand instances can achieve that.

input:
    expand(expand("Outputs/MergeBamAlignment/{{samples}}_{lanes}_{flowcells}.merged.bam", 
        zip, lanes=samples['lane'], flowcells=samples['flowcell']), 
            samples=samples['sample'])

PS: output.tmp file uses {sample} instead of {samples}. Typo?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!