Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Snakemake:在一条规则中,在每个输入文件之前插入样本名称_Python_Perl_Snakemake - Fatal编程技术网

Python Snakemake:在一条规则中,在每个输入文件之前插入样本名称

Python Snakemake:在一条规则中,在每个输入文件之前插入样本名称,python,perl,snakemake,Python,Perl,Snakemake,我正在尝试为生物信息学工具FMAP创建一个规则文件 我一直在为FMAP_table.pl脚本创建规则。这是我目前的规则: rule fmap_table: input: expand(str(CLASSIFY_FP/"mapping"/"{sample}_abundance.txt"), sample=Samples.keys()) output: str(CLASSIFY_FP/'mapping'/'abu

我正在尝试为生物信息学工具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_funtity.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}
        """

运行该命令时会出现哪些错误?我不熟悉FMAP,但看起来在等号两边都不应该有空格。当我运行命令perl/media/data/FMAP/FMAP_table.pl{input}>{output}时,将创建一个表,其中列名将是每个输入文件的绝对路径,而不是
SAMPLE111_S1=SAMPLE111_S1\u funsity.txt
。这使得表格更难阅读,也使下游分析复杂化。我可以指定像这样的文件名perl/media/data/FMAP/FMAP_table.pl SAMPLE111_S1=SAMPLE111_S1_funtity.txt SAMPLE112_S2=SAMPLE112_S2.funtity.txt[etc.]>funtity.txt“问题是,我经常有50个或更多的样本,所以我想自动化它,而不是写下每个文件的名称