

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# HealthOmics ワークフロー定義のタスク出力
<a name="workflows-task-outputs"></a>

ワークフロー定義でタスク出力を指定します。デフォルトでは、ワークフローが完了すると HealthOmics はすべての中間タスクファイルを破棄します。中間ファイルをエクスポートするには、出力として定義します。

コールキャッシュを使用する場合、HealthOmics は出力として定義した中間ファイルを含め、タスク出力をキャッシュに保存します。

以下のトピックでは、各ワークフロー定義言語のタスク定義の例を示します。

**Topics**
+ [WDL のタスク出力](#workflow-task-outputs-wdl)
+ [Nextflow のタスク出力](#workflow-task-outputs-nextflow)
+ [CWL のタスク出力](#workflow-task-outputs-cwl)

## WDL のタスク出力
<a name="workflow-task-outputs-wdl"></a>

WDL で記述されたワークフロー定義については、最上位のワークフロー**outputs**セクションで出力を定義します。

Omics

**Topics**
+ [STDOUT のタスク出力](#task-outputs-wdl-stdout)
+ [STDERR のタスク出力](#task-outputs-wdl-stderr)
+ [ファイルへのタスク出力](#task-outputs-wdl-file)
+ [ファイルの配列へのタスク出力](#task-outputs-wdl-files)

### STDOUT のタスク出力
<a name="task-outputs-wdl-stdout"></a>

この例では、STDOUT コンテンツをタスク出力ファイルにエコー`SayHello`する という名前のタスクを作成します。WDL **stdout**関数は、STDOUT コンテンツ (この例では、入力文字列 **Hello World\$1**) をファイル にキャプチャします**stdout\$1file**。

HealthOmics はすべての STDOUT コンテンツのログを作成するため、出力はタスクの他の STDERR ログ情報とともに CloudWatch Logs にも表示されます。

```
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 のタスク出力
<a name="task-outputs-wdl-stderr"></a>

この例では、STDERR コンテンツをタスク出力ファイルにエコー`SayHello`する という名前のタスクを作成します。WDL **stderr**関数は、STDERR コンテンツ (この例では、入力文字列 **Hello World\$1**) をファイル にキャプチャします**stderr\$1file**。

HealthOmics はすべての STDERR コンテンツのログを作成するため、出力はタスクの他の STDERR ログ情報とともに CloudWatch Logs に表示されます。

```
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()
    }
}
```

### ファイルへのタスク出力
<a name="task-outputs-wdl-file"></a>

この例では、SayHello タスクは 2 つのファイル (message.txt と info.txt) を作成し、これらのファイルを名前付き出力 (message\$1file と info\$1file) として明示的に宣言します。

```
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"
    } 
}
```

### ファイルの配列へのタスク出力
<a name="task-outputs-wdl-files"></a>

この例では、`GenerateGreetings`タスクはファイルの配列をタスク出力として生成します。タスクは、入力配列 のメンバーごとに 1 つの挨拶ファイルを動的に生成します`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 のタスク出力
<a name="workflow-task-outputs-nextflow"></a>

Nextflow で記述されたワークフロー定義の場合、タスクコンテンツを出力 Amazon S3 バケットにエクスポートする **publishDir** ディレクティブを定義します。**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 のタスク出力
<a name="workflow-task-outputs-cwl"></a>

CWL で記述されたワークフロー定義では、タスクを使用して`CommandLineTool`タスク出力を指定できます。以下のセクションでは、さまざまなタイプの出力を定義する`CommandLineTool`タスクの例を示します。

**Topics**
+ [STDOUT のタスク出力](#task-outputs-cwl-stdout)
+ [STDERR のタスク出力](#task-outputs-cwl-stderr)
+ [ファイルへのタスク出力](#task-outputs-cwl-file)
+ [ファイルの配列へのタスク出力](#task-outputs-cwl-files)

### STDOUT のタスク出力
<a name="task-outputs-cwl-stdout"></a>

この例では、STDOUT コンテンツを という名前のテキスト出力ファイルにエコーする`CommandLineTool`タスクを作成します**output.txt**。たとえば、次の入力を指定すると、結果のタスク出力は **output.txt** ファイル内の **Hello World\$1** になります。

```
{
    "message": "Hello World!"
}
```

`outputs` ディレクティブは、出力名を **example\$1out**に、タイプを に指定します`stdout`。ダウンストリームタスクがこのタスクの出力を消費するには、出力を と呼びます`example_out`。

HealthOmics はすべての STDERR および STDOUT コンテンツのログを作成するため、出力はタスクの他の STDERR ログ情報とともに CloudWatch Logs にも表示されます。

```
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 のタスク出力
<a name="task-outputs-cwl-stderr"></a>

この例では、STDERR コンテンツを という名前のテキスト出力ファイルにエコーする`CommandLineTool`タスクを作成します**stderr.txt**。タスクは、 が (STDOUT ではなく) STDERR に`echo`書き込む`baseCommand`ように を変更します。

`outputs` ディレクティブは、出力名を **stderr\$1out**に、タイプを に指定します`stderr`。

HealthOmics はすべての STDERR および STDOUT コンテンツのログを作成するため、出力はタスクの他の STDERR ログ情報とともに CloudWatch Logs に表示されます。

```
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
```

### ファイルへのタスク出力
<a name="task-outputs-cwl-file"></a>

この例では、入力ファイルから圧縮された tar アーカイブを作成する`CommandLineTool`タスクを作成します。アーカイブの名前を入力パラメータ (archive\$1name) として指定します。

**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
```

### ファイルの配列へのタスク出力
<a name="task-outputs-cwl-files"></a>

この例では、`CommandLineTool`タスクは `touch` コマンドを使用してファイルの配列を作成します。コマンドは、`files-to-create`入力パラメータの文字列を使用してファイルに名前を付けます。コマンドはファイルの配列を出力します。配列には、`glob`パターンに一致する作業ディレクトリ内のすべてのファイルが含まれます。この例では、すべてのファイルに一致するワイルドカードパターン (「\$1」) を使用しています。

```
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
```