pyobo 0.11.1__py3-none-any.whl → 0.12.0__py3-none-any.whl

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.
Files changed (242) hide show
  1. pyobo/.DS_Store +0 -0
  2. pyobo/__init__.py +95 -20
  3. pyobo/__main__.py +0 -0
  4. pyobo/api/__init__.py +81 -10
  5. pyobo/api/alts.py +52 -42
  6. pyobo/api/combine.py +39 -0
  7. pyobo/api/edges.py +68 -0
  8. pyobo/api/hierarchy.py +231 -203
  9. pyobo/api/metadata.py +14 -19
  10. pyobo/api/names.py +207 -127
  11. pyobo/api/properties.py +117 -113
  12. pyobo/api/relations.py +68 -94
  13. pyobo/api/species.py +24 -21
  14. pyobo/api/typedefs.py +11 -11
  15. pyobo/api/utils.py +66 -13
  16. pyobo/api/xrefs.py +108 -114
  17. pyobo/cli/__init__.py +0 -0
  18. pyobo/cli/cli.py +35 -50
  19. pyobo/cli/database.py +183 -161
  20. pyobo/{xrefdb/xrefs_pipeline.py → cli/database_utils.py} +54 -73
  21. pyobo/cli/lookup.py +163 -195
  22. pyobo/cli/utils.py +19 -6
  23. pyobo/constants.py +102 -3
  24. pyobo/getters.py +196 -118
  25. pyobo/gilda_utils.py +79 -200
  26. pyobo/identifier_utils/__init__.py +41 -0
  27. pyobo/identifier_utils/api.py +296 -0
  28. pyobo/identifier_utils/model.py +130 -0
  29. pyobo/identifier_utils/preprocessing.json +812 -0
  30. pyobo/identifier_utils/preprocessing.py +61 -0
  31. pyobo/identifier_utils/relations/__init__.py +8 -0
  32. pyobo/identifier_utils/relations/api.py +162 -0
  33. pyobo/identifier_utils/relations/data.json +5824 -0
  34. pyobo/identifier_utils/relations/data_owl.json +57 -0
  35. pyobo/identifier_utils/relations/data_rdf.json +1 -0
  36. pyobo/identifier_utils/relations/data_rdfs.json +7 -0
  37. pyobo/mocks.py +9 -6
  38. pyobo/ner/__init__.py +9 -0
  39. pyobo/ner/api.py +72 -0
  40. pyobo/ner/normalizer.py +33 -0
  41. pyobo/obographs.py +43 -39
  42. pyobo/plugins.py +5 -4
  43. pyobo/py.typed +0 -0
  44. pyobo/reader.py +1358 -395
  45. pyobo/reader_utils.py +155 -0
  46. pyobo/resource_utils.py +42 -22
  47. pyobo/resources/__init__.py +0 -0
  48. pyobo/resources/goc.py +75 -0
  49. pyobo/resources/goc.tsv +188 -0
  50. pyobo/resources/ncbitaxon.py +4 -5
  51. pyobo/resources/ncbitaxon.tsv.gz +0 -0
  52. pyobo/resources/ro.py +3 -2
  53. pyobo/resources/ro.tsv +0 -0
  54. pyobo/resources/so.py +0 -0
  55. pyobo/resources/so.tsv +0 -0
  56. pyobo/sources/README.md +12 -8
  57. pyobo/sources/__init__.py +52 -29
  58. pyobo/sources/agrovoc.py +0 -0
  59. pyobo/sources/antibodyregistry.py +11 -12
  60. pyobo/sources/bigg/__init__.py +13 -0
  61. pyobo/sources/bigg/bigg_compartment.py +81 -0
  62. pyobo/sources/bigg/bigg_metabolite.py +229 -0
  63. pyobo/sources/bigg/bigg_model.py +46 -0
  64. pyobo/sources/bigg/bigg_reaction.py +77 -0
  65. pyobo/sources/biogrid.py +1 -2
  66. pyobo/sources/ccle.py +7 -12
  67. pyobo/sources/cgnc.py +0 -5
  68. pyobo/sources/chebi.py +1 -1
  69. pyobo/sources/chembl/__init__.py +9 -0
  70. pyobo/sources/{chembl.py → chembl/chembl_compound.py} +13 -25
  71. pyobo/sources/chembl/chembl_target.py +160 -0
  72. pyobo/sources/civic_gene.py +55 -15
  73. pyobo/sources/clinicaltrials.py +160 -0
  74. pyobo/sources/complexportal.py +24 -24
  75. pyobo/sources/conso.py +14 -22
  76. pyobo/sources/cpt.py +0 -0
  77. pyobo/sources/credit.py +1 -9
  78. pyobo/sources/cvx.py +27 -5
  79. pyobo/sources/depmap.py +9 -12
  80. pyobo/sources/dictybase_gene.py +2 -7
  81. pyobo/sources/drugbank/__init__.py +9 -0
  82. pyobo/sources/{drugbank.py → drugbank/drugbank.py} +11 -16
  83. pyobo/sources/{drugbank_salt.py → drugbank/drugbank_salt.py} +3 -8
  84. pyobo/sources/drugcentral.py +17 -13
  85. pyobo/sources/expasy.py +31 -34
  86. pyobo/sources/famplex.py +13 -18
  87. pyobo/sources/flybase.py +3 -8
  88. pyobo/sources/gard.py +62 -0
  89. pyobo/sources/geonames/__init__.py +9 -0
  90. pyobo/sources/geonames/features.py +28 -0
  91. pyobo/sources/{geonames.py → geonames/geonames.py} +87 -26
  92. pyobo/sources/geonames/utils.py +115 -0
  93. pyobo/sources/gmt_utils.py +6 -7
  94. pyobo/sources/go.py +20 -13
  95. pyobo/sources/gtdb.py +154 -0
  96. pyobo/sources/gwascentral/__init__.py +9 -0
  97. pyobo/sources/{gwascentral_phenotype.py → gwascentral/gwascentral_phenotype.py} +5 -7
  98. pyobo/sources/{gwascentral_study.py → gwascentral/gwascentral_study.py} +1 -7
  99. pyobo/sources/hgnc/__init__.py +9 -0
  100. pyobo/sources/{hgnc.py → hgnc/hgnc.py} +56 -70
  101. pyobo/sources/{hgncgenefamily.py → hgnc/hgncgenefamily.py} +8 -18
  102. pyobo/sources/icd/__init__.py +9 -0
  103. pyobo/sources/{icd10.py → icd/icd10.py} +35 -37
  104. pyobo/sources/icd/icd11.py +148 -0
  105. pyobo/sources/{icd_utils.py → icd/icd_utils.py} +66 -20
  106. pyobo/sources/interpro.py +4 -9
  107. pyobo/sources/itis.py +0 -5
  108. pyobo/sources/kegg/__init__.py +0 -0
  109. pyobo/sources/kegg/api.py +16 -38
  110. pyobo/sources/kegg/genes.py +9 -20
  111. pyobo/sources/kegg/genome.py +1 -7
  112. pyobo/sources/kegg/pathway.py +9 -21
  113. pyobo/sources/mesh.py +58 -24
  114. pyobo/sources/mgi.py +3 -10
  115. pyobo/sources/mirbase/__init__.py +11 -0
  116. pyobo/sources/{mirbase.py → mirbase/mirbase.py} +8 -11
  117. pyobo/sources/{mirbase_constants.py → mirbase/mirbase_constants.py} +0 -0
  118. pyobo/sources/{mirbase_family.py → mirbase/mirbase_family.py} +4 -8
  119. pyobo/sources/{mirbase_mature.py → mirbase/mirbase_mature.py} +3 -7
  120. pyobo/sources/msigdb.py +74 -39
  121. pyobo/sources/ncbi/__init__.py +9 -0
  122. pyobo/sources/ncbi/ncbi_gc.py +162 -0
  123. pyobo/sources/{ncbigene.py → ncbi/ncbigene.py} +18 -19
  124. pyobo/sources/nih_reporter.py +60 -0
  125. pyobo/sources/nlm/__init__.py +9 -0
  126. pyobo/sources/nlm/nlm_catalog.py +48 -0
  127. pyobo/sources/nlm/nlm_publisher.py +36 -0
  128. pyobo/sources/nlm/utils.py +116 -0
  129. pyobo/sources/npass.py +6 -8
  130. pyobo/sources/omim_ps.py +10 -3
  131. pyobo/sources/pathbank.py +4 -8
  132. pyobo/sources/pfam/__init__.py +9 -0
  133. pyobo/sources/{pfam.py → pfam/pfam.py} +3 -8
  134. pyobo/sources/{pfam_clan.py → pfam/pfam_clan.py} +2 -7
  135. pyobo/sources/pharmgkb/__init__.py +15 -0
  136. pyobo/sources/pharmgkb/pharmgkb_chemical.py +89 -0
  137. pyobo/sources/pharmgkb/pharmgkb_disease.py +77 -0
  138. pyobo/sources/pharmgkb/pharmgkb_gene.py +108 -0
  139. pyobo/sources/pharmgkb/pharmgkb_pathway.py +63 -0
  140. pyobo/sources/pharmgkb/pharmgkb_variant.py +84 -0
  141. pyobo/sources/pharmgkb/utils.py +86 -0
  142. pyobo/sources/pid.py +1 -6
  143. pyobo/sources/pombase.py +6 -10
  144. pyobo/sources/pubchem.py +4 -9
  145. pyobo/sources/reactome.py +5 -11
  146. pyobo/sources/rgd.py +11 -16
  147. pyobo/sources/rhea.py +37 -36
  148. pyobo/sources/ror.py +69 -42
  149. pyobo/sources/selventa/__init__.py +0 -0
  150. pyobo/sources/selventa/schem.py +4 -7
  151. pyobo/sources/selventa/scomp.py +1 -6
  152. pyobo/sources/selventa/sdis.py +4 -7
  153. pyobo/sources/selventa/sfam.py +1 -6
  154. pyobo/sources/sgd.py +6 -11
  155. pyobo/sources/signor/__init__.py +7 -0
  156. pyobo/sources/signor/download.py +41 -0
  157. pyobo/sources/signor/signor_complexes.py +105 -0
  158. pyobo/sources/slm.py +12 -15
  159. pyobo/sources/umls/__init__.py +7 -1
  160. pyobo/sources/umls/__main__.py +0 -0
  161. pyobo/sources/umls/get_synonym_types.py +20 -4
  162. pyobo/sources/umls/sty.py +57 -0
  163. pyobo/sources/umls/synonym_types.tsv +1 -1
  164. pyobo/sources/umls/umls.py +18 -22
  165. pyobo/sources/unimod.py +46 -0
  166. pyobo/sources/uniprot/__init__.py +1 -1
  167. pyobo/sources/uniprot/uniprot.py +40 -32
  168. pyobo/sources/uniprot/uniprot_ptm.py +4 -34
  169. pyobo/sources/utils.py +3 -2
  170. pyobo/sources/wikipathways.py +7 -10
  171. pyobo/sources/zfin.py +5 -10
  172. pyobo/ssg/__init__.py +12 -16
  173. pyobo/ssg/base.html +0 -0
  174. pyobo/ssg/index.html +26 -13
  175. pyobo/ssg/term.html +12 -2
  176. pyobo/ssg/typedef.html +0 -0
  177. pyobo/struct/__init__.py +54 -8
  178. pyobo/struct/functional/__init__.py +1 -0
  179. pyobo/struct/functional/dsl.py +2572 -0
  180. pyobo/struct/functional/macros.py +423 -0
  181. pyobo/struct/functional/obo_to_functional.py +385 -0
  182. pyobo/struct/functional/ontology.py +270 -0
  183. pyobo/struct/functional/utils.py +112 -0
  184. pyobo/struct/reference.py +331 -136
  185. pyobo/struct/struct.py +1413 -643
  186. pyobo/struct/struct_utils.py +1078 -0
  187. pyobo/struct/typedef.py +162 -210
  188. pyobo/struct/utils.py +12 -5
  189. pyobo/struct/vocabulary.py +138 -0
  190. pyobo/utils/__init__.py +0 -0
  191. pyobo/utils/cache.py +13 -11
  192. pyobo/utils/io.py +17 -31
  193. pyobo/utils/iter.py +5 -5
  194. pyobo/utils/misc.py +41 -53
  195. pyobo/utils/ndex_utils.py +0 -0
  196. pyobo/utils/path.py +76 -70
  197. pyobo/version.py +3 -3
  198. {pyobo-0.11.1.dist-info → pyobo-0.12.0.dist-info}/METADATA +224 -225
  199. pyobo-0.12.0.dist-info/RECORD +202 -0
  200. pyobo-0.12.0.dist-info/WHEEL +4 -0
  201. {pyobo-0.11.1.dist-info → pyobo-0.12.0.dist-info}/entry_points.txt +1 -0
  202. {pyobo-0.11.1.dist-info → pyobo-0.12.0.dist-info/licenses}/LICENSE +0 -0
  203. pyobo/apps/__init__.py +0 -3
  204. pyobo/apps/cli.py +0 -24
  205. pyobo/apps/gilda/__init__.py +0 -3
  206. pyobo/apps/gilda/__main__.py +0 -8
  207. pyobo/apps/gilda/app.py +0 -48
  208. pyobo/apps/gilda/cli.py +0 -36
  209. pyobo/apps/gilda/templates/base.html +0 -33
  210. pyobo/apps/gilda/templates/home.html +0 -11
  211. pyobo/apps/gilda/templates/matches.html +0 -32
  212. pyobo/apps/mapper/__init__.py +0 -3
  213. pyobo/apps/mapper/__main__.py +0 -11
  214. pyobo/apps/mapper/cli.py +0 -37
  215. pyobo/apps/mapper/mapper.py +0 -187
  216. pyobo/apps/mapper/templates/base.html +0 -35
  217. pyobo/apps/mapper/templates/mapper_home.html +0 -64
  218. pyobo/aws.py +0 -162
  219. pyobo/cli/aws.py +0 -47
  220. pyobo/identifier_utils.py +0 -142
  221. pyobo/normalizer.py +0 -232
  222. pyobo/registries/__init__.py +0 -16
  223. pyobo/registries/metaregistry.json +0 -507
  224. pyobo/registries/metaregistry.py +0 -135
  225. pyobo/sources/icd11.py +0 -105
  226. pyobo/xrefdb/__init__.py +0 -1
  227. pyobo/xrefdb/canonicalizer.py +0 -214
  228. pyobo/xrefdb/priority.py +0 -59
  229. pyobo/xrefdb/sources/__init__.py +0 -60
  230. pyobo/xrefdb/sources/biomappings.py +0 -36
  231. pyobo/xrefdb/sources/cbms2019.py +0 -91
  232. pyobo/xrefdb/sources/chembl.py +0 -83
  233. pyobo/xrefdb/sources/compath.py +0 -82
  234. pyobo/xrefdb/sources/famplex.py +0 -64
  235. pyobo/xrefdb/sources/gilda.py +0 -50
  236. pyobo/xrefdb/sources/intact.py +0 -113
  237. pyobo/xrefdb/sources/ncit.py +0 -133
  238. pyobo/xrefdb/sources/pubchem.py +0 -27
  239. pyobo/xrefdb/sources/wikidata.py +0 -116
  240. pyobo-0.11.1.dist-info/RECORD +0 -173
  241. pyobo-0.11.1.dist-info/WHEEL +0 -5
  242. pyobo-0.11.1.dist-info/top_level.txt +0 -1
pyobo/struct/typedef.py CHANGED
@@ -1,202 +1,91 @@
1
1
  """Default typedefs, references, and other structures."""
2
2
 
3
- from collections.abc import Iterable
4
- from dataclasses import dataclass, field
5
- from typing import Optional, Union
3
+ from __future__ import annotations
6
4
 
7
- from .reference import Reference, Referenced
8
- from ..identifier_utils import normalize_curie
5
+ from collections.abc import Sequence
6
+
7
+ from curies import ReferenceTuple
8
+
9
+ from . import vocabulary as v
10
+ from .reference import Reference, default_reference
11
+ from .struct import TypeDef
9
12
  from ..resources.ro import load_ro
10
13
 
11
14
  __all__ = [
12
- "TypeDef",
13
- "RelationHint",
14
- "get_reference_tuple",
15
+ "alternative_term",
16
+ "broad_match",
17
+ "close_match",
15
18
  "default_typedefs",
19
+ "editor_note",
20
+ "enables",
21
+ "exact_match",
22
+ "example_of_usage",
16
23
  "from_species",
17
- "species_specific",
24
+ "gene_product_member_of",
25
+ "has_contributor",
26
+ "has_dbxref",
27
+ "has_end_date",
28
+ "has_gene_product",
29
+ "has_homepage",
30
+ "has_inchi",
31
+ "has_mature",
32
+ "has_member",
18
33
  "has_part",
19
- "part_of",
34
+ "has_participant",
35
+ "has_predecessor",
36
+ "has_role",
37
+ "has_salt",
38
+ "has_smiles",
39
+ "has_start_date",
40
+ "has_successor",
41
+ "has_taxonomy_rank",
20
42
  "is_a",
21
- "see_also",
22
- "has_member",
43
+ "located_in",
44
+ "mapping_has_confidence",
45
+ "mapping_has_justification",
46
+ "match_typedefs",
23
47
  "member_of",
24
- "superclass_of",
48
+ "narrow_match",
25
49
  "orthologous",
26
- "has_role",
50
+ "part_of",
51
+ "participates_in",
52
+ "related_match",
27
53
  "role_of",
28
- "has_mature",
29
- "has_gene_product",
30
- "gene_product_member_of",
31
- "has_gene_product",
54
+ "see_also",
55
+ "species_specific",
56
+ "superclass_of",
32
57
  "transcribes_to",
33
58
  "translates_to",
34
- "gene_product_member_of",
35
- "example_of_usage",
36
- "alternative_term",
37
- "editor_note",
38
- "has_salt",
39
- "enables",
40
- "participates_in",
41
- "has_participant",
42
- "exact_match",
43
- "has_dbxref",
44
- "located_in",
45
- "has_successor",
46
- "has_predecessor",
47
- # Properties
48
- "has_inchi",
49
- "has_smiles",
50
- "has_homepage",
51
59
  ]
52
60
 
53
-
54
- def _bool_to_obo(v: bool) -> str:
55
- return "true" if v else "false"
56
-
57
-
58
- @dataclass
59
- class TypeDef(Referenced):
60
- """A type definition in OBO.
61
-
62
- See the subsection of https://owlcollab.github.io/oboformat/doc/GO.format.obo-1_4.html#S.2.2.
63
- """
64
-
65
- reference: Reference
66
- comment: Optional[str] = None
67
- namespace: Optional[str] = None
68
- definition: Optional[str] = None
69
- is_transitive: Optional[bool] = None
70
- is_symmetric: Optional[bool] = None
71
- domain: Optional[Reference] = None
72
- range: Optional[Reference] = None
73
- parents: list[Reference] = field(default_factory=list)
74
- xrefs: list[Reference] = field(default_factory=list)
75
- inverse: Optional[Reference] = None
76
- created_by: Optional[str] = None
77
- holds_over_chain: Optional[list[Reference]] = None
78
- #: Whether this relationship is a metadata tag. Properties that are marked as metadata tags are
79
- #: used to record object metadata. Object metadata is additional information about an object
80
- #: that is useful to track, but does not impact the definition of the object or how it should
81
- #: be treated by a reasoner. Metadata tags might be used to record special term synonyms or
82
- #: structured notes about a term, for example.
83
- is_metadata_tag: Optional[bool] = None
84
-
85
- def __hash__(self) -> int:
86
- return hash((self.__class__, self.prefix, self.identifier))
87
-
88
- def iterate_obo_lines(self) -> Iterable[str]:
89
- """Iterate over the lines to write in an OBO file."""
90
- yield "\n[Typedef]"
91
- yield f"id: {self.reference.preferred_curie}"
92
- if self.name:
93
- yield f"name: {self.reference.name}"
94
- if self.definition:
95
- yield f'def: "{self.definition}"'
96
-
97
- if self.is_metadata_tag is not None:
98
- yield f"is_metadata_tag: {_bool_to_obo(self.is_metadata_tag)}"
99
-
100
- if self.namespace:
101
- yield f"namespace: {self.namespace}"
102
-
103
- if self.created_by:
104
- yield f"created_by: {self.created_by}"
105
-
106
- if self.comment:
107
- yield f"comment: {self.comment}"
108
-
109
- for xref in self.xrefs:
110
- yield f"xref: {xref.preferred_curie}"
111
-
112
- if self.is_transitive is not None:
113
- yield f'is_transitive: {"true" if self.is_transitive else "false"}'
114
-
115
- if self.is_symmetric is not None:
116
- yield f'is_symmetric: {"true" if self.is_symmetric else "false"}'
117
- if self.holds_over_chain:
118
- _chain = " ".join(link.preferred_curie for link in self.holds_over_chain)
119
- _names = " / ".join(link.name or "_" for link in self.holds_over_chain)
120
- yield f"holds_over_chain: {_chain} ! {_names}"
121
- if self.inverse:
122
- yield f"inverse_of: {self.inverse}"
123
- if self.domain:
124
- yield f"domain: {self.domain}"
125
- if self.range:
126
- yield f"range: {self.range}"
127
-
128
- @classmethod
129
- def from_triple(cls, prefix: str, identifier: str, name: Optional[str] = None) -> "TypeDef":
130
- """Create a typedef from a reference."""
131
- return cls(reference=Reference(prefix=prefix, identifier=identifier, name=name))
132
-
133
- @classmethod
134
- def from_curie(cls, curie: str, name: Optional[str] = None) -> "TypeDef":
135
- """Create a TypeDef directly from a CURIE and optional name."""
136
- prefix, identifier = normalize_curie(curie)
137
- if prefix is None or identifier is None:
138
- raise ValueError
139
- return cls.from_triple(prefix=prefix, identifier=identifier, name=name)
140
-
141
-
142
- RelationHint = Union[Reference, TypeDef, tuple[str, str], str]
143
-
144
-
145
- def get_reference_tuple(relation: RelationHint) -> tuple[str, str]:
146
- """Get tuple for typedef/reference."""
147
- if isinstance(relation, (Reference, TypeDef)):
148
- return relation.prefix, relation.identifier
149
- elif isinstance(relation, tuple):
150
- return relation
151
- elif isinstance(relation, str):
152
- prefix, identifier = normalize_curie(relation)
153
- if prefix is None or identifier is None:
154
- raise ValueError(f"string given is not valid curie: {relation}")
155
- return prefix, identifier
156
- else:
157
- raise TypeError(f"Relation is invalid type: {relation}")
158
-
159
-
160
61
  RO_PREFIX = "RO"
161
62
  BFO_PREFIX = "BFO"
162
63
  IAO_PREFIX = "IAO"
163
64
  SIO_PREFIX = "SIO"
164
65
 
165
- from_species = TypeDef(
166
- reference=Reference(prefix=RO_PREFIX, identifier="0002162", name="in taxon"),
167
- )
66
+ from_species = TypeDef(reference=v.from_species)
168
67
  species_specific = TypeDef(
169
- reference=Reference(prefix="debio", identifier="0000007", name="species specific"),
68
+ reference=v.species_specific,
170
69
  definition="X speciesSpecific Y means that Y is a general phenomena, "
171
70
  "like a pathway, and X is the version that appears in a species. X should state which"
172
71
  "species with RO:0002162 (in taxon)",
173
72
  )
174
- has_left_to_right_reaction = TypeDef(
175
- Reference(prefix="debio", identifier="0000007", name="has left-to-right reaction"),
176
- is_metadata_tag=True,
177
- )
178
- has_right_to_left_reaction = TypeDef(
179
- Reference(prefix="debio", identifier="0000008", name="has right-to-left reaction"),
180
- is_metadata_tag=True,
181
- )
73
+ has_left_to_right_reaction = TypeDef(v.has_left_to_right_reaction, is_metadata_tag=True)
74
+ has_right_to_left_reaction = TypeDef(v.has_right_to_left_reaction, is_metadata_tag=True)
182
75
  has_bidirectional_reaction = TypeDef(
183
- Reference(prefix="debio", identifier="0000009", name="has bi-directional reaction"),
76
+ reference=default_reference("RO", "hasBiDirectionalReaction"),
184
77
  is_metadata_tag=True,
185
- )
78
+ ).append_xref(Reference(prefix="debio", identifier="0000009", name="has bi-directional reaction"))
186
79
  reaction_enabled_by_molecular_function = TypeDef(
80
+ reference=default_reference("RO", "reactionEnabledByMolecularFunction")
81
+ ).append_xref(
187
82
  Reference(prefix="debio", identifier="0000047", name="reaction enabled by molecular function")
188
83
  )
189
84
 
190
-
191
- part_of = TypeDef(
192
- reference=Reference(prefix=BFO_PREFIX, identifier="0000050", name="part of"),
193
- comment="Inverse of has_part",
194
- inverse=Reference(prefix=BFO_PREFIX, identifier="0000051", name="has part"),
195
- )
196
- has_part = TypeDef(
197
- reference=Reference(prefix=BFO_PREFIX, identifier="0000051", name="has part"),
198
- comment="Inverse of part_of",
199
- inverse=Reference(prefix=BFO_PREFIX, identifier="0000050", name="part of"),
85
+ part_of = TypeDef(reference=v.part_of, comment="Inverse of has_part", inverse=v.has_part)
86
+ has_part = TypeDef(reference=v.has_part, comment="Inverse of part_of", inverse=v.part_of)
87
+ occurs_in = TypeDef(
88
+ reference=Reference(prefix=BFO_PREFIX, identifier="BFO:0000066", name="occurs in")
200
89
  )
201
90
  participates_in = TypeDef(
202
91
  reference=Reference(prefix=RO_PREFIX, identifier="0000056", name="participates in"),
@@ -208,6 +97,9 @@ has_participant = TypeDef(
208
97
  comment="Inverse of has participant",
209
98
  inverse=Reference(prefix=RO_PREFIX, identifier="0000056", name="participates in"),
210
99
  )
100
+ has_component = TypeDef(
101
+ reference=Reference(prefix=RO_PREFIX, identifier="0002180", name="has component"),
102
+ )
211
103
  derives_from = TypeDef(
212
104
  reference=Reference(prefix=RO_PREFIX, identifier="0001000", name="derives from"),
213
105
  )
@@ -217,16 +109,22 @@ molecularly_interacts_with = TypeDef(
217
109
  located_in = TypeDef(
218
110
  reference=Reference(prefix=RO_PREFIX, identifier="0001025", name="located in"),
219
111
  )
220
- exact_match = TypeDef(
221
- reference=Reference(prefix="skos", identifier="exactMatch", name="exact match"),
222
- )
223
- is_a = TypeDef(
224
- reference=Reference(prefix="rdfs", identifier="subClassOf", name="subclass of"),
225
- )
226
- see_also = TypeDef(
227
- reference=Reference(prefix="rdfs", identifier="seeAlso", name="see also"),
228
- )
229
- comment = TypeDef(reference=Reference(prefix="rdfs", identifier="comment", name="comment"))
112
+ exact_match = TypeDef(reference=v.exact_match, is_metadata_tag=True)
113
+ narrow_match = TypeDef(reference=v.narrow_match, is_metadata_tag=True)
114
+ broad_match = TypeDef(reference=v.broad_match, is_metadata_tag=True)
115
+ close_match = TypeDef(reference=v.close_match, is_metadata_tag=True)
116
+ related_match = TypeDef(reference=v.related_match, is_metadata_tag=True)
117
+ owl_same_as = TypeDef(
118
+ reference=v.owl_same_as,
119
+ )
120
+ equivalent_class = TypeDef(reference=v.equivalent_class)
121
+ equivalent_property = TypeDef(reference=v.equivalent_property)
122
+
123
+ is_a = TypeDef(reference=v.is_a)
124
+ rdf_type = TypeDef(reference=v.rdf_type)
125
+ subproperty_of = TypeDef(reference=v.subproperty_of)
126
+ see_also = TypeDef(reference=v.see_also, is_metadata_tag=True)
127
+ comment = TypeDef(reference=v.comment, is_metadata_tag=True)
230
128
  has_member = TypeDef(
231
129
  reference=Reference(prefix=RO_PREFIX, identifier="0002351", name="has member"),
232
130
  )
@@ -241,12 +139,7 @@ superclass_of = TypeDef(
241
139
  )
242
140
 
243
141
  develops_from = TypeDef.from_triple(prefix=RO_PREFIX, identifier="0002202", name="develops from")
244
- orthologous = TypeDef(
245
- reference=Reference(
246
- prefix=RO_PREFIX, identifier="HOM0000017", name="in orthology relationship with"
247
- ),
248
- is_symmetric=True,
249
- )
142
+ orthologous = TypeDef(reference=v.orthologous, is_symmetric=True)
250
143
 
251
144
  has_role = TypeDef(
252
145
  reference=Reference(prefix=RO_PREFIX, identifier="0000087", name="has role"),
@@ -286,8 +179,10 @@ has_gene_product = TypeDef(
286
179
  gene_product_member_of = TypeDef(
287
180
  reference=Reference(prefix="debio", identifier="0000001", name="gene product is a member of"),
288
181
  holds_over_chain=[
289
- has_gene_product.reference,
290
- member_of.reference,
182
+ [
183
+ has_gene_product.reference,
184
+ member_of.reference,
185
+ ]
291
186
  ],
292
187
  )
293
188
 
@@ -295,24 +190,23 @@ has_salt = TypeDef(
295
190
  reference=Reference(prefix="debio", identifier="0000006", name="has salt"),
296
191
  )
297
192
 
298
- term_replaced_by = TypeDef.from_triple(
299
- prefix=IAO_PREFIX, identifier="0100001", name="term replaced by"
300
- )
301
- example_of_usage = TypeDef.from_triple(
302
- prefix=IAO_PREFIX, identifier="0000112", name="example of usage"
303
- )
304
- alternative_term = TypeDef.from_triple(
305
- prefix=IAO_PREFIX, identifier="0000118", name="alternative term"
306
- )
307
- has_ontology_root_term = TypeDef.from_triple(
308
- prefix=IAO_PREFIX, identifier="0000700", name="has ontology root term"
193
+ term_replaced_by = TypeDef(reference=v.term_replaced_by, is_metadata_tag=True)
194
+ example_of_usage = TypeDef(
195
+ reference=Reference(prefix=IAO_PREFIX, identifier="0000112", name="example of usage"),
196
+ is_metadata_tag=True,
309
197
  )
310
- definition_source = TypeDef.from_triple(
311
- prefix=IAO_PREFIX, identifier="0000119", name="definition source"
198
+ alternative_term = TypeDef(reference=v.alternative_term, is_metadata_tag=True)
199
+ has_ontology_root_term = TypeDef(reference=v.has_ontology_root_term, is_metadata_tag=True)
200
+ definition_source = TypeDef(
201
+ reference=Reference(prefix=IAO_PREFIX, identifier="0000119", name="definition source"),
202
+ is_metadata_tag=True,
312
203
  )
313
- has_dbxref = TypeDef.from_curie("oboInOwl:hasDbXref", name="has database cross-reference")
204
+ has_dbxref = TypeDef(reference=v.has_dbxref, is_metadata_tag=True)
314
205
 
315
- editor_note = TypeDef.from_triple(prefix=IAO_PREFIX, identifier="0000116", name="editor note")
206
+ editor_note = TypeDef(
207
+ reference=Reference(prefix=IAO_PREFIX, identifier="0000116", name="editor note"),
208
+ is_metadata_tag=True,
209
+ )
316
210
 
317
211
  is_immediately_transformed_from = TypeDef.from_triple(
318
212
  prefix=SIO_PREFIX, identifier="000658", name="is immediately transformed from"
@@ -329,7 +223,7 @@ has_output = TypeDef.from_triple(prefix=RO_PREFIX, identifier="0002234", name="h
329
223
  has_successor = TypeDef.from_triple(prefix="BFO", identifier="0000063", name="has successor")
330
224
  has_predecessor = TypeDef.from_triple(prefix="BFO", identifier="0000062", name="has predecessor")
331
225
 
332
- """ChEBI"""
226
+ # ChEBI
333
227
 
334
228
  is_conjugate_base_of = TypeDef(
335
229
  reference=Reference(prefix="ro", identifier="0018033", name="is conjugate base of"),
@@ -353,13 +247,15 @@ has_functional_parent = TypeDef(
353
247
  reference=Reference(prefix="ro", identifier="0018038", name="has functional parent"),
354
248
  )
355
249
 
356
- has_smiles = TypeDef(
357
- reference=Reference(prefix="debio", identifier="0000022", name="has SMILES"),
250
+ has_citation = TypeDef(
251
+ reference=v.has_citation,
252
+ is_metadata_tag=True,
253
+ range=Reference(prefix="IAO", identifier="0000013", name="journal article"),
358
254
  )
359
255
 
360
- has_inchi = TypeDef(
361
- reference=Reference(prefix="debio", identifier="0000020", name="has InChI"),
362
- )
256
+ has_smiles = TypeDef(reference=v.has_smiles, is_metadata_tag=True).append_xref(v.debio_has_smiles)
257
+
258
+ has_inchi = TypeDef(reference=v.has_inchi, is_metadata_tag=True).append_xref(v.debio_has_inchi)
363
259
 
364
260
  has_homepage = TypeDef(
365
261
  reference=Reference(prefix="foaf", identifier="homepage", name="homepage"), is_metadata_tag=True
@@ -370,10 +266,66 @@ has_category = TypeDef(
370
266
  is_metadata_tag=True,
371
267
  )
372
268
 
373
- default_typedefs: dict[tuple[str, str], TypeDef] = {
374
- v.pair: v for k, v in locals().items() if isinstance(v, TypeDef)
269
+ has_taxonomy_rank = TypeDef(
270
+ reference=Reference(prefix="taxrank", identifier="1000000", name="has rank"),
271
+ is_metadata_tag=True,
272
+ )
273
+
274
+ mapping_has_justification = TypeDef(
275
+ reference=v.mapping_has_justification,
276
+ is_metadata_tag=True,
277
+ range=Reference(prefix="semapv", identifier="Matching", name="matching process"),
278
+ )
279
+ mapping_has_confidence = TypeDef(
280
+ reference=v.mapping_has_confidence, is_metadata_tag=True, range=v.xsd_float
281
+ )
282
+ has_contributor = TypeDef(reference=v.has_contributor, is_metadata_tag=True)
283
+ has_source = TypeDef(reference=v.has_source, is_metadata_tag=True)
284
+
285
+ has_start_date = TypeDef(
286
+ reference=Reference(prefix="dcat", identifier="startDate", name="has start date"),
287
+ is_metadata_tag=True,
288
+ )
289
+ has_end_date = TypeDef(
290
+ reference=Reference(prefix="dcat", identifier="endDate", name="has end date"),
291
+ is_metadata_tag=True,
292
+ )
293
+
294
+ has_title = TypeDef(reference=v.has_title, is_metadata_tag=True)
295
+ has_license = TypeDef(reference=v.has_license, is_metadata_tag=True)
296
+ has_description = TypeDef(reference=v.has_description, is_metadata_tag=True)
297
+
298
+ in_subset = TypeDef(reference=v.in_subset, is_metadata_tag=True)
299
+ has_term_editor = TypeDef(reference=v.has_term_editor, is_metadata_tag=True)
300
+
301
+ default_typedefs: dict[ReferenceTuple, TypeDef] = {
302
+ v.pair: v for v in locals().values() if isinstance(v, TypeDef)
375
303
  }
376
304
 
377
- for pair, name in load_ro().items():
378
- if pair not in default_typedefs:
379
- default_typedefs[pair] = TypeDef.from_triple(pair[0], pair[1], name)
305
+ for reference, name in load_ro().items():
306
+ if reference not in default_typedefs:
307
+ default_typedefs[reference] = TypeDef.from_triple(
308
+ reference.prefix, reference.identifier, name
309
+ )
310
+
311
+ #: SSSOM-compliant match type definitions
312
+ #: .. seealso:: https://mapping-commons.github.io/sssom/spec-model/
313
+ match_typedefs: Sequence[TypeDef] = (
314
+ broad_match,
315
+ close_match,
316
+ exact_match,
317
+ narrow_match,
318
+ related_match,
319
+ owl_same_as, # for instances
320
+ equivalent_class, # for classes
321
+ equivalent_property, # for properties
322
+ has_dbxref,
323
+ see_also,
324
+ )
325
+
326
+ # Extension past the SSSOM spec
327
+ extended_match_typedefs = (
328
+ *match_typedefs,
329
+ alternative_term,
330
+ term_replaced_by,
331
+ )
pyobo/struct/utils.py CHANGED
@@ -1,11 +1,14 @@
1
1
  """Utilities for data structures for OBO."""
2
2
 
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Iterable
6
+
3
7
  __all__ = [
4
- "OBO_ESCAPE_SLIM",
5
8
  "OBO_ESCAPE",
9
+ "OBO_ESCAPE_SLIM",
6
10
  "obo_escape",
7
11
  "obo_escape_slim",
8
- "comma_separate",
9
12
  ]
10
13
 
11
14
  OBO_ESCAPE_SLIM = {c: f"\\{c}" for c in ':,"\\()[]{}'}
@@ -24,6 +27,10 @@ def obo_escape_slim(string: str) -> str:
24
27
  return rv
25
28
 
26
29
 
27
- def comma_separate(elements) -> str:
28
- """Map a list to strings and make comma separated."""
29
- return ", ".join(map(str, elements))
30
+ def _bool_to_obo(v: bool) -> str:
31
+ return "true" if v else "false"
32
+
33
+
34
+ def _boolean_tag(tag: str, bv: bool | None) -> Iterable[str]:
35
+ if bv is not None:
36
+ yield f"{tag}: {_bool_to_obo(bv)}"
@@ -0,0 +1,138 @@
1
+ """Reusable vocabulary."""
2
+
3
+ from collections.abc import Sequence
4
+
5
+ import curies
6
+ from curies import vocabulary as _v
7
+
8
+ from .reference import Reference, default_reference
9
+
10
+ __all__ = [
11
+ "equivalent_class",
12
+ "has_contributor",
13
+ "mapping_has_confidence",
14
+ "mapping_has_justification",
15
+ ]
16
+
17
+ RO_PREFIX = "RO"
18
+ BFO_PREFIX = "BFO"
19
+
20
+
21
+ def _c(c: curies.Reference) -> Reference:
22
+ if isinstance(c, curies.NamableReference):
23
+ return Reference(prefix=c.prefix, identifier=c.identifier, name=c.name)
24
+ else:
25
+ return Reference(prefix=c.prefix, identifier=c.identifier)
26
+
27
+
28
+ broad_match = _c(_v.broad_match)
29
+ close_match = _c(_v.close_match)
30
+ exact_match = _c(_v.exact_match)
31
+ narrow_match = _c(_v.narrow_match)
32
+ related_match = _c(_v.related_match)
33
+
34
+ has_related_synonym = _c(_v.has_related_synonym)
35
+ has_exact_synonym = _c(_v.has_exact_synonym)
36
+ has_narrow_synonym = _c(_v.has_narrow_synonym)
37
+ has_broad_synonym = _c(_v.has_broad_synonym)
38
+
39
+ mapping_has_justification = Reference(
40
+ prefix="sssom", identifier="mapping_justification", name="mapping justification"
41
+ )
42
+ mapping_has_confidence = Reference(prefix="sssom", identifier="confidence", name="has confidence")
43
+ has_contributor = _c(_v.has_contributor)
44
+ has_source = _c(_v.has_source)
45
+ has_date = _c(_v.has_date)
46
+ has_dbxref = _c(_v.has_dbxref)
47
+
48
+ in_subset = _c(_v.obo_in_subset)
49
+ has_obo_namespace = _c(_v.obo_has_namespace)
50
+ obo_autogenerated_by = _c(_v.obo_autogenerated_by)
51
+ obo_creation_date = _c(_v.obo_creation_date)
52
+
53
+ equivalent_class = _c(_v.equivalent_property)
54
+ equivalent_property = _c(_v.equivalent_class)
55
+ owl_same_as = _c(_v.same_as)
56
+ version_info = _c(_v.owl_version_info)
57
+ term_replaced_by = _c(_v.term_replaced_by)
58
+ alternative_term = _c(_v.alternative_term)
59
+ has_ontology_root_term = _c(_v.has_ontology_root_term)
60
+ has_term_editor = _c(_v.has_term_editor)
61
+
62
+ see_also = _c(_v.see_also)
63
+ comment = _c(_v.has_comment)
64
+ label = _c(_v.has_label)
65
+
66
+ from_species = Reference(prefix=RO_PREFIX, identifier="0002162", name="in taxon")
67
+ species_specific = Reference(prefix="debio", identifier="0000007", name="species specific")
68
+ has_left_to_right_reaction = Reference(
69
+ prefix="debio", identifier="0000007", name="has left-to-right reaction"
70
+ )
71
+ has_right_to_left_reaction = Reference(
72
+ prefix="debio", identifier="0000008", name="has right-to-left reaction"
73
+ )
74
+ debio_has_inchi = Reference(prefix="debio", identifier="0000020", name="has InChI")
75
+ has_inchi = Reference(prefix="chemrof", identifier="inchi_string")
76
+
77
+ debio_has_smiles = Reference(prefix="debio", identifier="0000022", name="has SMILES")
78
+ has_smiles = Reference(prefix="chemrof", identifier="smiles_string")
79
+
80
+ # TODO update to use debio, or put in RO
81
+ has_citation = default_reference(prefix="RO", identifier="hasCitation", name="has citation")
82
+ has_description = _c(_v.has_description)
83
+ has_license = _c(_v.has_license)
84
+ has_title = _c(_v.has_title)
85
+
86
+ has_part = Reference(prefix=BFO_PREFIX, identifier="0000051", name="has part")
87
+ part_of = Reference(prefix=BFO_PREFIX, identifier="0000050", name="part of")
88
+ orthologous = Reference(
89
+ prefix=RO_PREFIX, identifier="HOM0000017", name="in orthology relationship with"
90
+ )
91
+ is_a = _c(_v.is_a)
92
+ subproperty_of = _c(_v.subproperty_of)
93
+ rdf_type = _c(_v.rdf_type)
94
+
95
+ xsd_string = _c(_v.xsd_string)
96
+ xsd_float = _c(_v.xsd_float)
97
+ xsd_decimal = _c(_v.xsd_decimal)
98
+ xsd_integer = _c(_v.xsd_integer)
99
+ xsd_boolean = _c(_v.xsd_boolean)
100
+ xsd_year = _c(_v.xsd_year)
101
+ xsd_uri = _c(_v.xsd_uri)
102
+
103
+ CHARLIE = _c(_v.charlie)
104
+ HUMAN = _c(_v.human)
105
+
106
+ #: See https://mapping-commons.github.io/sssom/spec-model/
107
+ match_typedefs: Sequence[Reference] = (
108
+ broad_match,
109
+ close_match,
110
+ exact_match,
111
+ narrow_match,
112
+ related_match,
113
+ owl_same_as, # for instances
114
+ equivalent_class, # for classes
115
+ equivalent_property, # for properties
116
+ has_dbxref,
117
+ see_also,
118
+ )
119
+
120
+ # Extension past the SSSOM spec
121
+ extended_match_typedefs: Sequence[Reference] = (
122
+ *match_typedefs,
123
+ alternative_term,
124
+ term_replaced_by,
125
+ )
126
+
127
+ #: These are predicates that have their own dedicated fields
128
+ #: in OBO and FunOWL output
129
+ SKIP_PROPERTY_PREDICATES_OBJECTS = [
130
+ term_replaced_by, # maps to "replaced_by:" line
131
+ see_also, # maps to "consider:" line
132
+ alternative_term, # maps to "alt_id:" line
133
+ ]
134
+
135
+ SKIP_PROPERTY_PREDICATES_LITERAL = [
136
+ comment, # maps to "comment:" line with strings
137
+ obo_creation_date,
138
+ ]
pyobo/utils/__init__.py CHANGED
File without changes