LoginSignup
2
1

More than 3 years have passed since last update.

CWLでblastをかける

Posted at

CWL初級者にとってよく詰まる部分にfileの入出力がある。

python hogehoge.py -in infile -out outfile

のようにコマンドラインで指定するようなシンプルな場合は簡単だが、入力ファイルがちょっと特殊な場合一気に難しくなる。

生物学分野では広く使われるblastだが、blastではindexファイルを以下のように指定する。

blastn -query hoge.fasta -db huga.fasta

ここで注意しなければいけないのはhuga.fastaの部分で、blastを走らせるためには huga.fasta だけでなく makeblastdb コマンドで作った以下のようなindexファイルをhuga.fastaを同じディレクトリに用意する必要がある。

huga.fasta
huga.fasta.nsd
huga.fasta.nsi
huga.fasta.nhd
huga.fasta.nhi
huga.fasta.nhr
huga.fasta.nin

CWLではホスト側のデータは明示的に読み込まないとマウントしてくれないため、単にhuga.fastaだけinputしてもindexファイルが見つかりませんと言われてしまう。

色々試行錯誤した結果、NCBIのPGAPパイプラインに参考となる記法が見つかったのでそれを参考にした。

blast.cwl
cwlVersion: v1.0
class: CommandLineTool
baseCommand: /root/ncbi-blast-2.10.0+/bin/blastn
requirements:
  - class: InitialWorkDirRequirement
    listing:
      - entry: $(inputs.blastdb_dir)
        writable: False

inputs:
  blastdb_dir:
    type: Directory?
  blastdb:
    type: string?
    inputBinding:
      prefix: -db
      valueFrom: $(inputs.blastdb_dir.path)/$(inputs.blastdb)
  blastinput:
    type: File
    inputBinding:
      prefix: -query
  outfmt:
    type: string
    inputBinding:
      prefix: -outfmt 
  outfile:
    type: string
    inputBinding:
      prefix: -out 
  evalue:
    type: string
    inputBinding:
      prefix: -evalue
  max_target_seqs:
    type: string
    inputBinding:
      prefix: -max_target_seqs
  num_threads:
    type: string
    inputBinding:
      prefix: -num_threads

outputs:
  blast_out:
    type: File
    outputBinding:
      glob: blast_result.tsv

InitialWorkDirRequirement でディレクトリをワークフロー実行時にマウントしているのがポイント。
@manabuishiirb さんのエントリとかをみると InitialWorkDirRequirement

あくまで ステージング用途で使うものである。
ホスト側のディレクトリを、ワークフロー実行時にマウントするという用途のためにあるわけではない。

とか書いてあるのでもっとスマートな書き方があるのかもしれない。

2
1
4

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
2
1