乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      snakemake 學(xué)習(xí)筆記1

       育種數(shù)據(jù)分析 2021-11-18
      snakemake是一個(gè)寫流程的工具, 功能非常強(qiáng)大, 特別是針對(duì)批量化處理時(shí), 效率很高, 而且語法非常人性化, 下面是一個(gè)簡(jiǎn)單的示例, 介紹怎么用snakemake書寫自己的第一個(gè)程序. 

      1, snakemake介紹

      Snakemake是用Python3寫的一個(gè)流程化工具, 非常方便. 官網(wǎng)上的例子有點(diǎn)難度, 這里用最簡(jiǎn)單的案例解釋一下snakemake的應(yīng)用方法.
      安裝方法

      easy_install3 snakemake

      或者:

      pip3 install snakemake

      也可以從源文件安裝:

      git clone https:///snakemake/snakemake.git
      cd snakemake
      virtualenv -p python3 .venv
      source .venv/bin/activate
      python setup.py install

      2, 一個(gè)簡(jiǎn)單的案例

      思路:

      • 1, 生成一個(gè)1.txt文件

      • 2, 生成一個(gè)2.txt文件

      • 3, 使用cat命令, 將兩者合并為hebing.txt

      echo "hello number1" >1.txt
      echo "hello number2" >2.txt
      cat 1.txt 2.txt
      cat 1.txt 2.txt >hebing.txt

      3, 生成snakemake腳本

      生成一個(gè)名為:Snakemake的文件

      (base) [dengfei@localhost example]$ cat Snakefile
      rule test_cat:
      input:
      "1.txt",
      "2.txt"
      output:
      "hebing.txt"
      shell:
      "cat {input} >> {output}"

      這里有四個(gè)參數(shù):

      • rule: 是名稱, 這里命名為test_cat

      • Input: 輸入文件, 這里是”1.txt”, “2.txt”

      • Output: 輸出文件, 這里是”hebing.txt”

      • Shell: 這里是要執(zhí)行的腳本, 輸入文件是{input}, 輸出文件是{output}

      4, snakemake -np

      使用-np查看轉(zhuǎn)化后的命令

      (base) [dengfei@localhost example]$ snakemake -np

      rule test_cat:
      input: 1.txt, 2.txt
      output: hebing.txt
      jobid: 0

      cat 1.txt 2.txt >> hebing.txt
      Job counts:
      count jobs
      1 test_cat
      1

      5, 執(zhí)行命令 snakemake

      snakemake默認(rèn)執(zhí)行的文件名是: Snakemake, 如果想要指定自己編寫的文件名, 可以加上參數(shù): —snakefile
      比如: 文件名為a.snake

      snakemake --snakefile a.snake

      如果文件名是默認(rèn)的Snakemake, 不用加參數(shù), 直接運(yùn)行snakemake即可直接執(zhí)行.

      (base) [dengfei@localhost example]$ snakemake
      Provided cores: 1
      Rules claiming more threads will be scaled down.
      Job counts:
      count jobs
      1 test_cat
      1

      rule test_cat:
      input: 1.txt, 2.txt
      output: hebing.txt
      jobid: 0

      Finished job 0.
      1 of 1 steps (100%) done

      查看結(jié)果:

      (base) [dengfei@localhost example]$ cat hebing.txt
      hello number1
      hello number2

      可以看到, 使用snakemake, 成功的將1.txt 和2.txt 合并為hebing.txt.

      6, 運(yùn)行成功, 重新運(yùn)行時(shí)

      顯示Nothing to be done, 即不會(huì)執(zhí)行.

      (base) [dengfei@localhost example]$ snakemake
      Nothing to be done.

      如果heibng.txt文件被刪掉了, 再執(zhí)行, 就會(huì)重新執(zhí)行.

      這是一小步, 也是一大步.

        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多