Skip to content

Commit 1aae031

Browse files
authored
Merge pull request #238 from linkml/rdflib-percent-encoded-tests
Rdflib percent encoded tests
2 parents 32cd5f0 + fcbd2cb commit 1aae031

22 files changed

+7493
-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: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
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+
percent_encoded: true
52+
rank: 1
53+
description: "e.g. ISBN, PMID:123456, DOI:..., FHIR mapping: Reference.identifier"
54+
range: string
55+
reference:
56+
annotations:
57+
rank: 2
58+
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
59+
range: string
60+
description: "FHIR mapping: Reference (https://www.hl7.org/fhir/references.html)"
61+
File:
62+
attributes:
63+
fileAttributes:
64+
annotations:
65+
rank: 3
66+
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.
67+
inlined: true
68+
range: Dictionary
69+
individualToFileIdentifiers:
70+
annotations:
71+
rank: 2
72+
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.
73+
inlined: true
74+
range: Dictionary
75+
uri:
76+
annotations:
77+
rank: 1
78+
description: URI for the file e.g. file://data/genomes/file1.vcf.gz or https://opensnp.org/data/60.23andme-exome-vcf.231?1341012444
79+
range: string
80+
description: ''
81+
GestationalAge:
82+
attributes:
83+
days:
84+
annotations:
85+
rank: 2
86+
description: ''
87+
range: integer
88+
weeks:
89+
annotations:
90+
rank: 1
91+
description: ''
92+
range: integer
93+
description: ''
94+
OntologyClass:
95+
attributes:
96+
id:
97+
annotations:
98+
rank: 1
99+
description: a CURIE-style identifier e.g. HP:0100024, MP:0001284, UBERON:0001690. This is the primary key for the ontology class REQUIRED!
100+
identifier: true
101+
range: string
102+
required: true
103+
label:
104+
annotations:
105+
rank: 2
106+
description: class label, aka name. E.g. "Abnormality of cardiovascular system"
107+
range: string
108+
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)"
109+
Procedure:
110+
attributes:
111+
bodySite:
112+
annotations:
113+
rank: 2
114+
description: "FHIR mapping: Procedure.bodySite"
115+
inlined: true
116+
range: OntologyClass
117+
code:
118+
annotations:
119+
rank: 1
120+
description: "FHIR mapping: Procedure.code"
121+
inlined: true
122+
range: OntologyClass
123+
performed:
124+
annotations:
125+
rank: 3
126+
description: When the procedure was performed.
127+
inlined: true
128+
range: TimeElement
129+
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)"
130+
TimeElement:
131+
attributes:
132+
age:
133+
annotations:
134+
rank: 1
135+
description: ''
136+
range: Age
137+
ageRange:
138+
annotations:
139+
rank: 2
140+
description: ''
141+
range: AgeRange
142+
gestationalAge:
143+
annotations:
144+
rank: 6
145+
description: ''
146+
range: GestationalAge
147+
interval:
148+
annotations:
149+
rank: 5
150+
description: ''
151+
inlined: true
152+
range: TimeInterval
153+
ontologyClass:
154+
annotations:
155+
rank: 3
156+
description: ''
157+
inlined: true
158+
range: OntologyClass
159+
timestamp:
160+
annotations:
161+
rank: 4
162+
description: ''
163+
range: string
164+
description: ''
165+
rules:
166+
-
167+
postconditions:
168+
exactly_one_of:
169+
-
170+
slot_conditions:
171+
gestationalAge:
172+
required: true
173+
-
174+
slot_conditions:
175+
age:
176+
required: true
177+
-
178+
slot_conditions:
179+
ageRange:
180+
required: true
181+
-
182+
slot_conditions:
183+
ontologyClass:
184+
required: true
185+
-
186+
slot_conditions:
187+
timestamp:
188+
required: true
189+
-
190+
slot_conditions:
191+
interval:
192+
required: true
193+
TimeInterval:
194+
attributes:
195+
end:
196+
annotations:
197+
rank: 2
198+
description: ''
199+
range: string
200+
start:
201+
annotations:
202+
rank: 1
203+
description: ''
204+
range: string
205+
description: ''
206+
default_prefix: base
207+
description: "Automatic translation of phenopackets protobuf to LinkML. Status: EXPERIMENTAL."
208+
enums: {}
209+
210+
id: https://w3id.org/linkml/phenopackets/base
211+
imports:
212+
- linkml:types
213+
- timestamp
214+
name: base
215+
prefixes:
216+
GENO: http://purl.obolibrary.org/obo/GENO_
217+
HP: http://purl.obolibrary.org/obo/HP_
218+
LOINC: https://loinc.org/
219+
MONDO: http://purl.obolibrary.org/obo/MONDO_
220+
NCIT: http://purl.obolibrary.org/obo/NCIT_
221+
UBERON: http://purl.obolibrary.org/obo/UBERON_
222+
UCUM: http://unitsofmeasure.org/
223+
UO: http://purl.obolibrary.org/obo/UO_
224+
argo: https://docs.icgc-argo.org/dictionary/
225+
base: https://w3id.org/linkml/phenopackets/base/
226+
linkml: https://w3id.org/linkml/
227+
slots: {}
228+

0 commit comments

Comments
 (0)