• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python workflow.attach_back函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中samflow.workflow.attach_back函数的典型用法代码示例。如果您正苦于以下问题:Python attach_back函数的具体用法?Python attach_back怎么用?Python attach_back使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了attach_back函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _bowtie

def _bowtie(workflow, conf):
    for target in conf.sample_targets:
        bowtie = attach_back(workflow,
            ShellCommand(
                "{tool} -p {param[threads]} -S -m {param[max_align]} \
                {param[genome_index]} {input[fastq]} {output[sam]} 2> {output[bowtie_summary]}",
                input={"genome_dir": os.path.dirname(conf.get_path("lib", "genome_index")),
                       "fastq": target + ".fastq"},
                output={"sam": target + ".sam",
                        "bowtie_summary": target + "_bowtie_summary.txt", },
                tool="bowtie",
                param={"threads": 4,
                       "max_align": 1,
                       "genome_index": conf.get_path("lib", "genome_index")}))

        bowtie.update(param=conf.items("bowtie"))
    __sam2bam(workflow, conf)

    ## using bowtie standard error output
    attach_back(workflow,
        PythonCommand(stat_bowtie,
            input={"bowtie_summaries": [t + "_bowtie_summary.txt" for t in conf.sample_targets],
                   "db": ChiLinQC_db,
                   "template": rlang_template},
            output={"json": conf.json_prefix + "_bowtie.json",
                    "R": conf.prefix + "_bowtie.R",
                    "pdf": conf.prefix + "_bowtie.pdf"},
            param={"sams": [t + ".sam" for t in conf.sample_targets], }))
开发者ID:hanfeisun,项目名称:ChiLin2,代码行数:28,代码来源:ChiLin2.py


示例2: sample_bam_stat

def sample_bam_stat(workflow, conf, tex):
    """ sample non chrm bam to 15M for NSC and PBC
    sample non chrm bam to 5M for spot
    """
    for i, target in enumerate(conf.treatment_targets):
        ## for PE, use name sorted in order to calculate PBC
        input_bam = target + "_name_sorted.bam" if conf.pe else target + "_final_nochrm.bam"
        attach_back(workflow, ShellCommand(
            "{tool} {input[namesorted]} {param[run_spp]} {output[bamstat]} {output[sppstat]}  {param[pe]} {output[pbc]}",
            tool = "eap_dnase_stats",
            input = {"namesorted": input_bam},
            output = {"bamstat": target + "_bam_stat.qc",  ## 15M
                      "sppstat": target + "_spp.qc",
                      "pbc": target + "_final_nochrm_15M_pbc.qc"},
            param = {"pe": "pe" if conf.pe else "se",
                     "run_spp": conf.get("tool", "spp")}))

        if not "macs" in conf.get("tool", "peak_calling"):

            attach_back(workflow, ShellCommand(
                "{tool} {input[bamwithoutchrm]} {param[genome]} {param[readsize]} {output[spot]} {param[hotspot_dir]} {param[hotspot_output]} {param[hotspot_tmp]} {param[spot_tmp]}",
                tool = "dac_spot", ## 5M
                input = {"bamwithoutchrm": target + "_final_nochrm.bam"},
                output = {"spot": target + "_spot_nochrm_5M.qc"},

                param = {"genome": conf.species,
                         "spot_tmp": conf.hotspot_reps_tmp_prefix[i] + "_final_nochrm.bam.5000000.spot.out",
                         "readsize": conf.readsize,
                         "hotspot_dir": conf.get("tool", "peak_calling"),
                         "hotspot_output": target + "_hotspot",
                         "hotspot_tmp": target + "_hotspot_tmp"}))
开发者ID:asntech,项目名称:GCAP,代码行数:31,代码来源:dnase_stat.py


示例3: fragment

def fragment(workflow, conf):
    ## this is done after FRiP
    if conf.get("tool", "macs2"):
       macs2_bin = conf.get("tool", "macs2")
    else:
        macs2_bin = "macs2"
    for target in conf.treatment_targets:
        fragment_size = attach_back(workflow, ShellCommand(
            "{tool} predictd -i {input[bam]} --rfile {param[prefix]} -g {param[species]}",
            tool = macs2_bin,
            input = {"bam": target + ".bam"},
            output = {"R": target + "_model.R"},
            param = {"prefix": target + "_model.R",
                     "species": 'hs'}))
        fragment_size.update(param = conf.items("macs2"))
        ## except two few peaks for modeling
        fragment_size.allow_fail = True
        fragment_size.allow_dangling = True
        
    ## extract standard deviation from MACS2 model.R,
    ## use m, p, and pileup value for standard deviation; mean fragment size is provided (choose the one with highest correlation)
    frag_qc = attach_back(workflow, PythonCommand(
        stat_frag_std,
        input = {"r": [target + "_model.R" for target in conf.treatment_targets]},
        output = {"json": conf.json_prefix + "_frag.json", "r": [ target + "_frag_sd.R" for target in conf.treatment_targets ]},
        param = {"samples": conf.treatment_bases,
                 "frag_tool": "BAMSE"},
        name = "macs2 model R script parser"))
    frag_qc.allow_fail = True
    frag_qc.allow_dangling = True
开发者ID:asntech,项目名称:chilin,代码行数:30,代码来源:dc.py


示例4: stat_bedAnnotate

def stat_bedAnnotate(workflow, conf, has_dhs, has_velcro):
    """ Describe peaks' distribution
    # collect meta gene distribution info
    """
    collect_meta2 = attach_back(workflow, PythonCommand(
        json_meta2,
        input={"meta": conf.prefix + ".meta"},
        output={"json": conf.json_prefix + "_meta.json"},
        param={"id": conf.id},
        name="bedAnnotate summary"))
    collect_meta2.allow_fail = True
    collect_meta2.allow_dangling = True

    if has_dhs:
        collect_dhs = attach_back(workflow, PythonCommand(
            json_dhs,
            input={"dhs": conf.prefix + ".dhs",
                   "top_peaks": 5000},
            output={"json": conf.json_prefix + "_dhs.json"},
            name="DHS summary"))
        collect_dhs.allow_dangling = True
        collect_dhs.allow_fail = True

    if has_velcro:
        collect_velcro = attach_back(workflow, PythonCommand(
            json_velcro,
            input={"velcro": conf.prefix + ".velcro",
                   "top_peaks": 5000},
            output={"json": conf.json_prefix + "_velcro.json"},
            name="Velcro summary"))
        collect_velcro.allow_fail = True
        collect_velcro.allow_dangling = True
开发者ID:cfce,项目名称:chilin,代码行数:32,代码来源:qc.py


示例5: tex_fastqc

def tex_fastqc(workflow, conf):
    quality = attach_back(workflow,
        PythonCommand(
            load_latex,
            input={"json": conf.json_prefix + "_fastqc.json",
                   "template": resource_filename("chilin2.modules.fastqc", "fastqc.tex"),
                   "pdf": conf.prefix + "_raw_sequence_qc.pdf"},
            output={"latex": conf.latex_prefix + "_fastqc.tex"}))

    quality.allow_fail = True
    quality.allow_dangling = True

    #these are name, png pairings
    if not conf.pe:
        gccontent_graphs = [(nm.replace("_"," "),
                             os.path.join(conf.target_dir, "%s_100k_fastqc" % nm,
                                          "Images","per_sequence_gc_content.png"))\
                                for nm in conf.sample_bases]
    else:
        gccontent_graphs = [(nm.replace("_"," "),
                             os.path.join(conf.target_dir, "%spair1_100k_fastqc" % nm,
                                          "Images","per_sequence_gc_content.png"))\
                                for nm in conf.sample_bases]
    gc = attach_back(workflow,
        PythonCommand(
            load_gc_latex,
            input={"template": resource_filename("chilin2.modules.fastqc", "fastqc_gc.tex"),
                   "gccontent_graphs":gccontent_graphs },
            output={"latex": conf.latex_prefix + "_fastqc_gc.tex"}))

    gc.allow_fail = True
    gc.allow_dangling = True
开发者ID:cfce,项目名称:chilin,代码行数:32,代码来源:tex.py


示例6: tex_conserv

def tex_conserv(workflow, conf):
    attach_back(workflow,
        PythonCommand(
            latex_conservation,
            input={"template": resource_filename("chilin2.modules.conservation", "conservation.tex")},
            output={"latex": conf.latex_prefix + "_conserv.tex"},
            param = {"prefix": conf.prefix}))
开发者ID:asntech,项目名称:chilin,代码行数:7,代码来源:tex.py


示例7: _bowtie_latex

def _bowtie_latex(workflow, conf):
    attach_back(workflow,
        PythonCommand(
            latex_bowtie,
            input={"json": conf.json_prefix + "_bowtie.json",
                   "template": latex_template},
            output={"latex": conf.latex_prefix + "_bowtie.latex"}))
开发者ID:hanfeisun,项目名称:ChiLin2,代码行数:7,代码来源:ChiLin2.py


示例8: _macs2_cor_latex

def _macs2_cor_latex(workflow, conf):
    attach_back(workflow,
        PythonCommand(
            latex_cor,
            input={"json": conf.json_prefix + "_cor.json",
                   "template": latex_template},
            output={"latex": conf.latex_prefix + "_cor.latex"}))
开发者ID:hanfeisun,项目名称:ChiLin2,代码行数:7,代码来源:ChiLin2.py


示例9: tex_bwa

def tex_bwa(workflow, conf):
    attach_back(workflow,
                PythonCommand(
                    long_tex,
                    input = {"template": resource_filename("chilin2.modules.bwa", "bwa.tex"),
                             "figure": conf.prefix + "_bwa_compare.pdf"},
                    output = {"latex": conf.latex_prefix + "_map.tex"}))
开发者ID:asntech,项目名称:chilin,代码行数:7,代码来源:tex.py


示例10: _begin_latex

def _begin_latex(workflow, conf):
    attach_back(workflow,
        PythonCommand(
            latex_start,
            input={"template": latex_template},
            output={"latex": conf.latex_prefix + "_start.latex"},
            param={"id": conf.id}))
开发者ID:hanfeisun,项目名称:ChiLin2,代码行数:7,代码来源:ChiLin2.py


示例11: prepare_clean_up

def prepare_clean_up(workflow, conf):
    """
    package all the necessary results and delete temporary files
    """
    p_list = ['*.bam', '*.xls', '*_summits.bed', '*_peaks.bed', '*.bw',
              '*.png', '*.pdf', '*.R', '*.zip', '*cor*', 'json', "*summary*",
              "*seqpos","*fastqc", '*latex', "*.conf"]

    p_pattern = [os.path.join(conf.target_dir, p) for p in p_list]

    final_dir = conf.target_dir + '/dataset_' + conf.id
    attach_back(workflow,
        ShellCommand("if [ ! -d '{output}' ]; then mkdir -p {output}; fi",
            output=final_dir))

    for pf in p_pattern:
        if not glob(pf):
            print(pf)
            continue
        move = attach_back(workflow,
            ShellCommand('mv {param[preserve_files]} {output[dir]} \n# Pattern: {param[p_pattern]}',
                output={"dir": final_dir},
                param={"preserve_files": " ".join(glob(pf)),
                       "p_pattern": pf}, ))
        move.allow_fail = True
开发者ID:hanfeisun,项目名称:ChiLin2,代码行数:25,代码来源:ChiLin2.py


示例12: _seqpos_latex

def _seqpos_latex(workflow, conf):
    attach_back(workflow,
        PythonCommand(
            latex_seqpos,
            input={"json": conf.json_prefix + "_seqpos.json",
                   "template": latex_template},
            output={"latex": conf.latex_prefix + "_seqpos.latex"}))
开发者ID:hanfeisun,项目名称:ChiLin2,代码行数:7,代码来源:ChiLin2.py


示例13: _summary_table_latex

def _summary_table_latex(workflow, conf):
    attach_back(workflow,
        PythonCommand(
            latex_summary_table,
            input={"template": latex_template},
            output={"latex": conf.latex_prefix + "_summary_table.latex"},
            param={"conf": conf}))
开发者ID:hanfeisun,项目名称:ChiLin2,代码行数:7,代码来源:ChiLin2.py


示例14: contamination_check

def contamination_check(workflow, conf):
    """
    bowtie mapping back to different species
    """
    if conf.items("contamination"):
        for target in conf.sample_targets:
            for species in dict(conf.items("contamination")):
                index = conf.get("contamination", species)
                if conf.mapper == "bwa":
                    output = target + species + ".sam"
                    if conf.pe:
                        outsai = [target + species + "pair1.sai", target + species + "pair2.sai"]
                        targets = [ target + "pair1", target + "pair2" ]
                    else:
                        outsai = target + species + ".sai"
                        targets = target
                    bwa(workflow, conf, targets, output, outsai, index)
                elif conf.mapper == "bowtie":
                    output = target + species + ".sam"
                    bowtie(workflow, conf, target, output, index)
                elif conf.mapper == "star":
                    output = target + species + "Aligned.out.sam"
                    star(workflow, conf, target, output, index)

                sam2bam = attach_back(workflow,  ## use mapping quality 1 defined by samtools official FAQ
                            ShellCommand(
                                """
                                {tool} view -bS -t {param[genome]} -q {param[mapq]} {input[sam]} > {param[tmp_bam]} && {tool} sort -m {param[max_mem]} {param[tmp_bam]} {param[output_prefix]}
                                """,
                                tool="samtools",
                                input={"sam": output},
                                output={"bam":target + species + ".bam"},
                                param={"tmp_bam": target + species + ".tmp.bam", "output_prefix": target + species,
                                       "mapq": 1,
                                       "genome": conf.get(conf.get("basics", "species"), "chrom_len"),
                                       "max_mem": 4000000000},
                                name = "filtering mapping and convert")) # Use 5G memory as default

                sam2bam.update(param=conf.items("sam2bam"))
                sam2bam.allow_dangling = True
                sam2bam.allow_fail = True

                rem = attach_back(workflow, ShellCommand(
                """
                {tool} view -Sc {input[sam]} > {output[total]}
                {tool} flagstat {input[bam]} > {output[stat]}
                """,
                tool = "samtools",
                input = {"bam": target + species + ".bam",
                         "sam": output},
                output = {"stat": target + species + "_mapped." + conf.mapper,
                          "total": target + species + "_total." + conf.mapper},
                name = "contamination calculation"))
                rem.allow_fail = True
                rem.allow_dangling = True

        ## QC part
        stat_contamination(workflow, conf)
        if conf.long:
            tex_contamination(workflow, conf)
开发者ID:cfce,项目名称:chilin,代码行数:60,代码来源:dc.py


示例15: reg_potential

def reg_potential(workflow, conf):
    """

    """
    get_top_peaks = attach_back(workflow,
                                ShellCommand(
                                    "{tool} -n {param[peaks]} {input} | cut -f 1,2,3,4,9> {output}",
                                    tool="head",
                                    input=conf.prefix + "_sort_peaks.narrowPeak" if conf.get("macs2", "type") in ["both", "narrow"] else conf.prefix + "_b_sort_peaks.broadPeak",
                                    output=conf.prefix + "_peaks_top_reg.bed",
                                    param={"peaks": 10000},
                                    name="top summits for regpotential"))
    get_top_peaks.update(param=conf.items("reg_potential"))

    reg = attach_back(workflow,
                      ShellCommand(
                          "{tool} -t {input[peaks]} -g {param[geneTable]} -n {param[prefix]} -d {param[dist]}",
                          tool = "RegPotential.py",
                          input = {"peaks": conf.prefix + "_peaks_top_reg.bed"},
                          output = {"potential": conf.prefix + "_gene_score.txt"},
                          param = {"geneTable": conf.get_path(conf.get("basics", "species"), "geneTable"),
                                   "tool": resource_filename("chilin2.modules", "regulatory/RegPotential.py"),
                                   "prefix": conf.prefix,
                                   "dist": 100000},
                          name = "Regulatory Potential"))
    reg.update(param=conf.items("reg_potential"))
开发者ID:asntech,项目名称:chilin,代码行数:26,代码来源:dc.py


示例16: read_quality

def read_quality(workflow, conf, tex):
    if conf.pe:
        for raw, target in conf.treatment_pairs_pe:
            attach_back(workflow,
                        ShellCommand(
                            "{tool} {input[fastq][0]} {input[fastq][1]} {output[stat][0]} {output[stat][1]}",
                            tool = "dac_pe_read_quality",
                            input = {"fastq": raw},
                            output = {"stat": [ i + "_read_quality.qc" for i in target ]}))

        # attach_back(workflow, PythonCommand(stat_fastqStat,
        #                                     input = {"seq": [ [ p + "_100k.seq" for p in target ] for target in conf.treatment_pair_data ]},
        #                                     output = {"json": conf.json_prefix + "_seq_quality.json"},
        #                                     param = {"samples": conf.treatment_bases, "seq_type": conf.pe}))
        # attach_back(workflow, PythonCommand(
        #     seq_quality_doc,
        #     input = {"tex": tex, "json": conf.json_prefix + "_seq_quality.json"},
        #     output = {"seq": conf.latex_prefix + "seq_quality.tex", "len": conf.latex_prefix + "len.tex"},
        #     param = {"seq_type": conf.seq_type, "reps": len(conf.treatment_pairs),
        #              "pe_samples": conf.treatment_bases}))
    else:
        for raw, target in conf.treatment_pairs:
            sample_fq = {"stat": target + "_read_quality.qc"}
            attach_back(workflow,
                        ShellCommand(
                            "{tool} {input} {output[stat]}",
                            tool = "dac_se_read_quality",
                            input = raw,
                            output = sample_fq,
                            name = "100k read sequence quality and sequence length"))
开发者ID:asntech,项目名称:GCAP,代码行数:30,代码来源:sequence_quality.py


示例17: _macs2_cor

def _macs2_cor(workflow, conf):
    cor_on_bw = attach_back(workflow,
        ShellCommand(
            template=
            """{tool} \
            -s {param[wig_correlation_step]}  \
            --min-score {param[wig_correlation_min]} --max-score {param[wig_correlation_max]} \
            -r {output[R]} {param[bw]}  {param[rep]} && \
            mv {output[R]}.pdf {output[pdf]}""",
            tool="bigwig_correlation.py",
            input=[target + "_treat.bw" for target in conf.treatment_targets],
            output={"R": conf.prefix + "_cor.R", "pdf": conf.prefix + "_cor.pdf"},
            param={"wig_correlation_method": "mean",
                   "wig_correlation_min": 2,
                   "wig_correlation_max": 50,
                   "wig_correlation_step": 10,},
            name="cor_on_bw"))
    cor_on_bw.param["bw"] = " ".join(cor_on_bw.input)
    cor_on_bw.param["rep"] = " ".join([" -l replicate_%s" % (x + 1) for x in range(len(conf.treatment_pairs))])
    cor_on_bw.update(param=conf.items("correlation"))
    cor_on_bw.allow_fail = True

    attach_back(workflow,
        PythonCommand(
            stat_cor,
            input={"correlation_R": conf.prefix + "_cor.R",
                   "cor_pdf": conf.prefix + "_cor.pdf"},
            output={"json": conf.json_prefix + "_cor.json"}))
开发者ID:hanfeisun,项目名称:ChiLin2,代码行数:28,代码来源:ChiLin2.py


示例18: stat_fastqc

def stat_fastqc(workflow, conf):  # collect raw reads quality and GC contents
    """
    long: generate long pages or not
    """
    sums = []
    for raw, target in conf.sample_pairs:
        if conf.pe:
            sums.append(target[0] + "_100k_fastqc/fastqc_data.txt")
        else:
            sums.append(target + "_100k_fastqc/fastqc_data.txt")

    attach_back(workflow,
                PythonCommand(
                    json_fastqc,
                    input={"fastqc_summaries": sums},
                    output={"json": conf.json_prefix + "_fastqc.json"},
                    param={"ids": conf.sample_bases,
                           "id": conf.id},
                    name = "collect fastqc results"))
    
    if conf.long:  ## prepare long document images and tex
        attach_back(workflow,
        PythonCommand(fastqc_detailed_figure,
                      input = {"dbaccessor": resource_filename("chilin2.modules.dbaccessor", "ChiLinQC.db"),
                               "template": resource_filename("chilin2.modules.summary", "R_culmulative_plot.R"), 
                               "json": conf.json_prefix + "_fastqc.json"},
                      output = {"R": conf.prefix + "_raw_sequence_qc.R",
                                "pdf": conf.prefix + "_raw_sequence_qc.pdf"},
                      param={"ids": conf.sample_bases}))
开发者ID:asntech,项目名称:chilin,代码行数:29,代码来源:qc.py


示例19: _raw_QC_latex

def _raw_QC_latex(workflow, conf):
    attach_back(workflow,
        PythonCommand(
            latex_fastqc,
            input={"json": conf.json_prefix + "_fastqc.json",
                   "template": latex_template},
            output={"latex": conf.latex_prefix + "_fastqc.latex"}))
开发者ID:hanfeisun,项目名称:ChiLin2,代码行数:7,代码来源:ChiLin2.py


示例20: _bwa

def _bwa(workflow, conf):
    """
    incorpate ENCODE ChIP-seq alignment parameters
    """
    for raw, target in conf.treatment_pairs:
        param = {"threads": conf.threads,
                 "index":conf.get(conf.species, "genome_index"),
                 "prefix": target + "_raw_sorted",
                 "qc2": target + "_rawbam_stats.qc"}

        if conf.pe:
            bwa = attach_back(workflow, ShellCommand(
                "{tool} {param[threads]} {param[index]} {input[fastq][0]} {input[fastq][1]} {output[bam]} {output[qc]} {param[prefix]} {param[qc2]}",
                tool = "eap_run_bwa_pe",
                input = {"fastq": raw},
                output = {"bam": target + "_raw_sorted.bam", "qc": target + "_rawbam.qc"},
                param = param,
                name = "pair end mapping"))
        else:
            bwa = attach_back(workflow, ShellCommand(
                "{tool} {param[threads]} {param[index]} {input[fastq]} {output[bam]} {output[qc]} {param[prefix]} {param[qc2]}",
                tool = "eap_run_bwa_se",
                input = {"fastq": raw},
                output = {"bam": target + "_raw_sorted.bam", "qc": target + "_rawbam.qc"},
                param = param,
                name = "single end mapping"))
        bwa.update(param = conf.items("bwa"))
开发者ID:asntech,项目名称:GCAP,代码行数:27,代码来源:mapping.py



注:本文中的samflow.workflow.attach_back函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python saml2.class_name函数代码示例发布时间:2022-05-27
下一篇:
Python tests.delete_force函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap