Is it possible to extend a record schema?
For example, let’s say I have the base schema ‘contig’ which has the attributes - chromosome
, start
and end
, that I have added to a file called contig_basic.yaml
. Let’s assume I use this schema in a tool called bedtools_basic.cwl
type: record
name: contig
fields:
chromosome:
label: chromosome
doc: |
The name of the chromosome
type: string
start:
label: start position
doc: |
The start position of the chromosome of the region
type: int?
end:
label: end position
doc: |
The end position of the chromosome of the region
type: int?
Let’s say now, for another tool called bedtools_advanced, I want to have a schema that is identical to the contig schema but with a boolean attribute is_alt_contig
which is set to true for ‘ALT’ contigs. Is there a way for me to import the attributes from contig_base.yaml and then extend this with my additional field?
The best I can achieve so far is:
type: record
name: contig_advanced
fields:
# Import each field from the basic schema
- $import: "contig_base.yaml#contig/chromosome"
- $import: "contig_base.yaml#contig/start"
- $import: "contig_base.yaml#contig/end"
# Extend the basic schema with the field 'is_alt_contig'
- name: is_alt_contig
label: is alt contig
doc: |
Is this contig an alt contig
type: boolean
Ideally I’d be able to do something like
type: record
name: contig_advanced
fields:
# Import entire schema
- { "$import": "contig_base.yaml#contig" }
# Extend the basic schema with the field 'is_alt_contig'
- name: is_alt_contig
label: is alt contig
doc: |
Is this contig an alt contig
type: boolean