我正在尝试为生物信息学工具FMAP创建规则文件。https://github.com/jiwoongbio/FMAP
我一直在为FMAP_table.pl
脚本创建规则。这是我目前的规则:
rule fmap_table:
input:
expand(str(CLASSIFY_FP/"mapping"/"{sample}_abundance.txt"), sample=Samples.keys())
output:
str(CLASSIFY_FP/'mapping'/'abundance_table.txt')
shell:
"""
perl /media/data/FMAP/FMAP_table.pl {input} > {output}
"""
我希望列名仅包含样本名称,而不包含整个路径。可以在这样的脚本中完成
perl FMAP_table.pl [options] [name1=]abundance1.txt [[name2=]abundance2.txt [...]] > abundance_table.txt
我的问题是,如何为每个样本文件选择样本名称,样本路径并在两者之间添加=。
我的样本就是这样命名的SAMPLE111_S1_abundance.txt这是我想自动实现的格式:
perl /media/data/FMAP/FMAP_table.pl SAMPLE111_S1 = SAMPLE111_S1_abundance.txt SAMPLE112_S2 = SAMPLE112_S2.abundance.txt [etc.] > abundance.txt"
谢谢
我可能会添加一个参数来构建它,也许还会在外部构建dict中的文件名:
FMAP_INPUTS = {sample: str(CLASSIFY_FP/"mapping"/"{sample}_abundance.txt")
for sample in Samples.keys()}
rule fmap:
input: FMAP_INPUTS.values()
output:
str(CLASSIFY_FP/'mapping'/'abundance_table.txt')
params:
names=" ".join(f"{s}={f}" for s,f in FMAP_INPUTS.items())
shell:
"""
perl /media/data/FMAP/FMAP_table.pl {params.names} > {output}
"""
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句