linkml-phenopackets 0.1.0rc1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- linkml_phenopackets-0.1.0rc1/LICENSE +29 -0
- linkml_phenopackets-0.1.0rc1/NOTICE +134 -0
- linkml_phenopackets-0.1.0rc1/PKG-INFO +240 -0
- linkml_phenopackets-0.1.0rc1/README.md +208 -0
- linkml_phenopackets-0.1.0rc1/pyproject.toml +78 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/__init__.py +16 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/cli/__init__.py +24 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/cli/cli.py +266 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/datamodel/__init__.py +9 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/datamodel/phenopackets.py +4214 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/jsonschema/phenopackets.schema.json +4616 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/pydantic/__init__.py +0 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/pydantic/model.py +2469 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/any.yaml +37 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/base.yaml +243 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/biosample.yaml +181 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/constants.yaml +392 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/cv_terms.yaml +144 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/disease.yaml +85 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/genome.yaml +25 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/individual.yaml +194 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/interpretation.yaml +210 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/measurement.yaml +168 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/medical_action.yaml +290 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/meta_data.yaml +123 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/pedigree.yaml +82 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/phenopackets.yaml +189 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/phenotypic_feature.yaml +75 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/timestamp.yaml +37 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/vrs.yaml +862 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/schema/vrsatile.yaml +245 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/utilities/__init__.py +0 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/utilities/ingest_constants.py +74 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/utilities/io_utilities.py +84 -0
- linkml_phenopackets-0.1.0rc1/src/linkml_phenopackets/utilities/ontology_utilities.py +194 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2026, linkml-phenopackets contributors
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
linkml-phenopackets
|
|
2
|
+
===================
|
|
3
|
+
|
|
4
|
+
linkml-phenopackets is distributed under the BSD 3-Clause License, see LICENSE.
|
|
5
|
+
|
|
6
|
+
The schema (the YAML files in linkml_phenopackets/schema) is converted from the
|
|
7
|
+
works that are listed here. It repeats the documentation of their messages,
|
|
8
|
+
fields and enums. The Python classes and the JSON Schema in this package are
|
|
9
|
+
generated from the schema.
|
|
10
|
+
|
|
11
|
+
1. phenopacket-schema, release 2.0.0
|
|
12
|
+
https://github.com/phenopackets/phenopacket-schema
|
|
13
|
+
|
|
14
|
+
The source of every module of the schema that is not named below.
|
|
15
|
+
cv_terms.yaml is written for this project, and follows the ontologies that
|
|
16
|
+
the documentation of phenopacket-schema recommends.
|
|
17
|
+
|
|
18
|
+
2. vrs-protobuf, commit d045bb0c65152a0cb32177dfc21148cc13d40fbe
|
|
19
|
+
https://github.com/ga4gh/vrs-protobuf
|
|
20
|
+
|
|
21
|
+
The source of vrs.yaml.
|
|
22
|
+
|
|
23
|
+
3. Protocol Buffers, release 3.14.0
|
|
24
|
+
https://github.com/protocolbuffers/protobuf
|
|
25
|
+
|
|
26
|
+
The source of timestamp.yaml and any.yaml.
|
|
27
|
+
|
|
28
|
+
4. phenopacket-tools
|
|
29
|
+
https://github.com/phenopackets/phenopacket-tools
|
|
30
|
+
|
|
31
|
+
constants.yaml is converted from the tables of ontology terms in the
|
|
32
|
+
constants directory of phenopacket-tools. phenopacket-tools is
|
|
33
|
+
Copyright (c) 2022, Global Alliance for Genomics and Health, and is
|
|
34
|
+
distributed under the GNU General Public License, version 3:
|
|
35
|
+
https://github.com/phenopackets/phenopacket-tools/blob/main/LICENSE
|
|
36
|
+
|
|
37
|
+
The licenses of the first three follow.
|
|
38
|
+
|
|
39
|
+
------------------------------------------------------------------------------
|
|
40
|
+
1. phenopacket-schema
|
|
41
|
+
------------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
BSD 3-Clause License
|
|
44
|
+
|
|
45
|
+
Copyright (c) 2018-2021, Global Alliance for Genomics and Health
|
|
46
|
+
All rights reserved.
|
|
47
|
+
|
|
48
|
+
Redistribution and use in source and binary forms, with or without
|
|
49
|
+
modification, are permitted provided that the following conditions are met:
|
|
50
|
+
|
|
51
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
52
|
+
list of conditions and the following disclaimer.
|
|
53
|
+
|
|
54
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
55
|
+
this list of conditions and the following disclaimer in the documentation
|
|
56
|
+
and/or other materials provided with the distribution.
|
|
57
|
+
|
|
58
|
+
* Neither the name of the copyright holder nor the names of its
|
|
59
|
+
contributors may be used to endorse or promote products derived from
|
|
60
|
+
this software without specific prior written permission.
|
|
61
|
+
|
|
62
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
63
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
64
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
65
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
66
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
67
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
68
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
69
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
70
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
71
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
72
|
+
|
|
73
|
+
------------------------------------------------------------------------------
|
|
74
|
+
2. vrs-protobuf
|
|
75
|
+
------------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
MIT License
|
|
78
|
+
|
|
79
|
+
Copyright (c) 2021 Global Alliance for Genomics and Health
|
|
80
|
+
|
|
81
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
82
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
83
|
+
in the Software without restriction, including without limitation the rights
|
|
84
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
85
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
86
|
+
furnished to do so, subject to the following conditions:
|
|
87
|
+
|
|
88
|
+
The above copyright notice and this permission notice shall be included in all
|
|
89
|
+
copies or substantial portions of the Software.
|
|
90
|
+
|
|
91
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
92
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
93
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
94
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
95
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
96
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
97
|
+
SOFTWARE.
|
|
98
|
+
|
|
99
|
+
------------------------------------------------------------------------------
|
|
100
|
+
3. Protocol Buffers
|
|
101
|
+
------------------------------------------------------------------------------
|
|
102
|
+
|
|
103
|
+
Copyright 2008 Google Inc. All rights reserved.
|
|
104
|
+
|
|
105
|
+
Redistribution and use in source and binary forms, with or without
|
|
106
|
+
modification, are permitted provided that the following conditions are
|
|
107
|
+
met:
|
|
108
|
+
|
|
109
|
+
* Redistributions of source code must retain the above copyright
|
|
110
|
+
notice, this list of conditions and the following disclaimer.
|
|
111
|
+
* Redistributions in binary form must reproduce the above
|
|
112
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
113
|
+
in the documentation and/or other materials provided with the
|
|
114
|
+
distribution.
|
|
115
|
+
* Neither the name of Google Inc. nor the names of its
|
|
116
|
+
contributors may be used to endorse or promote products derived from
|
|
117
|
+
this software without specific prior written permission.
|
|
118
|
+
|
|
119
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
120
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
121
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
122
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
123
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
124
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
125
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
126
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
127
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
128
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
129
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
130
|
+
|
|
131
|
+
Code generated by the Protocol Buffer compiler is owned by the owner
|
|
132
|
+
of the input file used when generating it. This code is not
|
|
133
|
+
standalone and requires a support library to be linked with it. This
|
|
134
|
+
support library is itself covered by the above license.
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: linkml-phenopackets
|
|
3
|
+
Version: 0.1.0rc1
|
|
4
|
+
Summary: A LinkML rendering of the GA4GH Phenopacket Schema: the schema, Python dataclasses, Pydantic models and JSON Schema. This is not the official GA4GH phenopackets library.
|
|
5
|
+
License-Expression: BSD-3-Clause
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Keywords: phenopackets,linkml,GA4GH,schema
|
|
9
|
+
Author: Chris Mungall
|
|
10
|
+
Author-email: cjmungall@lbl.gov
|
|
11
|
+
Requires-Python: >=3.11,<4.0
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
16
|
+
Provides-Extra: tools
|
|
17
|
+
Requires-Dist: bioregistry (>=0.11.1,<0.12.0) ; extra == "tools"
|
|
18
|
+
Requires-Dist: click ; extra == "tools"
|
|
19
|
+
Requires-Dist: curies ; extra == "tools"
|
|
20
|
+
Requires-Dist: linkml (>=1.11.0,<2.0.0) ; extra == "tools"
|
|
21
|
+
Requires-Dist: linkml-runtime (>=1.11.0,<2.0.0)
|
|
22
|
+
Requires-Dist: oaklib (>=0.6.0,<0.7.0) ; extra == "tools"
|
|
23
|
+
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
|
|
24
|
+
Requires-Dist: pyyaml ; extra == "tools"
|
|
25
|
+
Requires-Dist: setuptools (<82) ; (python_version < "3.12") and (extra == "tools")
|
|
26
|
+
Project-URL: Documentation, https://cmungall.github.io/linkml-phenopackets/
|
|
27
|
+
Project-URL: Homepage, https://cmungall.github.io/linkml-phenopackets/
|
|
28
|
+
Project-URL: Issues, https://github.com/cmungall/linkml-phenopackets/issues
|
|
29
|
+
Project-URL: Repository, https://github.com/cmungall/linkml-phenopackets
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# Phenopackets linkml schema
|
|
33
|
+
|
|
34
|
+
Browse the autogenerated schema documentation here:
|
|
35
|
+
|
|
36
|
+
* [https://cmungall.github.io/linkml-phenopackets/](https://cmungall.github.io/linkml-phenopackets/)
|
|
37
|
+
|
|
38
|
+
Note the linkml markdown rendering is still incomplete, for a full schema, see
|
|
39
|
+
|
|
40
|
+
* [src/linkml_phenopackets/schema](https://github.com/cmungall/linkml-phenopackets/tree/main/src/linkml_phenopackets/schema)
|
|
41
|
+
|
|
42
|
+
## What is this repo and how was it made?
|
|
43
|
+
|
|
44
|
+
This is a rendering of the [phenopackets](https://phenopacket-schema.readthedocs.io/) schema in LinkML.
|
|
45
|
+
It is NOT the official GA4GH phenopackets schema.
|
|
46
|
+
|
|
47
|
+
The intent is to demonstrate some of the tooling and integrative capabilities of LinkML over Protobuf, in particular:
|
|
48
|
+
|
|
49
|
+
- Additional validation not possible in Protobuf, including:
|
|
50
|
+
- required fields
|
|
51
|
+
- ontology constraints
|
|
52
|
+
- Generation of python classes and tooling
|
|
53
|
+
- Export/Import phenopackets from to and from RDF
|
|
54
|
+
- Semantic annotation of schemas
|
|
55
|
+
- Cross-schema integration
|
|
56
|
+
|
|
57
|
+
The LinkML schema is generated using a script [proto2linkml](https://github.com/cmungall/linkml-phenopackets/blob/main/util/proto2linkml.pl) that converts from the Protobuf source. This makes
|
|
58
|
+
use of specific *conventions* in the Protobuf source, such as the use of particular controlled
|
|
59
|
+
keywords in `//` comments. As such, this code is *not* generalizable to other protobuf schemas.
|
|
60
|
+
|
|
61
|
+
Note we intentionally don't use out of band-info. We have not done additional curation based on the `.rst` docs,
|
|
62
|
+
it comes from protobuf.
|
|
63
|
+
|
|
64
|
+
### Which version of Phenopackets is this?
|
|
65
|
+
|
|
66
|
+
The schema corresponds to [release 2.0.0](https://github.com/phenopackets/phenopacket-schema/releases/tag/2.0.0)
|
|
67
|
+
of phenopacket-schema. The root module, [phenopackets.yaml](https://github.com/cmungall/linkml-phenopackets/blob/main/src/linkml_phenopackets/schema/phenopackets.yaml), names the
|
|
68
|
+
protobuf file of that release as its `source`.
|
|
69
|
+
|
|
70
|
+
The release is set in the [Makefile](https://github.com/cmungall/linkml-phenopackets/blob/main/Makefile), together with the two things that the release itself depends on:
|
|
71
|
+
the commit of [vrs-protobuf](https://github.com/ga4gh/vrs-protobuf) that it includes as a git submodule, and the
|
|
72
|
+
version of Protobuf that its `Timestamp` and `Any` types come from. To generate the schema again, and then
|
|
73
|
+
everything that is derived from it:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
make auto deploy # downloads the protobuf files of the release and converts them
|
|
77
|
+
make descriptors # only needed after changing the release or a pin, see below
|
|
78
|
+
make all py jsonschema src/linkml_phenopackets/pydantic/model.py
|
|
79
|
+
make test sync-examples
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`make test` compares the schema with what `protoc` makes of the same protobuf files, which is stored in
|
|
83
|
+
[tests/input](https://github.com/cmungall/linkml-phenopackets/tree/main/tests/input) by `make descriptors`. Every message, field, oneof and enum of the release has to be
|
|
84
|
+
in the schema, with its documentation, and the generated modules may not define anything else. See
|
|
85
|
+
[tests/test_schema](https://github.com/cmungall/linkml-phenopackets/blob/main/tests/test_schema/test_protobuf_conformance.py), which also describes how each protobuf
|
|
86
|
+
construct is translated. `make test` also generates the Python classes and the JSON Schema again, and fails when they differ from
|
|
87
|
+
the ones in the repository.
|
|
88
|
+
|
|
89
|
+
### Differences from protobuf
|
|
90
|
+
|
|
91
|
+
The schema describes a phenopacket as it is written in JSON or YAML: attributes are named after the JSON names
|
|
92
|
+
of the fields (`individual_id` is `individualId`, and the VRS `_id` fields are `Id`). A few things are not
|
|
93
|
+
carried over exactly:
|
|
94
|
+
|
|
95
|
+
- **Requirement levels.** A field is required only if its protobuf comment says `REQUIRED`. The documentation
|
|
96
|
+
of the release marks many more fields as required or recommended (`Phenopacket.id` for example). These
|
|
97
|
+
are not in the protobuf files, and so they are not in the schema.
|
|
98
|
+
- **Maps.** `File.fileAttributes` and `File.individualToFileIdentifiers` are `map<string, string>` fields.
|
|
99
|
+
They are dictionaries of `DictionaryEntry` objects. The `{key: value}` form of protobuf is valid; the Python
|
|
100
|
+
classes write `{key: {key: ..., value: ...}}`.
|
|
101
|
+
- **64 bit integers.** `VcfRecord.pos` and the positions and counts in VRS are integers. Protobuf writes them as
|
|
102
|
+
strings in JSON (`"pos": "45989626"`), which the Python classes convert, but which `linkml-validate` reports
|
|
103
|
+
as errors. Convert such a file with `linkml-convert` before validating it.
|
|
104
|
+
- **Timestamps** are strings, as they are in JSON.
|
|
105
|
+
- **`Extension.value`** is a list of strings. In release 2.0.0 it is a list of `google.protobuf.Any`. Later
|
|
106
|
+
versions of phenopacket-schema (2.0.1 and up, used by phenopacket-tools) changed it to a single string.
|
|
107
|
+
- **Oneofs.** A `oneof` is a rule that says that exactly one of its fields is required, which is how the
|
|
108
|
+
documentation describes them. Protobuf also accepts a message with none of them. Neither `linkml-validate`
|
|
109
|
+
nor the Python classes check these rules.
|
|
110
|
+
|
|
111
|
+
## Ontology Enhancements
|
|
112
|
+
|
|
113
|
+
The file [cv_terms.yaml](https://github.com/cmungall/linkml-phenopackets/blob/main/src/linkml_phenopackets/schema/cv_terms.yaml)
|
|
114
|
+
is hand-curated, rather than derived from the YAML. It is based on: [recommended ontologies](https://phenopacket-schema.readthedocs.io/en/latest/recommended-ontologies.html)
|
|
115
|
+
from the official phenopackets repo. It makes use of *dynamic enums* which allows for more advanced
|
|
116
|
+
ontology checking; for example:
|
|
117
|
+
|
|
118
|
+
* Uberon anatomy terms must be found under the "anatomical entity branch"
|
|
119
|
+
* HPO abnormality terms must be found under the "phenotypic abnormality branch"
|
|
120
|
+
|
|
121
|
+
etc
|
|
122
|
+
|
|
123
|
+
We also include [constants.yaml](https://github.com/cmungall/linkml-phenopackets/blob/main/src/linkml_phenopackets/schema/constants.yaml)
|
|
124
|
+
which is a direct transform from the phenopackets-tools repo.
|
|
125
|
+
|
|
126
|
+
## How to use this repo
|
|
127
|
+
|
|
128
|
+
You can browse the [schema docs](https://cmungall.github.io/linkml-phenopackets/) which are generated from the LinkML
|
|
129
|
+
schema.
|
|
130
|
+
|
|
131
|
+
You can also explore the schema in the [schema](https://github.com/cmungall/linkml-phenopackets/tree/main/src/linkml_phenopackets/schema) directory.
|
|
132
|
+
|
|
133
|
+
As part of the build process, we also validate and convert all canonical Phenopacket examples into YAML, JSON,
|
|
134
|
+
and RDF.
|
|
135
|
+
|
|
136
|
+
* [examples/](https://github.com/cmungall/linkml-phenopackets/tree/main/examples) - converted examples
|
|
137
|
+
|
|
138
|
+
### Installing the Python package
|
|
139
|
+
|
|
140
|
+
The schema, and the Python classes and the JSON Schema that are generated from it, are on PyPI as
|
|
141
|
+
[linkml-phenopackets](https://pypi.org/project/linkml-phenopackets/):
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pip install linkml-phenopackets
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
This is NOT the official GA4GH library. That one is [phenopackets](https://pypi.org/project/phenopackets/), which
|
|
148
|
+
has the classes that are generated from the protobuf files. This package is imported as `linkml_phenopackets`, so
|
|
149
|
+
the two can be installed in the same environment.
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
# dataclasses, for the loaders and dumpers of linkml-runtime
|
|
153
|
+
from linkml_phenopackets.datamodel.phenopackets import Phenopacket
|
|
154
|
+
# Pydantic models, which have the same names
|
|
155
|
+
from linkml_phenopackets.pydantic import model
|
|
156
|
+
# the paths of the schema and of the JSON Schema in the package
|
|
157
|
+
from linkml_phenopackets.datamodel import JSON_SCHEMA_PATH, MAIN_SCHEMA_PATH
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The `p3` command and `linkml_phenopackets.utilities.ontology_utilities`, which are described below, need OAK,
|
|
161
|
+
Bioregistry and LinkML as well. These are installed with the `tools` extra:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
pip install 'linkml-phenopackets[tools]'
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
To work on the repository itself, clone it and install it with [Poetry](https://python-poetry.org/):
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
poetry install --all-extras
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
There will also be demonstrator Jupyter notebooks here:
|
|
174
|
+
|
|
175
|
+
- [notebooks](https://github.com/cmungall/linkml-phenopackets/tree/main/src/docs/notebooks) directory
|
|
176
|
+
|
|
177
|
+
### Building the documentation
|
|
178
|
+
|
|
179
|
+
The [schema docs](https://cmungall.github.io/linkml-phenopackets/) are built by [mkdocs](https://www.mkdocs.org/)
|
|
180
|
+
from the pages in [src/docs](https://github.com/cmungall/linkml-phenopackets/tree/main/src/docs) and the pages that `gen-doc` generates from the schema:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
make serve # generates the pages in docs/, and shows the site on http://127.0.0.1:8000/linkml-phenopackets/
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The generated pages use the templates that come with LinkML, except for the index page, which has a
|
|
187
|
+
template in [src/doc-templates](https://github.com/cmungall/linkml-phenopackets/tree/main/src/doc-templates). The diagram of the whole schema has a
|
|
188
|
+
[page of its own](https://github.com/cmungall/linkml-phenopackets/blob/main/src/docs/schema-diagram.md), which shows the output of `gen-erdiagram`.
|
|
189
|
+
|
|
190
|
+
On a file system that does not distinguish upper and lower case, as is usual on macOS, the page of a class
|
|
191
|
+
overwrites the page of a slot with the same name (`Age` and `age`), and mkdocs reports links that it cannot
|
|
192
|
+
find. The site that is published is built on Linux, and has both pages.
|
|
193
|
+
|
|
194
|
+
A push to `main` that changes the schema or the documentation publishes the site, see the
|
|
195
|
+
[workflow](https://github.com/cmungall/linkml-phenopackets/blob/main/.github/workflows/deploy_documentation.yml).
|
|
196
|
+
|
|
197
|
+
### Releasing the package
|
|
198
|
+
|
|
199
|
+
The version of the package is the git tag of the release without the `v`, so a tag has to be a version as PyPI
|
|
200
|
+
writes it: `v0.1.0`, or `v0.1.0rc1` for a release candidate. Publishing a
|
|
201
|
+
[release](https://github.com/cmungall/linkml-phenopackets/releases) on GitHub starts a
|
|
202
|
+
[workflow](https://github.com/cmungall/linkml-phenopackets/blob/main/.github/workflows/pypi-publish.yaml) that runs the tests, builds the package and
|
|
203
|
+
publishes it to [PyPI](https://pypi.org/project/linkml-phenopackets/).
|
|
204
|
+
|
|
205
|
+
To try out a release, publish a release candidate as a pre-release on GitHub first. `pip` only installs a
|
|
206
|
+
pre-release when it is asked for: `pip install linkml-phenopackets==0.1.0rc1`, or `pip install --pre linkml-phenopackets`.
|
|
207
|
+
|
|
208
|
+
There is no token in the repository: PyPI has this repository and the workflow as a
|
|
209
|
+
[trusted publisher](https://docs.pypi.org/trusted-publishers/) of the project.
|
|
210
|
+
|
|
211
|
+
`make check-wheel` is the check of the package that the workflow runs before it publishes. It builds the package in
|
|
212
|
+
`dist/`, installs the wheel in a new environment without the `tools` extra, and checks that the schema and the
|
|
213
|
+
classes can be loaded.
|
|
214
|
+
|
|
215
|
+
## Validation
|
|
216
|
+
|
|
217
|
+
Use `p3 validate` to validate objects (`p3` is installed with the `tools` extra). This goes beyond what can be done with JSON-Schema alone, and
|
|
218
|
+
includes ontology validation using OAK and CURIE validation using BioRegistry.
|
|
219
|
+
|
|
220
|
+
See [this notebook](https://github.com/cmungall/linkml-phenopackets/blob/main/src/docs/notebooks/OAK.ipynb)
|
|
221
|
+
|
|
222
|
+
## Repairing ontology terms
|
|
223
|
+
|
|
224
|
+
Phenopackets include ontology terms, which are liable to become stale.
|
|
225
|
+
|
|
226
|
+
This toolkit uses OAK to assist in auto-migration of obsoletes or stale labels.
|
|
227
|
+
|
|
228
|
+
See [this notebook](https://github.com/cmungall/linkml-phenopackets/blob/main/src/docs/notebooks/OAK.ipynb)
|
|
229
|
+
|
|
230
|
+
## Querying Phenopackets as RDF
|
|
231
|
+
|
|
232
|
+
TODO: Add documentation here
|
|
233
|
+
|
|
234
|
+
## Using Phenopackets in conjunction with OAK
|
|
235
|
+
|
|
236
|
+
TODO: Add documentation here
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Phenopackets linkml schema
|
|
2
|
+
|
|
3
|
+
Browse the autogenerated schema documentation here:
|
|
4
|
+
|
|
5
|
+
* [https://cmungall.github.io/linkml-phenopackets/](https://cmungall.github.io/linkml-phenopackets/)
|
|
6
|
+
|
|
7
|
+
Note the linkml markdown rendering is still incomplete, for a full schema, see
|
|
8
|
+
|
|
9
|
+
* [src/linkml_phenopackets/schema](https://github.com/cmungall/linkml-phenopackets/tree/main/src/linkml_phenopackets/schema)
|
|
10
|
+
|
|
11
|
+
## What is this repo and how was it made?
|
|
12
|
+
|
|
13
|
+
This is a rendering of the [phenopackets](https://phenopacket-schema.readthedocs.io/) schema in LinkML.
|
|
14
|
+
It is NOT the official GA4GH phenopackets schema.
|
|
15
|
+
|
|
16
|
+
The intent is to demonstrate some of the tooling and integrative capabilities of LinkML over Protobuf, in particular:
|
|
17
|
+
|
|
18
|
+
- Additional validation not possible in Protobuf, including:
|
|
19
|
+
- required fields
|
|
20
|
+
- ontology constraints
|
|
21
|
+
- Generation of python classes and tooling
|
|
22
|
+
- Export/Import phenopackets from to and from RDF
|
|
23
|
+
- Semantic annotation of schemas
|
|
24
|
+
- Cross-schema integration
|
|
25
|
+
|
|
26
|
+
The LinkML schema is generated using a script [proto2linkml](https://github.com/cmungall/linkml-phenopackets/blob/main/util/proto2linkml.pl) that converts from the Protobuf source. This makes
|
|
27
|
+
use of specific *conventions* in the Protobuf source, such as the use of particular controlled
|
|
28
|
+
keywords in `//` comments. As such, this code is *not* generalizable to other protobuf schemas.
|
|
29
|
+
|
|
30
|
+
Note we intentionally don't use out of band-info. We have not done additional curation based on the `.rst` docs,
|
|
31
|
+
it comes from protobuf.
|
|
32
|
+
|
|
33
|
+
### Which version of Phenopackets is this?
|
|
34
|
+
|
|
35
|
+
The schema corresponds to [release 2.0.0](https://github.com/phenopackets/phenopacket-schema/releases/tag/2.0.0)
|
|
36
|
+
of phenopacket-schema. The root module, [phenopackets.yaml](https://github.com/cmungall/linkml-phenopackets/blob/main/src/linkml_phenopackets/schema/phenopackets.yaml), names the
|
|
37
|
+
protobuf file of that release as its `source`.
|
|
38
|
+
|
|
39
|
+
The release is set in the [Makefile](https://github.com/cmungall/linkml-phenopackets/blob/main/Makefile), together with the two things that the release itself depends on:
|
|
40
|
+
the commit of [vrs-protobuf](https://github.com/ga4gh/vrs-protobuf) that it includes as a git submodule, and the
|
|
41
|
+
version of Protobuf that its `Timestamp` and `Any` types come from. To generate the schema again, and then
|
|
42
|
+
everything that is derived from it:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
make auto deploy # downloads the protobuf files of the release and converts them
|
|
46
|
+
make descriptors # only needed after changing the release or a pin, see below
|
|
47
|
+
make all py jsonschema src/linkml_phenopackets/pydantic/model.py
|
|
48
|
+
make test sync-examples
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`make test` compares the schema with what `protoc` makes of the same protobuf files, which is stored in
|
|
52
|
+
[tests/input](https://github.com/cmungall/linkml-phenopackets/tree/main/tests/input) by `make descriptors`. Every message, field, oneof and enum of the release has to be
|
|
53
|
+
in the schema, with its documentation, and the generated modules may not define anything else. See
|
|
54
|
+
[tests/test_schema](https://github.com/cmungall/linkml-phenopackets/blob/main/tests/test_schema/test_protobuf_conformance.py), which also describes how each protobuf
|
|
55
|
+
construct is translated. `make test` also generates the Python classes and the JSON Schema again, and fails when they differ from
|
|
56
|
+
the ones in the repository.
|
|
57
|
+
|
|
58
|
+
### Differences from protobuf
|
|
59
|
+
|
|
60
|
+
The schema describes a phenopacket as it is written in JSON or YAML: attributes are named after the JSON names
|
|
61
|
+
of the fields (`individual_id` is `individualId`, and the VRS `_id` fields are `Id`). A few things are not
|
|
62
|
+
carried over exactly:
|
|
63
|
+
|
|
64
|
+
- **Requirement levels.** A field is required only if its protobuf comment says `REQUIRED`. The documentation
|
|
65
|
+
of the release marks many more fields as required or recommended (`Phenopacket.id` for example). These
|
|
66
|
+
are not in the protobuf files, and so they are not in the schema.
|
|
67
|
+
- **Maps.** `File.fileAttributes` and `File.individualToFileIdentifiers` are `map<string, string>` fields.
|
|
68
|
+
They are dictionaries of `DictionaryEntry` objects. The `{key: value}` form of protobuf is valid; the Python
|
|
69
|
+
classes write `{key: {key: ..., value: ...}}`.
|
|
70
|
+
- **64 bit integers.** `VcfRecord.pos` and the positions and counts in VRS are integers. Protobuf writes them as
|
|
71
|
+
strings in JSON (`"pos": "45989626"`), which the Python classes convert, but which `linkml-validate` reports
|
|
72
|
+
as errors. Convert such a file with `linkml-convert` before validating it.
|
|
73
|
+
- **Timestamps** are strings, as they are in JSON.
|
|
74
|
+
- **`Extension.value`** is a list of strings. In release 2.0.0 it is a list of `google.protobuf.Any`. Later
|
|
75
|
+
versions of phenopacket-schema (2.0.1 and up, used by phenopacket-tools) changed it to a single string.
|
|
76
|
+
- **Oneofs.** A `oneof` is a rule that says that exactly one of its fields is required, which is how the
|
|
77
|
+
documentation describes them. Protobuf also accepts a message with none of them. Neither `linkml-validate`
|
|
78
|
+
nor the Python classes check these rules.
|
|
79
|
+
|
|
80
|
+
## Ontology Enhancements
|
|
81
|
+
|
|
82
|
+
The file [cv_terms.yaml](https://github.com/cmungall/linkml-phenopackets/blob/main/src/linkml_phenopackets/schema/cv_terms.yaml)
|
|
83
|
+
is hand-curated, rather than derived from the YAML. It is based on: [recommended ontologies](https://phenopacket-schema.readthedocs.io/en/latest/recommended-ontologies.html)
|
|
84
|
+
from the official phenopackets repo. It makes use of *dynamic enums* which allows for more advanced
|
|
85
|
+
ontology checking; for example:
|
|
86
|
+
|
|
87
|
+
* Uberon anatomy terms must be found under the "anatomical entity branch"
|
|
88
|
+
* HPO abnormality terms must be found under the "phenotypic abnormality branch"
|
|
89
|
+
|
|
90
|
+
etc
|
|
91
|
+
|
|
92
|
+
We also include [constants.yaml](https://github.com/cmungall/linkml-phenopackets/blob/main/src/linkml_phenopackets/schema/constants.yaml)
|
|
93
|
+
which is a direct transform from the phenopackets-tools repo.
|
|
94
|
+
|
|
95
|
+
## How to use this repo
|
|
96
|
+
|
|
97
|
+
You can browse the [schema docs](https://cmungall.github.io/linkml-phenopackets/) which are generated from the LinkML
|
|
98
|
+
schema.
|
|
99
|
+
|
|
100
|
+
You can also explore the schema in the [schema](https://github.com/cmungall/linkml-phenopackets/tree/main/src/linkml_phenopackets/schema) directory.
|
|
101
|
+
|
|
102
|
+
As part of the build process, we also validate and convert all canonical Phenopacket examples into YAML, JSON,
|
|
103
|
+
and RDF.
|
|
104
|
+
|
|
105
|
+
* [examples/](https://github.com/cmungall/linkml-phenopackets/tree/main/examples) - converted examples
|
|
106
|
+
|
|
107
|
+
### Installing the Python package
|
|
108
|
+
|
|
109
|
+
The schema, and the Python classes and the JSON Schema that are generated from it, are on PyPI as
|
|
110
|
+
[linkml-phenopackets](https://pypi.org/project/linkml-phenopackets/):
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
pip install linkml-phenopackets
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
This is NOT the official GA4GH library. That one is [phenopackets](https://pypi.org/project/phenopackets/), which
|
|
117
|
+
has the classes that are generated from the protobuf files. This package is imported as `linkml_phenopackets`, so
|
|
118
|
+
the two can be installed in the same environment.
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
# dataclasses, for the loaders and dumpers of linkml-runtime
|
|
122
|
+
from linkml_phenopackets.datamodel.phenopackets import Phenopacket
|
|
123
|
+
# Pydantic models, which have the same names
|
|
124
|
+
from linkml_phenopackets.pydantic import model
|
|
125
|
+
# the paths of the schema and of the JSON Schema in the package
|
|
126
|
+
from linkml_phenopackets.datamodel import JSON_SCHEMA_PATH, MAIN_SCHEMA_PATH
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The `p3` command and `linkml_phenopackets.utilities.ontology_utilities`, which are described below, need OAK,
|
|
130
|
+
Bioregistry and LinkML as well. These are installed with the `tools` extra:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pip install 'linkml-phenopackets[tools]'
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
To work on the repository itself, clone it and install it with [Poetry](https://python-poetry.org/):
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
poetry install --all-extras
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
There will also be demonstrator Jupyter notebooks here:
|
|
143
|
+
|
|
144
|
+
- [notebooks](https://github.com/cmungall/linkml-phenopackets/tree/main/src/docs/notebooks) directory
|
|
145
|
+
|
|
146
|
+
### Building the documentation
|
|
147
|
+
|
|
148
|
+
The [schema docs](https://cmungall.github.io/linkml-phenopackets/) are built by [mkdocs](https://www.mkdocs.org/)
|
|
149
|
+
from the pages in [src/docs](https://github.com/cmungall/linkml-phenopackets/tree/main/src/docs) and the pages that `gen-doc` generates from the schema:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
make serve # generates the pages in docs/, and shows the site on http://127.0.0.1:8000/linkml-phenopackets/
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The generated pages use the templates that come with LinkML, except for the index page, which has a
|
|
156
|
+
template in [src/doc-templates](https://github.com/cmungall/linkml-phenopackets/tree/main/src/doc-templates). The diagram of the whole schema has a
|
|
157
|
+
[page of its own](https://github.com/cmungall/linkml-phenopackets/blob/main/src/docs/schema-diagram.md), which shows the output of `gen-erdiagram`.
|
|
158
|
+
|
|
159
|
+
On a file system that does not distinguish upper and lower case, as is usual on macOS, the page of a class
|
|
160
|
+
overwrites the page of a slot with the same name (`Age` and `age`), and mkdocs reports links that it cannot
|
|
161
|
+
find. The site that is published is built on Linux, and has both pages.
|
|
162
|
+
|
|
163
|
+
A push to `main` that changes the schema or the documentation publishes the site, see the
|
|
164
|
+
[workflow](https://github.com/cmungall/linkml-phenopackets/blob/main/.github/workflows/deploy_documentation.yml).
|
|
165
|
+
|
|
166
|
+
### Releasing the package
|
|
167
|
+
|
|
168
|
+
The version of the package is the git tag of the release without the `v`, so a tag has to be a version as PyPI
|
|
169
|
+
writes it: `v0.1.0`, or `v0.1.0rc1` for a release candidate. Publishing a
|
|
170
|
+
[release](https://github.com/cmungall/linkml-phenopackets/releases) on GitHub starts a
|
|
171
|
+
[workflow](https://github.com/cmungall/linkml-phenopackets/blob/main/.github/workflows/pypi-publish.yaml) that runs the tests, builds the package and
|
|
172
|
+
publishes it to [PyPI](https://pypi.org/project/linkml-phenopackets/).
|
|
173
|
+
|
|
174
|
+
To try out a release, publish a release candidate as a pre-release on GitHub first. `pip` only installs a
|
|
175
|
+
pre-release when it is asked for: `pip install linkml-phenopackets==0.1.0rc1`, or `pip install --pre linkml-phenopackets`.
|
|
176
|
+
|
|
177
|
+
There is no token in the repository: PyPI has this repository and the workflow as a
|
|
178
|
+
[trusted publisher](https://docs.pypi.org/trusted-publishers/) of the project.
|
|
179
|
+
|
|
180
|
+
`make check-wheel` is the check of the package that the workflow runs before it publishes. It builds the package in
|
|
181
|
+
`dist/`, installs the wheel in a new environment without the `tools` extra, and checks that the schema and the
|
|
182
|
+
classes can be loaded.
|
|
183
|
+
|
|
184
|
+
## Validation
|
|
185
|
+
|
|
186
|
+
Use `p3 validate` to validate objects (`p3` is installed with the `tools` extra). This goes beyond what can be done with JSON-Schema alone, and
|
|
187
|
+
includes ontology validation using OAK and CURIE validation using BioRegistry.
|
|
188
|
+
|
|
189
|
+
See [this notebook](https://github.com/cmungall/linkml-phenopackets/blob/main/src/docs/notebooks/OAK.ipynb)
|
|
190
|
+
|
|
191
|
+
## Repairing ontology terms
|
|
192
|
+
|
|
193
|
+
Phenopackets include ontology terms, which are liable to become stale.
|
|
194
|
+
|
|
195
|
+
This toolkit uses OAK to assist in auto-migration of obsoletes or stale labels.
|
|
196
|
+
|
|
197
|
+
See [this notebook](https://github.com/cmungall/linkml-phenopackets/blob/main/src/docs/notebooks/OAK.ipynb)
|
|
198
|
+
|
|
199
|
+
## Querying Phenopackets as RDF
|
|
200
|
+
|
|
201
|
+
TODO: Add documentation here
|
|
202
|
+
|
|
203
|
+
## Using Phenopackets in conjunction with OAK
|
|
204
|
+
|
|
205
|
+
TODO: Add documentation here
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|