问题我如何创建并导入我自己的自定义类型到CWL描述中?目标学习如何编写自定义CWL对象类型。学习如何将这些自定义对象导入工具描述。
有时,您可能希望编写自己的自定义类型,以便在CWL描述中使用和重用。使用这种自定义类型可以减少多个使用相同类型的描述之间的冗余,并且允许额外的自定义/配置工具/分析,而不需要直接处理CWL描述。
下面的示例是biom convert format工具的CWL描述,用于将标准的biom表文件转换为hd5格式。
custom-types.cwl
#!/usr/bin/env cwl-runnercwlVersion: v1.0class: CommandLineToolrequirements:InlineJavascriptRequirement: {}ResourceRequirement:coresMax: 1ramMin: 100 # just a default, could be loweredSchemaDefRequirement:types:- $import: biom-convert-table.yamlhints:DockerRequirement:dockerPull: 'quay.io/biocontainers/biom-format:2.1.6--py27_0'SoftwareRequirement:packages:biom-format:specs: [ "https://doi.org/10.1186/2047-217X-1-7" ]version: [ "2.1.6" ]inputs:biom:type: Fileformat: edam:format_3746 # BIOMinputBinding:prefix: --input-fptable_type:type: biom-convert-table.yaml#table_typeinputBinding:prefix: --table-typeheader_key:type: string?doc: |The observation metadata to include from the input BIOM table file whencreating a tsv table file. By default no observation metadata will beincluded.inputBinding:prefix: --header-keybaseCommand: [ biom, convert ]arguments:- valueFrom: $(inputs.biom.nameroot).hdf5prefix: --output-fp- --to-hdf5outputs:result:type: FileoutputBinding: { glob: "$(inputs.biom.nameroot)*" }$namespaces:edam: http://edamontology.org/s: https://schema.org/$schemas:- http://edamontology.org/EDAM_1.16.owl- http://schema.org/version/9.0/schemaorg-current-http.rdfs:license: https://spdx.org/licenses/Apache-2.0s:copyrightHolder: "EMBL - European Bioinformatics Institute"
custom-types.yml
biom:class: Fileformat: http://edamontology.org/format_3746path: rich_sparse_otu_table.biomtable_type: OTU table
注意:要遵循下面的示例,您需要下载示例输入文件rich_sparse_otu_table.biom。该文件可从https://raw.githubusercontent.com/common-workflow-language/user_guide/gh-pages/_includes/cwl/19-custom-types/rich_sparse_otu_table.biom获得,并可以通过wget下载:
wget https://raw.githubusercontent.com/common-workflow-language/user_guide/gh-pages/_includes/cwl/19-custom-types/rich_sparse_otu_table.biom
在第34行,在inputs:table_type中,表转换中允许使用的表选项列表被作为自定义对象导入:
inputs:biom:type: Fileformat: edam:format_3746 # BIOMinputBinding:prefix: --input-fptable_type:type: biom-convert-table.yaml#table_typeinputBinding:prefix: --table-type
对自定义类型的引用是定义对象的文件名(bio -convert-table.yaml)和定义自定义类型的文件中的对象名(table_type)的组合。在这种情况下,符号数组从导入的生物转换表。yaml文件定义允许的表选项。例如,在custom-types.yml中,我们传递OTU表作为输入,它告诉工具创建一个hd5格式的OTU表。
描述自定义类型的YAML文件的内容如下所示:
type: enumname: table_typelabel: The type of the table to producesymbols:- OTU table- Pathway table- Function table- Ortholog table- Gene table- Metabolite table- Taxon table- Table
为了在CWL描述中使用自定义类型,必须导入它。导入在requirements: schemadefrerequirements中进行了描述,如下面的示例自定义类型中所示。cwl描述:
requirements:InlineJavascriptRequirement: {}ResourceRequirement:coresMax: 1ramMin: 100SchemaDefRequirement:types:- $import: biom-convert-table.yaml
还要注意这CWL描述的作者也包括ResourceRequirements,指定内存的最小数量和所需数量的核心工具运行成功,以及详细的版本的软件,和其他有用的描述写元数据。这些特性将在本用户指南的其他章节中进一步讨论。
