Skip to content

Commit 546f53c

Browse files
committed
Additional tests for percent encoding of IDs for rdflib_dumper
1 parent 32cd5f0 commit 546f53c

22 files changed

+7471
-7
lines changed

linkml_runtime/dumpers/rdflib_dumper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def dumps(self, element: YAMLRoot, schemaview: SchemaView = None,
160160
return self.as_rdf_graph(element, schemaview, prefix_map=prefix_map).\
161161
serialize(format=fmt)
162162

163-
def _as_uri(self, element_id: str, id_slot: SlotDefinition, schemaview: SchemaView) -> URIRef:
164-
if schemaview.is_slot_percent_encoded(id_slot):
163+
def _as_uri(self, element_id: str, id_slot: Optional[SlotDefinition], schemaview: SchemaView) -> URIRef:
164+
if id_slot and schemaview.is_slot_percent_encoded(id_slot):
165165
return URIRef(urllib.parse.quote(element_id))
166166
else:
167167
return schemaview.namespaces().uri_for(element_id)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
classes:
3+
Any:
4+
attributes:
5+
typeUrl:
6+
annotations:
7+
rank: 1
8+
description: "A URL/resource name that uniquely identifies the type of the serialized protocol buffer message. This string must contain at least one \"/\" character. The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). The name should be in a canonical form (e.g., leading \".\" is not accepted). In practice, teams usually precompile into the binary all types that they expect it to use in the context of Any. However, for URLs which use the scheme `http`, `https`, or no scheme, one can optionally set up a type server that maps type URLs to message definitions as follows: * If no scheme is provided, `https` is assumed. * An HTTP GET on the URL must yield a [google.protobuf.Type][] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Note: this functionality is not currently available in the official protobuf release, and it is not used for type URLs beginning with type.googleapis.com. Schemes other than `http`, `https` (or the empty scheme) might be used with implementation specific semantics. "
9+
range: string
10+
value:
11+
annotations:
12+
rank: 2
13+
description: Must be a valid serialized protocol buffer of the above specified type.
14+
range: string
15+
description: "`Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type. Example 1: Pack and unpack a message in C++. Foo foo = ...; Any any; any.PackFrom(foo); ... if (any.UnpackTo(&foo)) { ... } Example 2: Pack and unpack a message in Java. Foo foo = ...; Any any = Any.pack(foo); ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() any.Pack(foo) ... if any.Is(Foo.DESCRIPTOR): any.Unpack(foo) ... Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := anypb.New(foo) if err != nil { ... } ... foo := &pb.Foo{} if err := any.UnmarshalTo(foo); err != nil { ... } The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example \"foo.bar.com/x/y.z\" will yield type name \"y.z\". JSON ==== The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: package google.profile; message Person { string first_name = 1; string last_name = 2; } { \"@type\": \"type.googleapis.com/google.profile.Person\", \"firstName\": <string>, \"lastName\": <string> } If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the `@type` field. Example (for message [google.protobuf.Duration][]): { \"@type\": \"type.googleapis.com/google.protobuf.Duration\", \"value\": \"1.212s\" } "
16+
default_prefix: any
17+
description: "Automatic translation of phenopackets protobuf to LinkML. Status: EXPERIMENTAL."
18+
enums: {}
19+
20+
id: https://w3id.org/linkml/phenopackets/any
21+
imports:
22+
- linkml:types
23+
name: any
24+
prefixes:
25+
GENO: http://purl.obolibrary.org/obo/GENO_
26+
HP: http://purl.obolibrary.org/obo/HP_
27+
LOINC: https://loinc.org/
28+
MONDO: http://purl.obolibrary.org/obo/MONDO_
29+
NCIT: http://purl.obolibrary.org/obo/NCIT_
30+
UBERON: http://purl.obolibrary.org/obo/UBERON_
31+
UCUM: http://unitsofmeasure.org/
32+
UO: http://purl.obolibrary.org/obo/UO_
33+
any: https://w3id.org/linkml/phenopackets/any/
34+
argo: https://docs.icgc-argo.org/dictionary/
35+
linkml: https://w3id.org/linkml/
36+
slots: {}
37+
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
2+
classes:
3+
Age:
4+
attributes:
5+
iso8601duration:
6+
annotations:
7+
rank: 1
8+
description: The :ref:`ISO 8601<metadata_date_time>` age of this object as ISO8601 duration or time intervals. e.g. P40Y10M05D)
9+
range: string
10+
description: See http://build.fhir.org/datatypes and http://build.fhir.org/condition-definitions.html#Condition.onset_x_ In FHIR this is represented as a UCUM measurement - http://unitsofmeasure.org/trac/
11+
AgeRange:
12+
attributes:
13+
end:
14+
annotations:
15+
rank: 2
16+
description: ''
17+
range: Age
18+
start:
19+
annotations:
20+
rank: 1
21+
description: ''
22+
range: Age
23+
description: ''
24+
Dictionary:
25+
comments:
26+
- TODO
27+
Evidence:
28+
attributes:
29+
evidenceCode:
30+
annotations:
31+
rank: 1
32+
description: "The encoded evidence type using, for example the Evidence & Conclusion Ontology (ECO - http://purl.obolibrary.org/obo/eco.owl) FHIR mapping: Condition.evidence.code"
33+
inlined: true
34+
range: OntologyClass
35+
reference:
36+
annotations:
37+
rank: 2
38+
description: "FHIR mapping: Condition.evidence.detail"
39+
inlined: true
40+
range: ExternalReference
41+
description: "FHIR mapping: Condition.evidence (https://www.hl7.org/fhir/condition-definitions.html#Condition.evidence)"
42+
ExternalReference:
43+
attributes:
44+
description:
45+
annotations:
46+
rank: 3
47+
description: "Human readable title or display string for the reference FHIR mapping: Reference.display"
48+
range: string
49+
id:
50+
annotations:
51+
rank: 1
52+
description: "e.g. ISBN, PMID:123456, DOI:..., FHIR mapping: Reference.identifier"
53+
range: string
54+
reference:
55+
annotations:
56+
rank: 2
57+
description: A full or partial URL pointing to the external reference if no commonly resolvable identifier can be used in the `id` field FHIR mapping Reference.reference
58+
range: string
59+
description: "FHIR mapping: Reference (https://www.hl7.org/fhir/references.html)"
60+
File:
61+
attributes:
62+
fileAttributes:
63+
annotations:
64+
rank: 3
65+
description: Map of attributes describing the file. For example the File format or genome assembly would be defied here. For genomic data files there MUST be a 'genomeAssembly' key.
66+
inlined: true
67+
range: Dictionary
68+
individualToFileIdentifiers:
69+
annotations:
70+
rank: 2
71+
description: A map of identifiers mapping an individual to a sample in the file. The key values must correspond to the Individual::id for the individuals in the message, the values must map to the samples in the file.
72+
inlined: true
73+
range: Dictionary
74+
uri:
75+
annotations:
76+
rank: 1
77+
description: URI for the file e.g. file://data/genomes/file1.vcf.gz or https://opensnp.org/data/60.23andme-exome-vcf.231?1341012444
78+
range: string
79+
description: ''
80+
GestationalAge:
81+
attributes:
82+
days:
83+
annotations:
84+
rank: 2
85+
description: ''
86+
range: integer
87+
weeks:
88+
annotations:
89+
rank: 1
90+
description: ''
91+
range: integer
92+
description: ''
93+
OntologyClass:
94+
attributes:
95+
id:
96+
annotations:
97+
rank: 1
98+
description: a CURIE-style identifier e.g. HP:0100024, MP:0001284, UBERON:0001690. This is the primary key for the ontology class REQUIRED!
99+
identifier: true
100+
range: string
101+
required: true
102+
label:
103+
annotations:
104+
rank: 2
105+
description: class label, aka name. E.g. "Abnormality of cardiovascular system"
106+
range: string
107+
description: "A class (aka term, concept) in an ontology. FHIR mapping: CodeableConcept (http://www.hl7.org/fhir/datatypes.html#CodeableConcept) see also Coding (http://www.hl7.org/fhir/datatypes.html#Coding)"
108+
Procedure:
109+
attributes:
110+
bodySite:
111+
annotations:
112+
rank: 2
113+
description: "FHIR mapping: Procedure.bodySite"
114+
inlined: true
115+
range: OntologyClass
116+
code:
117+
annotations:
118+
rank: 1
119+
description: "FHIR mapping: Procedure.code"
120+
inlined: true
121+
range: OntologyClass
122+
performed:
123+
annotations:
124+
rank: 3
125+
description: When the procedure was performed.
126+
inlined: true
127+
range: TimeElement
128+
description: "A clinical procedure performed on a subject. By preference a single concept to indicate both the procedure and the body site should be used. In cases where this is not possible, the body site should be indicated using a separate ontology class. e.g. {\"code\":{\"NCIT:C51585\": \"Biopsy of Soft Palate\"}} {\"code\":{\"NCIT:C28743\": \"Punch Biopsy\"}, \"body_site\":{\"UBERON:0003403\": \"skin of forearm\"}} - a punch biopsy of the skin from the forearm FHIR mapping: Procedure (https://www.hl7.org/fhir/procedure.html)"
129+
TimeElement:
130+
attributes:
131+
age:
132+
annotations:
133+
rank: 1
134+
description: ''
135+
range: Age
136+
ageRange:
137+
annotations:
138+
rank: 2
139+
description: ''
140+
range: AgeRange
141+
gestationalAge:
142+
annotations:
143+
rank: 6
144+
description: ''
145+
range: GestationalAge
146+
interval:
147+
annotations:
148+
rank: 5
149+
description: ''
150+
inlined: true
151+
range: TimeInterval
152+
ontologyClass:
153+
annotations:
154+
rank: 3
155+
description: ''
156+
inlined: true
157+
range: OntologyClass
158+
timestamp:
159+
annotations:
160+
rank: 4
161+
description: ''
162+
range: string
163+
description: ''
164+
rules:
165+
-
166+
postconditions:
167+
exactly_one_of:
168+
-
169+
slot_conditions:
170+
gestationalAge:
171+
required: true
172+
-
173+
slot_conditions:
174+
age:
175+
required: true
176+
-
177+
slot_conditions:
178+
ageRange:
179+
required: true
180+
-
181+
slot_conditions:
182+
ontologyClass:
183+
required: true
184+
-
185+
slot_conditions:
186+
timestamp:
187+
required: true
188+
-
189+
slot_conditions:
190+
interval:
191+
required: true
192+
TimeInterval:
193+
attributes:
194+
end:
195+
annotations:
196+
rank: 2
197+
description: ''
198+
range: string
199+
start:
200+
annotations:
201+
rank: 1
202+
description: ''
203+
range: string
204+
description: ''
205+
default_prefix: base
206+
description: "Automatic translation of phenopackets protobuf to LinkML. Status: EXPERIMENTAL."
207+
enums: {}
208+
209+
id: https://w3id.org/linkml/phenopackets/base
210+
imports:
211+
- linkml:types
212+
- timestamp
213+
name: base
214+
prefixes:
215+
GENO: http://purl.obolibrary.org/obo/GENO_
216+
HP: http://purl.obolibrary.org/obo/HP_
217+
LOINC: https://loinc.org/
218+
MONDO: http://purl.obolibrary.org/obo/MONDO_
219+
NCIT: http://purl.obolibrary.org/obo/NCIT_
220+
UBERON: http://purl.obolibrary.org/obo/UBERON_
221+
UCUM: http://unitsofmeasure.org/
222+
UO: http://purl.obolibrary.org/obo/UO_
223+
argo: https://docs.icgc-argo.org/dictionary/
224+
base: https://w3id.org/linkml/phenopackets/base/
225+
linkml: https://w3id.org/linkml/
226+
slots: {}
227+

0 commit comments

Comments
 (0)