HealthOmics 工作流程定義中的任務輸出 - AWS HealthOmics

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

HealthOmics 工作流程定義中的任務輸出

您可以在工作流程定義中指定任務輸出。根據預設,HealthOmics 會在工作流程完成時捨棄所有中繼任務檔案。若要匯出中繼檔案,請將其定義為輸出。

如果您使用呼叫快取,HealthOmics 會將任務輸出儲存到快取,包括您定義為輸出的任何中繼檔案。

下列主題包含每個工作流程定義語言的任務定義範例。

WDL 的任務輸出

對於以 WDL 撰寫的工作流程定義,請在最上層工作流程outputs區段中定義輸出。

HealthOmics

STDOUT 的任務輸出

此範例會建立名為 的任務SayHello,將 STDOUT 內容回應至任務輸出檔案。WDL stdout函數會擷取檔案 中的 STDOUT 內容 (在此範例中為 Hello World! 輸入字串)stdout_file

由於 HealthOmics 會為所有 STDOUT 內容建立日誌,因此輸出也會出現在 CloudWatch Logs 中,以及任務的其他 STDERR 記錄資訊。

version 1.0 workflow HelloWorld { input { String message = "Hello, World!" String ubuntu_container = "123456789012.dkr.ecr.us-east-1.amazonaws.com/dockerhub/library/ubuntu:20.04" } call SayHello { input: message = message, container = ubuntu_container } output { File stdout_file = SayHello.stdout_file } } task SayHello { input { String message String container } command <<< echo "~{message}" echo "Current date: $(date)" echo "This message was printed to STDOUT" >>> runtime { docker: container cpu: 1 memory: "2 GB" } output { File stdout_file = stdout() } }

STDERR 的任務輸出

此範例會建立名為 的任務SayHello,將 STDERR 內容回應至任務輸出檔案。WDL stderr函數會擷取檔案 中的 STDERR 內容 (在此範例中為 Hello World! 輸入字串)stderr_file

由於 HealthOmics 會為所有 STDERR 內容建立日誌,因此輸出會出現在 CloudWatch Logs 中,以及任務的其他 STDERR 記錄資訊。

version 1.0 workflow HelloWorld { input { String message = "Hello, World!" String ubuntu_container = "123456789012.dkr.ecr.us-east-1.amazonaws.com/dockerhub/library/ubuntu:20.04" } call SayHello { input: message = message, container = ubuntu_container } output { File stderr_file = SayHello.stderr_file } } task SayHello { input { String message String container } command <<< echo "~{message}" >&2 echo "Current date: $(date)" >&2 echo "This message was printed to STDERR" >&2 >>> runtime { docker: container cpu: 1 memory: "2 GB" } output { File stderr_file = stderr() } }

任務輸出至檔案

在此範例中,SayHello 任務會建立兩個檔案 (message.txt 和 info.txt),並明確將這些檔案宣告為具名輸出 (message_file 和 info_file)。

version 1.0 workflow HelloWorld { input { String message = "Hello, World!" String ubuntu_container = "123456789012.dkr.ecr.us-east-1.amazonaws.com/dockerhub/library/ubuntu:20.04" } call SayHello { input: message = message, container = ubuntu_container } output { File message_file = SayHello.message_file File info_file = SayHello.info_file } } task SayHello { input { String message String container } command <<< # Create message file echo "~{message}" > message.txt # Create info file with date and additional information echo "Current date: $(date)" > info.txt echo "This message was saved to a file" >> info.txt >>> runtime { docker: container cpu: 1 memory: "2 GB" } output { File message_file = "message.txt" File info_file = "info.txt" } }

檔案陣列的任務輸出

在此範例中,GenerateGreetings任務會產生一組檔案做為任務輸出。任務會為輸入陣列 的每個成員動態產生一個問候語檔案names。由於檔案名稱在執行時間之前是未知的,因此輸出定義會使用 WDL glob() 函數來輸出符合模式 的所有檔案*_greeting.txt

version 1.0 workflow HelloArray { input { Array[String] names = ["World", "Friend", "Developer"] String ubuntu_container = "123456789012.dkr.ecr.us-east-1.amazonaws.com/dockerhub/library/ubuntu:20.04" } call GenerateGreetings { input: names = names, container = ubuntu_container } output { Array[File] greeting_files = GenerateGreetings.greeting_files } } task GenerateGreetings { input { Array[String] names String container } command <<< # Create a greeting file for each name for name in ~{sep=" " names}; do echo "Hello, $name!" > ${name}_greeting.txt done >>> runtime { docker: container cpu: 1 memory: "2 GB" } output { Array[File] greeting_files = glob("*_greeting.txt") } }

Nextflow 的任務輸出

對於以 Nextflow 編寫的工作流程定義,請定義 publishDir 指令,將任務內容匯出到您的輸出 Amazon S3 儲存貯體。將 publishDir 值設定為 /mnt/workflow/pubdir

若要讓 HealthOmics 將檔案匯出至 Amazon S3,檔案必須位於此目錄中。

如果任務產生一組輸出檔案,做為後續任務的輸入,建議您將這些檔案分組在 目錄中,並將該目錄發出為任務輸出。列舉每個個別檔案可能會導致基礎檔案系統中的 I/O 瓶頸。例如:

process my_task { ... // recommended output "output-folder/", emit: output // not recommended // output "output-folder/**", emit: output ... }

CWL 的任務輸出

對於以 CWL 編寫的工作流程定義,您可以使用任務指定CommandLineTool任務輸出。下列各節顯示定義不同輸出類型的CommandLineTool任務範例。

STDOUT 的任務輸出

此範例會建立將 STDOUT 內容回應至名為 的文字輸出檔案CommandLineTool的任務output.txt。例如,如果您提供下列輸入,則產生的任務輸出在 output.txt 檔案中為 Hello World!

{ "message": "Hello World!" }

outputs 指令指定輸出名稱為 ,example_out其類型為 stdout。若要讓下游任務消耗此任務的輸出,它會將輸出稱為 example_out

由於 HealthOmics 會為所有 STDERR 和 STDOUT 內容建立日誌,因此輸出也會出現在 CloudWatch Logs 中,以及任務的其他 STDERR 日誌記錄資訊。

cwlVersion: v1.2 class: CommandLineTool baseCommand: echo stdout: output.txt inputs: message: type: string inputBinding: position: 1 outputs: example_out: type: stdout requirements: DockerRequirement: dockerPull: 123456789012.dkr.ecr.us-east-1.amazonaws.com/dockerhub/library/ubuntu:20.04 ResourceRequirement: ramMin: 2048 coresMin: 1

STDERR 的任務輸出

此範例會建立將 STDERR 內容回應至名為 的文字輸出檔案CommandLineTool的任務stderr.txt。任務會修改 ,baseCommandecho寫入 STDERR (而非 STDOUT)。

outputs 指令指定輸出名稱為 ,stderr_out其類型為 stderr

由於 HealthOmics 會為所有 STDERR 和 STDOUT 內容建立日誌,因此輸出會出現在 CloudWatch Logs 中,以及任務的其他 STDERR 日誌記錄資訊。

cwlVersion: v1.2 class: CommandLineTool baseCommand: [bash, -c] stderr: stderr.txt inputs: message: type: string inputBinding: position: 1 shellQuote: true valueFrom: "echo $(self) >&2" outputs: stderr_out: type: stderr requirements: DockerRequirement: dockerPull: 123456789012.dkr.ecr.us-east-1.amazonaws.com/dockerhub/library/ubuntu:20.04 ResourceRequirement: ramMin: 2048 coresMin: 1

任務輸出至檔案

此範例會建立從輸入檔案建立壓縮 tar 封存CommandLineTool的任務。您提供封存的名稱做為輸入參數 (archive_name)。

outputs 指令指定archive_file輸出類型為 File,並使用輸入參數的參考archive_name繫結至輸出檔案。

cwlVersion: v1.2 class: CommandLineTool baseCommand: [tar, cfz] inputs: archive_name: type: string inputBinding: position: 1 input_files: type: File[] inputBinding: position: 2 outputs: archive_file: type: File outputBinding: glob: "$(inputs.archive_name)" requirements: DockerRequirement: dockerPull: 123456789012.dkr.ecr.us-east-1.amazonaws.com/dockerhub/library/ubuntu:20.04 ResourceRequirement: ramMin: 2048 coresMin: 1

檔案陣列的任務輸出

在此範例中,CommandLineTool任務會使用 touch命令建立檔案陣列。命令會使用files-to-create輸入參數中的字串來命名檔案。命令會輸出一組檔案。陣列包含工作目錄中符合 glob 模式的任何檔案。此範例使用符合所有檔案的萬用字元模式 ("*")。

cwlVersion: v1.2 class: CommandLineTool baseCommand: touch inputs: files-to-create: type: type: array items: string inputBinding: position: 1 outputs: output-files: type: type: array items: File outputBinding: glob: "*" requirements: DockerRequirement: dockerPull: 123456789012.dkr.ecr.us-east-1.amazonaws.com/dockerhub/library/ubuntu:20.04 ResourceRequirement: ramMin: 2048 coresMin: 1