執行 dsub

使用 dsub 編寫指令碼,然後在 Google Cloud上執行批次運算工作和工作流程。

目標

完成本教學課程後,您將瞭解如何在 Google Cloud 上執行 dsub 管道,從 DNA 序列的大型二進位檔案 (BAM 檔案) 建立索引 (BAI 檔案)。

費用

在本文件中,您會使用 Google Cloud的下列計費元件:

  • Compute Engine
  • Cloud Storage

如要根據預測用量估算費用,請使用 Pricing Calculator

初次使用 Google Cloud 的使用者可能符合免費試用資格。

事前準備

  1. 安裝 Python 3.6 以上版本。如要進一步瞭解如何設定 Python 開發環境,例如在系統上安裝 pip,請參閱 Python 開發環境設定指南
  2. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  3. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  4. Make sure that billing is enabled for your Google Cloud project.

  5. Enable the Cloud Life Sciences, Compute Engine, and Cloud Storage APIs.

    Enable the APIs

  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  7. Make sure that billing is enabled for your Google Cloud project.

  8. Enable the Cloud Life Sciences, Compute Engine, and Cloud Storage APIs.

    Enable the APIs

  9. 建立 BAI 檔案

    完成下列步驟,從 DNA 序列的大型二進位檔案 (BAM 檔案) 建立索引 (BAI 檔案)。資料來源為 1,000 種基因體專案

    1. 複製 databiosphere/dsub GitHub 存放區:

      git clone https://github.com/databiosphere/dsub.git
    2. 切換至 dsub 工具的目錄。存放區包含預先建構的 Docker 映像檔,該映像檔使用 samtools 執行索引。

      cd dsub
    3. 安裝 dsub 及其依附元件:

      sudo python3 setup.py install
    4. 執行 dsub 工具建立 BAI 檔案,並將 PROJECT_ID 替換為您的 Google Cloud 專案,將 BUCKET 替換為您有權寫入的 Cloud Storage 值區:

      dsub \
          --provider google-cls-v2 \
          --project PROJECT_ID \
          --logging gs://BUCKET/logs \
          --input BAM=gs://genomics-public-data/1000-genomes/bam/HG00114.mapped.ILLUMINA.bwa.GBR.low_coverage.20120522.bam \
          --output BAI=gs://BUCKET/HG00114.mapped.ILLUMINA.bwa.GBR.low_coverage.20120522.bam.bai \
          --image quay.io/cancercollaboratory/dockstore-tool-samtools-index \
          --command 'samtools index ${BAM} ${BAI}' \
          --wait

      samtools 指令會對 --input 標記提供的資料檔案執行。管道會將輸出檔案與記錄寫入 Cloud Storage 值區。

    5. 確認是否已產生 BAI 檔案:

      gcloud storage ls gs://BUCKET
      

      指令會傳回下列回應:

      gs://BUCKET/HG00114.mapped.ILLUMINA.bwa.GBR.low_coverage.20120522.bam.bai
      

    清除所用資源

    完成教學課程後,您可以清除所建立的資源,這樣資源就不會繼續使用配額,也不會產生費用。下列各節將說明如何刪除或關閉這些資源。

    刪除專案

    如要避免付費,最簡單的方法就是刪除您為了本教學課程所建立的專案。

    如要刪除專案:

    1. In the Google Cloud console, go to the Manage resources page.

      Go to Manage resources

    2. In the project list, select the project that you want to delete, and then click Delete.
    3. In the dialog, type the project ID, and then click Shut down to delete the project.

    後續步驟

    如要進一步瞭解如何使用 dsub 在本機開發,或使用 dsub 在 Google Cloud上擴大執行多項工作,請參閱 GitHub 中的 dsub 說明文件