亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Snakemake - 如何通過子目錄獲取目錄中的所有文件

Snakemake - 如何通過子目錄獲取目錄中的所有文件

PHP
守著一只汪 2023-11-09 17:07:14
我有一個包含多個目錄的目錄:/test/cond1//test/cond2//test/cond3//test/cond4/所有子目錄都有幾個不同的文件:cond1 : a1.txt, a2.txtcond2 : b1.txt, b2.txt, b3.txtcond3 : c1.txt, c2.txt, c4.txtcond4 : d1.txt,c2.txt, c4.txt, d2.txt我正在使用 Snakemake 運行命令,我需要通過 cond 獲取所有文件,并用空白分隔我嘗試這樣做:def get_motifs_tf(wildcards):    file_list = sorted(glob.glob("tf_final/{wildcards.cond}/*.bed"))    return " ".join(file_list)這是我的規則snakemakerule compute_combi_enrichment:    """    For a given input, compute the enrichment in n-wise TF combinations using OLOGRAM-MODL.    """    input:        query = 'input/core_silencer/{cond}/core_silencer.bed',        excl = "input/exclude_region_dhs.bed",        genome = "input/mm9.chromsizes"    params:        trs = get_motifs_tf,        minibatch_number = 16, minibatch_size = 10   # Modulate depending on available RAM    threads: 8                                       # Do not use 16 threads to not vampirize all the cluster    output: 'output/ologram_result/{cond}/00_ologram_stats.tsv',    shell: """    set +u; source /gpfs/tagc/home/Apps/anaconda3/bin/activate dev; set -u    gtftk ologram -z -c {input.genome} -p {input.query} --more-bed {params.trs} \        -o output/ologram_result/{wildcards.cell_line} --force-chrom-peak --force-chrom-more-bed  \        -V 3 -k {threads} -mn {params.minibatch_number} -ms {params.minibatch_size} \        --more-bed-multiple-overlap --bed-excl {input.excl} --no-date \        --multiple-overlap-max-number-of-combinations 80    """在 --more-bed {params.trs} 中我預計會得到:/test/cond1/a1.txt /test/cond1/a2.txt然后/test/cond2/b1.txt /test/cond2/b2.txt /test/cond2/b3.txt等等...
查看完整描述

1 回答

?
手掌心

TA貢獻1942條經驗 獲得超3個贊

我解決了它:

函數中的通配符必須在 stp 中轉換并且不帶括號:

def get_motifs_tf(wildcards):
    file_list = sorted(glob.glob("tf_final/"+str(wildcards.cond)+"/*.bed"))
        return " ".join(file_list)


查看完整回答
反對 回復 2023-11-09
  • 1 回答
  • 0 關注
  • 159 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號