

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 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** 섹션에서 출력을 정의합니다.

HealthOmics

**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 작업은 두 개의 파일(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` 작업은 파일 배열을 작업 출력으로 생성합니다. 작업은 입력 배열의 각 멤버에 대해 하나의 인사말 파일을 동적으로 생성합니다`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에 작성된 워크플로 정의의 경우 **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에 대한 작업 출력
<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
```