5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Nextflow を使ってみる

Last updated at Posted at 2019-06-28

Nextflow

動作した場所

  • Mac
  • Linux
  • Windows WSL 1 でも動いた

Nextflow syntax highlighter

Atom

VSCode

20190628_nextflow_vscode_extension_install.png

その他

nextflow は、 groovy の派生のため
nextflow のシンタックスハイライターがない環境では、
groovy のハイライターを使うという手もある。

nextflow を使ってみよう

インストールなど

  1. Javaの8以降をいれておく
  2. curl -s https://get.nextflow.io | bash
  3. ./nextflow run hello

ダウンロードしているときのログなど

ダウンロードすると、
依存するjavaライブラリをダウンロードしているっぽいログがでてきて
最終的に動く環境がてにはいる

いろいろデータは、 ~/.nextflow に入るようである。

インストールおわったときの、ログ

CAPSULE: Downloading dependency commons-codec:commons-codec:jar:1.10

N E X T F L O W
version 19.04.1 build 5072
last modified 03-05-2019 12:29 UTC (21:29 JDT)
cite doi:10.1038/nbt.3820
http://nextflow.io


Nextflow installation completed. Please note:
- the executable file `nextflow` has been created in the folder: /Users/manabu/work/nextflow
- you may complete the installation by moving it to a directory in your $PATH

はじめてのコマンド実行

$ ./nextflow run hello
N E X T F L O W  ~  version 19.04.1
Pulling nextflow-io/hello ...
downloaded from https://github.com/nextflow-io/hello.git
Launching `nextflow-io/hello` [high_mayer] - revision: a9012339ce [master]
[warm up] executor > local
executor >  local (4)
[27/9839a3] process > sayHello [100%] 4 of 4 ✔
Ciao world!

Bonjour world!

Hola world!

Hello world!

Completed at: 28-Jun-2019 11:11:33
Duration    : 1.1s
CPU hours   : (a few seconds)
Succeeded   : 4
$  nextflow file nextflow
nextflow: Bourne-Again shell script text executable, ASCII text

のサンプルを、example1.nf として、保存する

$  nextflow ./nextflow example1.nf
N E X T F L O W  ~  version 19.04.1
Launching `example1` [suspicious_yalow] - revision: 3c1734c90b
[warm up] executor > local
executor >  local (1)
[ab/9776d1] process > splitSequences [  0%] 0 of 1
ERROR ~ Error executing process > 'splitSequences'

executor >  local (1)
[ab/9776d1] process > splitSequences [100%] 1 of 1, failed: 1 ✘
ERROR ~ Error executing process > 'splitSequences'

Caused by:
  Process `splitSequences` terminated with an error exit status (1)

Command executed:

  awk '/^>/{f="seq_"++d} {print > f}' < input.fa

Command exit status:
  1

Command output:
  (empty)

Command error:
  .command.sh: line 2: input.fa: No such file or directory

Work dir:
  /Users/manabu/work/nextflow/work/ab/9776d1a5bb20bbd2415b237cfda7d7

Tip: view the complete command output by changing to the process work dir and entering the command `cat .command.out`

 -- Check '.nextflow.log' file for details

FASTA - Wikipedia

>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
IENY

失敗したときのエラーを

入力ファイルを、デフォルトに合わせる

$ mv data/input.fa data/sample.fa

実行する。

  • 分解(split)したものは、ファイルに出力されて
  • 反転させたものは、標準出力に出力される
$  ./nextflow example1.nf
N E X T F L O W  ~  version 19.04.1
Launching `example1` [nauseous_mirzakhani] - revision: 3c1734c90b
[warm up] executor > local
executor >  local (2)
[43/3398fe] process > splitSequences [100%] 1 of 1 ✔
[3b/5a7487] process > reverse        [  0%] 0 of 1
]sumixam sumixam sahpelE[ b emorhcotyc |1.66144DAA|bg|1124255|ig>
VLNTGIYPIASFLNTIVTAGWFSMQGWPLVYGMFATAMTILLLMIGTNWTESYLYSGYYINRGIHTYLCL
GLFDKITYYPHFPIKDSDSTLGLPNNSGTEHLFTLHVGALAVMTFPLIFHFAFFRNLTAKDVSFGGWIWE
LIVISLFLALVGGLKNPVSRLIAYAFLFYWEPKIHLPTNLPDAPMHNDPDGLMDPSLLALLLLLLILILL
executor >  local (2)
[43/3398fe] process > splitSequences [100%] 1 of 1 ✔
[3b/5a7487] process > reverse        [100%] 1 of 1 ✔
Completed at: 28-Jun-2019 11:20:22
Duration    : 1.1s
CPU hours   : (a few seconds)
Succeeded   : 2
$ ./nextflow example1.nf
N E X T F L O W  ~  version 19.04.1
Launching `example1` [maniac_poisson] - revision: 3c1734c90b
[warm up] executor > local
executor >  local (2)
[ac/3e7150] process > splitSequences [100%] 1 of 1 ✔
[c4/de9f8e] process > reverse        [  0%] 0 of 1
]sumixam sumixam sahpelE[ b emorhcotyc |1.66144DAA|bg|1124255|ig>
VLNTGIYPIASFLNTIVTAGWFSMQGWPLVYGMFATAMTILLLMIGTNWTESYLYSGYYINRGIHTYLCL
GLFDKITYYPHFPIKDSDSTLGLPNNSGTEHLFTLHVGALAVMTFPLIFHFAFFRNLTAKDVSFGGWIWE
LIVISLFLALVGGLKNPVSRLIAYAFLFYWEPKIHLPTNLPDAPMHNDPDGLMDPSLLALLLLLLILILL
executor >  local (2)
[ac/3e7150] process > splitSequences [100%] 1 of 1 ✔
[c4/de9f8e] process > reverse        [100%] 1 of 1 ✔
Completed at: 28-Jun-2019 11:21:10
Duration    : 1.1s
CPU hours   : (a few seconds)
Succeeded   : 2

FASTA format - Wikipedia
より、以下の配列を、data/sample2.fa として保存

>MCHU - Calmodulin - Human, rabbit, bovine, rat, and chicken
ADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMINEVDADGNGTID
FPEFLTMMARKMKDTDSEEEIREAFRVFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIREA
DIDGDGQVNYEEFVQMMTAK*

>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
IENY

入力ファイルを変更してみる

$ ./nextflow example1.nf --in=data/sample2.fa

work の下に、データがでてきている

seq-1
seq-2
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?