Skip to content

Commit

Permalink
additional test for % encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed Jan 18, 2023
1 parent 546f53c commit fcbd2cb
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions tests/test_loaders_dumpers/input/phenopackets/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ classes:
range: string
id:
annotations:
percent_encoded: true
rank: 1
description: "e.g. ISBN, PMID:123456, DOI:..., FHIR mapping: Reference.identifier"
range: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ classes:
range: OntologyClass
id:
annotations:
percent_encoded: true
rank: 1
description: biosamples SAMN08666232 Human Cell Atlas The Biosample id This is unique in the context of the server instance. ARGO mapping specimen::submitter_specimen_id
exact_mappings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classes:
range: OntologyClass
id:
annotations:
percent_encoded: true
rank: 1
description: An identifier for the individual. This must be unique within the record. ARGO mapping donor::submitter_donor_id
exact_mappings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ classes:
range: Diagnosis
id:
annotations:
percent_encoded: true
rank: 1
description: id of the interpretation
range: string
Expand Down
4 changes: 3 additions & 1 deletion tests/test_loaders_dumpers/input/phenopackets/meta_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ classes:
description: ''
Resource:
attributes:
id:
id:
identifier: true
annotations:
percent_encoded: true
rank: 1
description: "for OBO Ontologies, the value of this string MUST always be the official OBO ID, which is always equivalent to the ID prefix in lower case. Examples: hp, go, mp, mondo Consult http://obofoundry.org for a complete list For other ontologies (e.g. SNOMED), use the prefix in identifiers.org"
range: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ classes:
range: File
id:
annotations:
percent_encoded: true
rank: 1
description: ''
range: string
Expand Down Expand Up @@ -49,6 +50,7 @@ classes:
range: File
id:
annotations:
percent_encoded: true
rank: 1
description: An identifier specific for this family.
range: string
Expand Down Expand Up @@ -101,6 +103,7 @@ classes:
range: File
id:
annotations:
percent_encoded: true
rank: 1
description: An identifier specific for this phenopacket.
range: string
Expand Down
6 changes: 6 additions & 0 deletions tests/test_loaders_dumpers/input/phenopackets/vrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ classes:
range: DerivedSequenceExpression
id:
annotations:
percent_encoded: true
rank: 1
description: ''
range: string
Expand Down Expand Up @@ -79,6 +80,7 @@ classes:
range: string
id:
annotations:
percent_encoded: true
rank: 1
description: ''
range: string
Expand Down Expand Up @@ -128,6 +130,7 @@ classes:
range: Haplotype
id:
annotations:
percent_encoded: true
rank: 1
description: ''
range: string
Expand Down Expand Up @@ -305,6 +308,7 @@ classes:
range: Haplotype
id:
annotations:
percent_encoded: true
rank: 1
description: ''
range: string
Expand Down Expand Up @@ -518,6 +522,7 @@ classes:
attributes:
id:
annotations:
percent_encoded: true
rank: 1
description: ''
range: string
Expand Down Expand Up @@ -586,6 +591,7 @@ classes:
range: string
id:
annotations:
percent_encoded: true
rank: 1
description: ''
range: string
Expand Down
2 changes: 2 additions & 0 deletions tests/test_loaders_dumpers/input/phenopackets/vrsatile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ classes:
range: GeneDescriptor
id:
annotations:
percent_encoded: true
rank: 1
description: ''
range: string
Expand Down Expand Up @@ -175,6 +176,7 @@ classes:
range: string
id:
annotations:
percent_encoded: true
rank: 4
description: ''
range: string
Expand Down
13 changes: 9 additions & 4 deletions tests/test_loaders_dumpers/test_rdflib_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from tests.test_loaders_dumpers import INPUT_DIR, OUTPUT_DIR
from tests.test_loaders_dumpers.models.personinfo import Container, Person, Address, Organization, OrganizationType
from tests.test_loaders_dumpers.models.node_object import NodeObject, Triple
from tests.test_loaders_dumpers.models.phenopackets import PhenotypicFeature, OntologyClass, Phenopacket, MetaData
from tests.test_loaders_dumpers.models.phenopackets import PhenotypicFeature, OntologyClass, Phenopacket, MetaData, \
Resource

SCHEMA = os.path.join(INPUT_DIR, 'personinfo.yaml')
DATA = os.path.join(INPUT_DIR, 'example_personinfo_data.yaml')
Expand Down Expand Up @@ -351,7 +352,8 @@ def test_phenopackets(self):
rdflib_dumper.dumps(c, view)
cases = [
("HP:1", "http://purl.obolibrary.org/obo/HP_1", None),
("FOO:1", "http://example.org/FOO_1", {'FOO': 'http://example.org/FOO_'}),
("FOO:1", "http://example.org/FOO_1", {'FOO': 'http://example.org/FOO_',
"@base": "http://example.org/base/"}),
]
for id, expected_uri, prefix_map in cases:

Expand All @@ -364,14 +366,17 @@ def test_phenopackets(self):
f'Expected label {test_label} for {expected_uri} in {ttl}')
pf = PhenotypicFeature(type=c)
pkt = Phenopacket(id='id with spaces',
metaData=MetaData(),
metaData=MetaData(resources=[Resource(id='id with spaces')]),
phenotypicFeatures=[pf])
ttl = rdflib_dumper.dumps(pkt, view, prefix_map=prefix_map)
print(ttl)
g = Graph()
g.parse(data=ttl, format='ttl')
self.assertIn(Literal(test_label), list(g.objects(URIRef(expected_uri))),
f'Expected label {test_label} for {expected_uri} in {ttl}')
if prefix_map and "@base" in prefix_map:
resource_uri = URIRef(prefix_map["@base"] + "id%20with%20spaces")
self.assertEqual(1, len(list(g.objects(resource_uri))))




Expand Down

0 comments on commit fcbd2cb

Please sign in to comment.