PairedEndSingleSampleWf.gatk4.0.wdlをローカルで実行する
Google Cloud Platformで実行するためのワークフローPairedEndSingleSampleWf.gatk4.0.wdlをローカル環境で実行する
何を行うためのワークフローなのか?
Broad InstituteのGATK(Genome Analysis Tool Kit)を利用して、ヒトゲノムのショートリードから変異をコールするための一連のワークフローでGATK Best Practices (June 2016)に対応したもの
ワークフローの改変について
このワークフローをローカルで実行するため、次のような変更を施した
- bamのbasenameの取得部分を変更
- GATKを利用するtaskをDocker利用に変更
- GATKを利用するcallの入力ファイル指定を String から File に変更
- GATKを利用するtaskのoutput部分でbaiファイルを取得するよう追記
- GATKをcallする部分のinput部分でbaiファイルを利用するよう追記
- task失敗時に再試行するようにruntimeに追記
bamのbasenameの取得部分を変更
Google Cloudのストレージを利用にないので、bamのベースネームを取得する部分を変更
GATKを利用するtaskをDocker利用に変更
taskの定義部分でgatk を /gatk/gatk
で実行している
これは、Google Cloud Platform上の仮想マシンが "docker": "broadinstitute/gatk:4.0.0.0"を指定している事によるもの
ローカル環境では、当然/gatk/gatk
などというところにgatkが無いのでそのままでは動作しない
そこで、gatkを利用するtaskをdockerを利用するように変更する
GATKを利用するcallの入力ファイル指定を String から File に変更
Docker内でマウントしているマウントポイントに必要なファイルが存在するようにするための処理
この記述を変更することでDocker内から指定のbamを参照できるようにする
このような記載になっている理由について PairedEndSingleSampleWf.mdに次のように記載されている
Use of Google NIO
Several tasks in this workflow use the NIO Filesystem Provider for GCS, which makes it specific to the Google Cloud platform. This manifests as inputs that would normally be typed as a
File
being typed as aString
instead, in tasks that call GATK4 tools (BaseRecalibrator, ApplyBQSR, and HaplotypeCaller). Setting the input type toString
means the file doesn’t get localized, but GATK4 knows how to deal with a gs:// path. IMPORTANT: This does not work outside of GCP, because either the other cloud providers don't have an equivalent streaming library like Google's NIO, or GATK4 doesn't know about them. To run this elsewhere you would need to switch the type of those inputs toFile
and adjust the disk autosizing to expect a full file instead of a slice (namely remove the denominator in the calculation).
GATKを利用するtaskのoutput部分でbaiファイルを取得するよう追記
GATKの一連の処理ではbamファイルとそのindexファイル(bai)が必要
taskのoutput部分にbaiファイルを出力項目として追記
GATKをcallする部分のinput部分でbaiファイルを利用するよう追記
callのinput:部分にbamに対応するindexファイルを入力項目として追記
これによりtask実行時、Docker内部からindexファイルが参照できる
task失敗時に再試行するようにruntimeに追記
docker run
がうまく動作せず、ワークフローがストールする事象に遭遇したことから、taskを再試行させるため maxRetries
を設定
上記全ての変更を施した結果の差分
115c115,118
< String sub_sub = sub(sub(unmapped_bam, sub_strip_path, ""), sub_strip_unmapped, "")
---
> # Following line is for Cloud only
> # String sub_sub = sub(sub(unmapped_bam, sub_strip_path, ""), sub_strip_unmapped, "")
> # Modified to run locally
> String sub_sub = basename(unmapped_bam, unmapped_bam_suffix)
245a249
> input_bam_index = SortSampleBam.output_bam_index,
275a280
> input_bam_index = SortSampleBam.output_bam_index,
442a448
> input_bam_index = GatherBamFiles.output_bam_index,
791a798
> maxRetries: 3
836a844
> maxRetries: 3
1020c1028,1029
< String input_bam
---
> File input_bam
> File input_bam_index
1049a1059
> docker: "docker.io/broadinstitute/gatk"
1058c1068,1069
< String input_bam
---
> File input_bam
> File input_bam_index
1087a1099
> docker: "docker.io/broadinstitute/gatk"
1090a1103
> File recalibrated_bai = "${output_bam_basename}.bai"
1111a1125
> docker: "docker.io/broadinstitute/gatk"
1113c1127
< output {
---
> output {
1445c1459,1460
< String input_bam
---
> File input_bam
> File input_bam_index
1487a1503
> maxRetries: 3
1549a1566
> docker: "docker.io/broadinstitute/gatk"
一度書けばどこでも動作するのが理想だけれど、なかなか実現は難しい...
今回はここまで