Skip to content

Commit

Permalink
create JSON for single-ref abstract classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwagner committed Sep 9, 2024
1 parent e4ba5ec commit fe29951
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 50 deletions.
10 changes: 7 additions & 3 deletions src/ga4gh/gks/metaschema/tools/source_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ def build_inheritance_dicts(self):
# If it inherits from a class, register the inheritance
for cls, cls_def in self.raw_defs.items():
cls_url = f'#/{self.schema_def_keyword}/{cls}'
if self.class_is_abstract(cls) and 'oneOf' in cls_def:
if self.class_is_abstract(cls) and ('oneOf' in cls_def or '$ref' in cls_def):
maps_to_urls = self.has_children_urls.get(cls_url, set())
maps_to = self.has_children.get(cls, set())
for record in cls_def['oneOf']:
if 'oneOf' in cls_def:
records = cls_def['oneOf']
else:
records = [{'$ref': cls_def['$ref']}]
for record in records:
if not isinstance(record, dict):
continue
assert len(record) == 1
Expand Down Expand Up @@ -440,7 +444,7 @@ def clean_for_js(self):
schema_definition.pop('ga4ghDigest', None)
schema_definition.pop('header_level', None)
self.concretize_js_object(schema_definition)
if 'oneOf' not in schema_definition and 'allOf' not in schema_definition:
if 'oneOf' not in schema_definition and 'allOf' not in schema_definition and '$ref' not in schema_definition:
abstract_class_removals.append(schema_class)
if 'description' in schema_definition:
schema_definition['description'] = \
Expand Down
52 changes: 26 additions & 26 deletions tests/data/gnomAD/json/GnomadCAF
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,6 @@
"title": "GnomadCAF",
"type": "object",
"$defs": {
"GrpMaxFAF95": {
"description": "The group maximum filtering allele frequency at 95% CI",
"protectedClassOf": "GnomadCAF",
"type": "object",
"maturity": "draft",
"properties": {
"frequency": {
"type": "number"
},
"confidenceInterval": {
"type": "number",
"const": 0.95,
"default": 0.95
},
"groupId": {
"type": "string",
"description": "The genetic ancestry group from which the max frequency was calculated."
}
},
"required": [
"confidenceInterval",
"frequency",
"groupId"
],
"additionalProperties": false
},
"GnomadCafProperties": {
"description": "Additional properties specific to the gnomAD CAF model.",
"protectedClassOf": "GnomadCAF",
Expand Down Expand Up @@ -101,6 +75,32 @@
}
},
"required": []
},
"GrpMaxFAF95": {
"description": "The group maximum filtering allele frequency at 95% CI",
"protectedClassOf": "GnomadCAF",
"type": "object",
"maturity": "draft",
"properties": {
"frequency": {
"type": "number"
},
"confidenceInterval": {
"type": "number",
"const": 0.95,
"default": 0.95
},
"groupId": {
"type": "string",
"description": "The genetic ancestry group from which the max frequency was calculated."
}
},
"required": [
"confidenceInterval",
"frequency",
"groupId"
],
"additionalProperties": false
}
},
"maturity": "draft",
Expand Down
4 changes: 2 additions & 2 deletions tests/data/vrs/def/Adjacency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some Adjacency attributes are inherited from :ref:`Variation`.
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand All @@ -45,7 +45,7 @@ Some Adjacency attributes are inherited from :ref:`Variation`.
- 0..m
-
* - adjoinedSequences
- `IRI <../gks-common/$defs/IRI>`_ | :ref:`Location`
- :ref:`IRI` | :ref:`Location`
- 1..2
- The terminal sequence or pair of adjoined sequences that defines in the adjacency.
* - linker
Expand Down
4 changes: 2 additions & 2 deletions tests/data/vrs/def/Allele.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some Allele attributes are inherited from :ref:`Variation`.
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand All @@ -45,7 +45,7 @@ Some Allele attributes are inherited from :ref:`Variation`.
- 0..m
-
* - location
- `IRI <../gks-common/$defs/IRI>`_ | :ref:`Location`
- :ref:`IRI` | :ref:`Location`
- 1..1
- The location of the Allele
* - state
Expand Down
4 changes: 2 additions & 2 deletions tests/data/vrs/def/CopyNumber.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some CopyNumber attributes are inherited from :ref:`Variation`.
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand All @@ -45,6 +45,6 @@ Some CopyNumber attributes are inherited from :ref:`Variation`.
- 0..m
-
* - location
- `IRI <../gks-common/$defs/IRI>`_ | :ref:`Location`
- :ref:`IRI` | :ref:`Location`
- 1..1
- A location for which the number of systemic copies is described.
4 changes: 2 additions & 2 deletions tests/data/vrs/def/CopyNumberChange.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some CopyNumberChange attributes are inherited from :ref:`CopyNumber`.
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand All @@ -45,7 +45,7 @@ Some CopyNumberChange attributes are inherited from :ref:`CopyNumber`.
- 0..m
-
* - location
- `IRI <../gks-common/$defs/IRI>`_ | :ref:`Location`
- :ref:`IRI` | :ref:`Location`
- 1..1
- A location for which the number of systemic copies is described.
* - copyChange
Expand Down
4 changes: 2 additions & 2 deletions tests/data/vrs/def/CopyNumberCount.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some CopyNumberCount attributes are inherited from :ref:`CopyNumber`.
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand All @@ -45,7 +45,7 @@ Some CopyNumberCount attributes are inherited from :ref:`CopyNumber`.
- 0..m
-
* - location
- `IRI <../gks-common/$defs/IRI>`_ | :ref:`Location`
- :ref:`IRI` | :ref:`Location`
- 1..1
- A location for which the number of systemic copies is described.
* - copies
Expand Down
2 changes: 1 addition & 1 deletion tests/data/vrs/def/Ga4ghIdentifiableObject.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some Ga4ghIdentifiableObject attributes are inherited from :ref:`gks.core:Entity
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand Down
4 changes: 2 additions & 2 deletions tests/data/vrs/def/Haplotype.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some Haplotype attributes are inherited from :ref:`Variation`.
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand All @@ -45,6 +45,6 @@ Some Haplotype attributes are inherited from :ref:`Variation`.
- 0..m
-
* - members
- :ref:`Adjacency` | :ref:`Allele` | `IRI <../gks-common/$defs/IRI>`_
- :ref:`Adjacency` | :ref:`Allele` | :ref:`IRI`
- 2..m
- A list of :ref:`Alleles <Allele>` and :ref:`Adjacencies <Adjacency>` that comprise a Haplotype. Members must share the same reference sequence as adjacent members. Alleles should not have overlapping or adjacent coordinates with neighboring Alleles. Neighboring alleles should be ordered by ascending coordinates, unless represented on a DNA inversion (following an Adjacency with end-defined adjoinedSequences), in which case they should be ordered in descending coordinates. Sequence references MUST be consistent for all members between and including the end of one Adjacency and the beginning of another.
2 changes: 1 addition & 1 deletion tests/data/vrs/def/LengthExpression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some LengthExpression attributes are inherited from :ref:`SequenceExpression`.
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand Down
2 changes: 1 addition & 1 deletion tests/data/vrs/def/LiteralSequenceExpression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some LiteralSequenceExpression attributes are inherited from :ref:`SequenceExpre
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand Down
2 changes: 1 addition & 1 deletion tests/data/vrs/def/ReferenceLengthExpression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some ReferenceLengthExpression attributes are inherited from :ref:`SequenceExpre
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand Down
2 changes: 1 addition & 1 deletion tests/data/vrs/def/SequenceExpression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some SequenceExpression attributes are inherited from :ref:`gks.core:Entity`.
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand Down
4 changes: 2 additions & 2 deletions tests/data/vrs/def/SequenceLocation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some SequenceLocation attributes are inherited from :ref:`Ga4ghIdentifiableObjec
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand All @@ -41,7 +41,7 @@ Some SequenceLocation attributes are inherited from :ref:`Ga4ghIdentifiableObjec
- 0..1
- A sha512t24u digest created using the VRS Computed Identifier algorithm.
* - sequenceReference
- `IRI <../gks-common/$defs/IRI>`_ | :ref:`SequenceReference`
- :ref:`IRI` | :ref:`SequenceReference`
- 0..1
- A :ref:`SequenceReference`.
* - start
Expand Down
2 changes: 1 addition & 1 deletion tests/data/vrs/def/SequenceReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some SequenceReference attributes are inherited from :ref:`gks.core:Entity`.
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand Down
2 changes: 1 addition & 1 deletion tests/data/vrs/def/Variation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Some Variation attributes are inherited from :ref:`Ga4ghIdentifiableObject`.
- 0..1
- A free-text description of the entity.
* - extensions
- `Extension <../gks-common/core.json#/$defs/Extension>`_
- :ref:`Extension`
- 0..m
-
* - type
Expand Down
11 changes: 11 additions & 0 deletions tests/data/vrs/json/Location
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://w3id.org/ga4gh/schema/vrs/2.x/json/Location",
"title": "Location",
"type": "object",
"description": "A contiguous segment of a biological sequence.",
"$ref": "/ga4gh/schema/vrs/2.x/json/SequenceLocation",
"discriminator": {
"propertyName": "type"
}
}
5 changes: 5 additions & 0 deletions tests/data/vrs/vrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ $defs:
- copyChange
- location
additionalProperties: false
Location:
description: A contiguous segment of a biological sequence.
$ref: '#/$defs/SequenceLocation'
discriminator:
propertyName: type
SequenceLocation:
maturity: draft
ga4ghDigest:
Expand Down

0 comments on commit fe29951

Please sign in to comment.