chemrecon 0.1.1__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.
- chemrecon/__init__.py +73 -0
- chemrecon/chem/__init__.py +0 -0
- chemrecon/chem/chemreaction.py +223 -0
- chemrecon/chem/constant_compounds.py +3 -0
- chemrecon/chem/create_mol.py +91 -0
- chemrecon/chem/elements.py +141 -0
- chemrecon/chem/gml/__init__.py +0 -0
- chemrecon/chem/gml/gml.py +324 -0
- chemrecon/chem/gml/gml_reactant_matching.py +130 -0
- chemrecon/chem/gml/gml_to_rdk.py +217 -0
- chemrecon/chem/mol.py +483 -0
- chemrecon/chem/sumformula.py +120 -0
- chemrecon/connection.py +97 -0
- chemrecon/core/__init__.py +0 -0
- chemrecon/core/id_types.py +687 -0
- chemrecon/core/ontology.py +209 -0
- chemrecon/core/populate_query_handler.py +336 -0
- chemrecon/core/query_handler.py +587 -0
- chemrecon/database/__init__.py +1 -0
- chemrecon/database/connect.py +63 -0
- chemrecon/database/connection_params/chemrecon_pub.dbinfo +5 -0
- chemrecon/database/connection_params/local_docker_dev.dbinfo +5 -0
- chemrecon/database/connection_params/local_docker_init.dbinfo +5 -0
- chemrecon/database/connection_params/local_docker_pub.dbinfo +5 -0
- chemrecon/database/params.py +88 -0
- chemrecon/entrygraph/draw.py +119 -0
- chemrecon/entrygraph/entrygraph.py +301 -0
- chemrecon/entrygraph/explorationprotocol.py +199 -0
- chemrecon/entrygraph/explore.py +421 -0
- chemrecon/entrygraph/explore_procedure.py +183 -0
- chemrecon/entrygraph/filter.py +88 -0
- chemrecon/entrygraph/scoring.py +141 -0
- chemrecon/query/__init__.py +26 -0
- chemrecon/query/create_entry.py +86 -0
- chemrecon/query/default_protocols.py +57 -0
- chemrecon/query/find_entry.py +84 -0
- chemrecon/query/get_relations.py +143 -0
- chemrecon/query/get_structures_from_compound.py +65 -0
- chemrecon/schema/__init__.py +86 -0
- chemrecon/schema/db_object.py +363 -0
- chemrecon/schema/direction.py +10 -0
- chemrecon/schema/entry_types/__init__.py +0 -0
- chemrecon/schema/entry_types/aam.py +34 -0
- chemrecon/schema/entry_types/aam_repr.py +37 -0
- chemrecon/schema/entry_types/compound.py +52 -0
- chemrecon/schema/entry_types/enzyme.py +49 -0
- chemrecon/schema/entry_types/molstructure.py +64 -0
- chemrecon/schema/entry_types/molstructure_repr.py +41 -0
- chemrecon/schema/entry_types/reaction.py +57 -0
- chemrecon/schema/enums.py +154 -0
- chemrecon/schema/procedural_relation_entrygraph.py +66 -0
- chemrecon/schema/relation_types_composed/__init__.py +0 -0
- chemrecon/schema/relation_types_composed/compound_has_molstructure_relation.py +59 -0
- chemrecon/schema/relation_types_composed/reaction_has_aam_relation.py +50 -0
- chemrecon/schema/relation_types_procedural/__init__.py +0 -0
- chemrecon/schema/relation_types_procedural/aam_convert_relation.py +69 -0
- chemrecon/schema/relation_types_procedural/compound_select_structure_proceduralrelation.py +36 -0
- chemrecon/schema/relation_types_procedural/compound_similarlity_proceduralrelation.py +1 -0
- chemrecon/schema/relation_types_procedural/molstructure_convert_relation.py +49 -0
- chemrecon/schema/relation_types_procedural/reaction_select_aam_proceduralrelation.py +38 -0
- chemrecon/schema/relation_types_procedural/reaction_similarity_proceduralrelation.py +1 -0
- chemrecon/schema/relation_types_source/__init__.py +0 -0
- chemrecon/schema/relation_types_source/aam_involves_molstructure_relation.py +77 -0
- chemrecon/schema/relation_types_source/aam_repr_involves_molstructure_repr_relation.py +79 -0
- chemrecon/schema/relation_types_source/compound_has_structure_representation_relation.py +33 -0
- chemrecon/schema/relation_types_source/compound_reference_relation.py +34 -0
- chemrecon/schema/relation_types_source/molstructure_standardisation_relation.py +71 -0
- chemrecon/schema/relation_types_source/ontology/__init__.py +0 -0
- chemrecon/schema/relation_types_source/ontology/compound_ontology.py +369 -0
- chemrecon/schema/relation_types_source/ontology/enzyme_ontology.py +142 -0
- chemrecon/schema/relation_types_source/ontology/reaction_ontology.py +140 -0
- chemrecon/schema/relation_types_source/reaction_has_aam_representation_relation.py +34 -0
- chemrecon/schema/relation_types_source/reaction_has_enzyme_relation.py +71 -0
- chemrecon/schema/relation_types_source/reaction_involves_compound_relation.py +69 -0
- chemrecon/schema/relation_types_source/reaction_reference_relation.py +33 -0
- chemrecon/scripts/initialize_database.py +494 -0
- chemrecon/utils/copy_signature.py +10 -0
- chemrecon/utils/encodeable_list.py +11 -0
- chemrecon/utils/get_id_type.py +70 -0
- chemrecon/utils/hungarian.py +31 -0
- chemrecon/utils/reactant_matching.py +168 -0
- chemrecon/utils/rxnutils.py +44 -0
- chemrecon/utils/set_cwd.py +12 -0
- chemrecon-0.1.1.dist-info/METADATA +143 -0
- chemrecon-0.1.1.dist-info/RECORD +86 -0
- chemrecon-0.1.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema.enums import SourceDatabase
|
|
4
|
+
from chemrecon.schema.db_object import Relation, col_src, InverseRelation
|
|
5
|
+
from chemrecon.schema.entry_types.compound import Compound
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Is A / Has Instance
|
|
9
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
10
|
+
class CompoundIsA(Relation[Compound, Compound]):
|
|
11
|
+
""" Hierarchical relation which indicates that a compound is a member of a class of compounds.
|
|
12
|
+
"""
|
|
13
|
+
# Attributes
|
|
14
|
+
src: SourceDatabase #: The source of the relation
|
|
15
|
+
|
|
16
|
+
# Database
|
|
17
|
+
entrytype_name = 'Is a'
|
|
18
|
+
_table_name = 'CompoundIsA'
|
|
19
|
+
symmetric = False
|
|
20
|
+
source_entrytype = Compound
|
|
21
|
+
target_entrytype = Compound
|
|
22
|
+
_attribute_columns = [
|
|
23
|
+
col_src
|
|
24
|
+
]
|
|
25
|
+
_index = [0]
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
src: SourceDatabase,
|
|
30
|
+
recon_id_1: Optional[int] = None,
|
|
31
|
+
recon_id_2: Optional[int] = None
|
|
32
|
+
):
|
|
33
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
34
|
+
self.src = src
|
|
35
|
+
|
|
36
|
+
def _vis_str(self) -> str:
|
|
37
|
+
return f'is a'
|
|
38
|
+
|
|
39
|
+
class CompoundHasInstance(InverseRelation[Compound, Compound]):
|
|
40
|
+
""" Hierarchical relation which indicates that a compound is a member of a class of compounds.
|
|
41
|
+
"""
|
|
42
|
+
# Attributes
|
|
43
|
+
src: SourceDatabase #: The source of the relation
|
|
44
|
+
|
|
45
|
+
# Inverse
|
|
46
|
+
inverse_main_relation = CompoundIsA
|
|
47
|
+
|
|
48
|
+
# Database
|
|
49
|
+
entrytype_name = 'Has Instance'
|
|
50
|
+
_table_name = 'CompoundHasInstance'
|
|
51
|
+
symmetric = False
|
|
52
|
+
source_entrytype = Compound
|
|
53
|
+
target_entrytype = Compound
|
|
54
|
+
_attribute_columns = [
|
|
55
|
+
col_src
|
|
56
|
+
]
|
|
57
|
+
_index = [0]
|
|
58
|
+
|
|
59
|
+
def __init__(
|
|
60
|
+
self,
|
|
61
|
+
src: SourceDatabase,
|
|
62
|
+
recon_id_1: Optional[int] = None,
|
|
63
|
+
recon_id_2: Optional[int] = None
|
|
64
|
+
):
|
|
65
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
66
|
+
self.src = src
|
|
67
|
+
|
|
68
|
+
def _vis_str(self) -> str:
|
|
69
|
+
return f'has instance'
|
|
70
|
+
|
|
71
|
+
# Set Inverse
|
|
72
|
+
CompoundIsA.has_inverse = CompoundHasInstance
|
|
73
|
+
|
|
74
|
+
# New / Old id
|
|
75
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
76
|
+
class CompoundHasNewID(Relation[Compound, Compound]):
|
|
77
|
+
""" Indicates correspondence between identifiers in different database versions. Can be used to resolve deprecated
|
|
78
|
+
identifiers.
|
|
79
|
+
"""
|
|
80
|
+
# Attributes
|
|
81
|
+
src: SourceDatabase #: The source of the relation
|
|
82
|
+
|
|
83
|
+
# Database
|
|
84
|
+
entrytype_name = 'Has New ID'
|
|
85
|
+
_table_name = 'CompoundHasNewID'
|
|
86
|
+
symmetric = False
|
|
87
|
+
source_entrytype = Compound
|
|
88
|
+
target_entrytype = Compound
|
|
89
|
+
_attribute_columns = [
|
|
90
|
+
col_src
|
|
91
|
+
]
|
|
92
|
+
_index = [0]
|
|
93
|
+
|
|
94
|
+
def __init__(
|
|
95
|
+
self,
|
|
96
|
+
src: SourceDatabase,
|
|
97
|
+
recon_id_1: Optional[int] = None,
|
|
98
|
+
recon_id_2: Optional[int] = None
|
|
99
|
+
):
|
|
100
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
101
|
+
self.src = src
|
|
102
|
+
|
|
103
|
+
def _vis_str(self) -> str:
|
|
104
|
+
return f'new id'
|
|
105
|
+
|
|
106
|
+
class CompoundHasOldID(InverseRelation[Compound, Compound]):
|
|
107
|
+
""" Indicates correspondence between identifiers in different database versions. Can be used to resolve deprecated
|
|
108
|
+
identifiers.
|
|
109
|
+
"""
|
|
110
|
+
# Attributes
|
|
111
|
+
src: SourceDatabase #: The source of the relation
|
|
112
|
+
|
|
113
|
+
# Inverse
|
|
114
|
+
inverse_main_relation = CompoundHasNewID
|
|
115
|
+
|
|
116
|
+
# Database
|
|
117
|
+
entrytype_name = 'Has Old ID'
|
|
118
|
+
_table_name = 'CompoundHasOldID'
|
|
119
|
+
symmetric = False
|
|
120
|
+
source_entrytype = Compound
|
|
121
|
+
target_entrytype = Compound
|
|
122
|
+
_attribute_columns = [
|
|
123
|
+
col_src
|
|
124
|
+
]
|
|
125
|
+
_index = [0]
|
|
126
|
+
|
|
127
|
+
def __init__(
|
|
128
|
+
self,
|
|
129
|
+
src: SourceDatabase,
|
|
130
|
+
recon_id_1: Optional[int] = None,
|
|
131
|
+
recon_id_2: Optional[int] = None
|
|
132
|
+
):
|
|
133
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
134
|
+
self.src = src
|
|
135
|
+
|
|
136
|
+
def _vis_str(self) -> str:
|
|
137
|
+
return f'old id'
|
|
138
|
+
|
|
139
|
+
# Set Inverse
|
|
140
|
+
CompoundHasNewID.has_inverse = CompoundHasOldID
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
# Has Part / Is Part of
|
|
144
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
145
|
+
class CompoundHasPart(Relation[Compound, Compound]):
|
|
146
|
+
""" Represents a relationship where one compound is a part of another.
|
|
147
|
+
"""
|
|
148
|
+
# Attributes
|
|
149
|
+
src: SourceDatabase #: The source of the relation
|
|
150
|
+
|
|
151
|
+
# Database
|
|
152
|
+
entrytype_name = 'Has Part'
|
|
153
|
+
_table_name = 'CompoundHasPart'
|
|
154
|
+
symmetric = False
|
|
155
|
+
source_entrytype = Compound
|
|
156
|
+
target_entrytype = Compound
|
|
157
|
+
_attribute_columns = [
|
|
158
|
+
col_src
|
|
159
|
+
]
|
|
160
|
+
_index = [0]
|
|
161
|
+
|
|
162
|
+
def __init__(
|
|
163
|
+
self,
|
|
164
|
+
src: SourceDatabase,
|
|
165
|
+
recon_id_1: Optional[int] = None,
|
|
166
|
+
recon_id_2: Optional[int] = None
|
|
167
|
+
):
|
|
168
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
169
|
+
self.src = src
|
|
170
|
+
|
|
171
|
+
def _vis_str(self) -> str:
|
|
172
|
+
return f'has part'
|
|
173
|
+
|
|
174
|
+
class CompoundIsPartOf(InverseRelation[Compound, Compound]):
|
|
175
|
+
""" Represents a relationship where one compound is a part of another.
|
|
176
|
+
"""
|
|
177
|
+
# Attributes
|
|
178
|
+
src: SourceDatabase #: The source of the relation
|
|
179
|
+
|
|
180
|
+
# Inverse
|
|
181
|
+
inverse_main_relation = CompoundHasNewID
|
|
182
|
+
|
|
183
|
+
# Database
|
|
184
|
+
entrytype_name = 'Is Part of'
|
|
185
|
+
_table_name = 'CompoundIsPartOf'
|
|
186
|
+
symmetric = False
|
|
187
|
+
source_entrytype = Compound
|
|
188
|
+
target_entrytype = Compound
|
|
189
|
+
_attribute_columns = [
|
|
190
|
+
col_src
|
|
191
|
+
]
|
|
192
|
+
_index = [0]
|
|
193
|
+
|
|
194
|
+
def __init__(
|
|
195
|
+
self,
|
|
196
|
+
src: SourceDatabase,
|
|
197
|
+
recon_id_1: Optional[int] = None,
|
|
198
|
+
recon_id_2: Optional[int] = None
|
|
199
|
+
):
|
|
200
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
201
|
+
self.src = src
|
|
202
|
+
|
|
203
|
+
def _vis_str(self) -> str:
|
|
204
|
+
return f'is part of'
|
|
205
|
+
|
|
206
|
+
# Set Inverse
|
|
207
|
+
CompoundHasPart.has_inverse = CompoundIsPartOf
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
# Conjugate Acid Base
|
|
211
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
212
|
+
class CompoundHasConjugateAcid(Relation[Compound, Compound]):
|
|
213
|
+
""" Represents a relationship indicating that a compound has a conjugate acid.
|
|
214
|
+
"""
|
|
215
|
+
# Attributes
|
|
216
|
+
src: SourceDatabase #: The source of the relation
|
|
217
|
+
|
|
218
|
+
# Database
|
|
219
|
+
entrytype_name = 'Has Conjugate Acid'
|
|
220
|
+
_table_name = 'CompoundHasConjugateAcid'
|
|
221
|
+
symmetric = False
|
|
222
|
+
source_entrytype = Compound
|
|
223
|
+
target_entrytype = Compound
|
|
224
|
+
_attribute_columns = [
|
|
225
|
+
col_src
|
|
226
|
+
]
|
|
227
|
+
_index = [0]
|
|
228
|
+
|
|
229
|
+
def __init__(
|
|
230
|
+
self,
|
|
231
|
+
src: SourceDatabase,
|
|
232
|
+
recon_id_1: Optional[int] = None,
|
|
233
|
+
recon_id_2: Optional[int] = None
|
|
234
|
+
):
|
|
235
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
236
|
+
self.src = src
|
|
237
|
+
|
|
238
|
+
def _vis_str(self) -> str:
|
|
239
|
+
return f'conj. acid'
|
|
240
|
+
|
|
241
|
+
class CompoundHasConjugateBase(InverseRelation[Compound, Compound]):
|
|
242
|
+
""" Represents a relationship indicating that a compound has a conjugate base.
|
|
243
|
+
"""
|
|
244
|
+
# Attributes
|
|
245
|
+
src: SourceDatabase #: The source of the relation
|
|
246
|
+
|
|
247
|
+
# Inverse
|
|
248
|
+
inverse_main_relation = CompoundHasNewID
|
|
249
|
+
|
|
250
|
+
# Database
|
|
251
|
+
entrytype_name = 'Has Conjugate Base'
|
|
252
|
+
_table_name = 'CompoundHasConjugateBase'
|
|
253
|
+
symmetric = False
|
|
254
|
+
source_entrytype = Compound
|
|
255
|
+
target_entrytype = Compound
|
|
256
|
+
_attribute_columns = [
|
|
257
|
+
col_src
|
|
258
|
+
]
|
|
259
|
+
_index = [0]
|
|
260
|
+
|
|
261
|
+
def __init__(
|
|
262
|
+
self,
|
|
263
|
+
src: SourceDatabase,
|
|
264
|
+
recon_id_1: Optional[int] = None,
|
|
265
|
+
recon_id_2: Optional[int] = None
|
|
266
|
+
):
|
|
267
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
268
|
+
self.src = src
|
|
269
|
+
|
|
270
|
+
def _vis_str(self) -> str:
|
|
271
|
+
return f'conj. base'
|
|
272
|
+
|
|
273
|
+
# Set Inverse
|
|
274
|
+
CompoundHasConjugateAcid.has_inverse = CompoundHasConjugateBase
|
|
275
|
+
|
|
276
|
+
# Tautomer
|
|
277
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
278
|
+
class CompoundHasTautomer(Relation[Compound, Compound]):
|
|
279
|
+
""" Represents that two compounds are considered tautomers of each other.
|
|
280
|
+
"""
|
|
281
|
+
# Attributes
|
|
282
|
+
src: SourceDatabase #: The source of the relation
|
|
283
|
+
|
|
284
|
+
# Database
|
|
285
|
+
entrytype_name = 'Has Tautomer'
|
|
286
|
+
_table_name = 'CompoundHasTautomer'
|
|
287
|
+
symmetric = True
|
|
288
|
+
source_entrytype = Compound
|
|
289
|
+
target_entrytype = Compound
|
|
290
|
+
_attribute_columns = [
|
|
291
|
+
col_src
|
|
292
|
+
]
|
|
293
|
+
_index = [0]
|
|
294
|
+
|
|
295
|
+
def __init__(
|
|
296
|
+
self,
|
|
297
|
+
src: SourceDatabase,
|
|
298
|
+
recon_id_1: Optional[int] = None,
|
|
299
|
+
recon_id_2: Optional[int] = None
|
|
300
|
+
):
|
|
301
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
302
|
+
self.src = src
|
|
303
|
+
|
|
304
|
+
def _vis_str(self) -> str:
|
|
305
|
+
return f'tautomer'
|
|
306
|
+
|
|
307
|
+
# Stereoisomer
|
|
308
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
309
|
+
class CompoundHasStereoIsomer(Relation[Compound, Compound]):
|
|
310
|
+
""" Represents that two compounds are considered stereoisomers of each other.
|
|
311
|
+
"""
|
|
312
|
+
# Attributes
|
|
313
|
+
src: SourceDatabase #: The source of the relation
|
|
314
|
+
|
|
315
|
+
# Database
|
|
316
|
+
entrytype_name = 'Has Stereoisomer'
|
|
317
|
+
_table_name = 'CompoundHasStereoisomer'
|
|
318
|
+
symmetric = True
|
|
319
|
+
source_entrytype = Compound
|
|
320
|
+
target_entrytype = Compound
|
|
321
|
+
_attribute_columns = [
|
|
322
|
+
col_src
|
|
323
|
+
]
|
|
324
|
+
_index = [0]
|
|
325
|
+
|
|
326
|
+
def __init__(
|
|
327
|
+
self,
|
|
328
|
+
src: SourceDatabase,
|
|
329
|
+
recon_id_1: Optional[int] = None,
|
|
330
|
+
recon_id_2: Optional[int] = None
|
|
331
|
+
):
|
|
332
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
333
|
+
self.src = src
|
|
334
|
+
|
|
335
|
+
def _vis_str(self) -> str:
|
|
336
|
+
return f'stereoisomer'
|
|
337
|
+
|
|
338
|
+
# Isotopologue
|
|
339
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
340
|
+
class CompoundHasIsotopologue(Relation[Compound, Compound]):
|
|
341
|
+
""" Represents that two compounds are considered isotopologues of each other.
|
|
342
|
+
(identical in elements, but different isotopic composition).
|
|
343
|
+
"""
|
|
344
|
+
# Attributes
|
|
345
|
+
src: SourceDatabase #: The source of the relation
|
|
346
|
+
|
|
347
|
+
# Database
|
|
348
|
+
entrytype_name = 'Has Isotopologue'
|
|
349
|
+
_table_name = 'CompoundHasIsotopologue'
|
|
350
|
+
symmetric = True
|
|
351
|
+
source_entrytype = Compound
|
|
352
|
+
target_entrytype = Compound
|
|
353
|
+
_attribute_columns = [
|
|
354
|
+
col_src
|
|
355
|
+
]
|
|
356
|
+
_index = [0]
|
|
357
|
+
|
|
358
|
+
def __init__(
|
|
359
|
+
self,
|
|
360
|
+
src: SourceDatabase,
|
|
361
|
+
recon_id_1: Optional[int] = None,
|
|
362
|
+
recon_id_2: Optional[int] = None
|
|
363
|
+
):
|
|
364
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
365
|
+
self.src = src
|
|
366
|
+
|
|
367
|
+
def _vis_str(self) -> str:
|
|
368
|
+
return f'isotopologue'
|
|
369
|
+
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema.enums import SourceDatabase
|
|
4
|
+
from chemrecon.schema.db_object import Relation, col_src, InverseRelation
|
|
5
|
+
from chemrecon.schema.entry_types.enzyme import Enzyme
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Is A / Has Instance
|
|
9
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
10
|
+
class EnzymeIsA(Relation[Enzyme, Enzyme]):
|
|
11
|
+
""" Hierarchical relation which indicates that an enzyme is a member of a class of enzymes.
|
|
12
|
+
The EC number means that this can be automatically resolved, e.g. `1.2.3.4` *is_a* `1.2.3`
|
|
13
|
+
"""
|
|
14
|
+
# Attributes
|
|
15
|
+
src: SourceDatabase #: The source of the relation
|
|
16
|
+
|
|
17
|
+
# Database
|
|
18
|
+
entrytype_name = 'Is a'
|
|
19
|
+
_table_name = 'EnzymeIsA'
|
|
20
|
+
symmetric = False
|
|
21
|
+
source_entrytype = Enzyme
|
|
22
|
+
target_entrytype = Enzyme
|
|
23
|
+
_attribute_columns = [
|
|
24
|
+
col_src
|
|
25
|
+
]
|
|
26
|
+
_index = [0]
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
src: SourceDatabase,
|
|
31
|
+
recon_id_1: Optional[int] = None,
|
|
32
|
+
recon_id_2: Optional[int] = None
|
|
33
|
+
):
|
|
34
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
35
|
+
self.src = src
|
|
36
|
+
|
|
37
|
+
def _vis_str(self) -> str:
|
|
38
|
+
return f'is a'
|
|
39
|
+
|
|
40
|
+
class EnzymeHasInstance(InverseRelation[Enzyme, Enzyme]):
|
|
41
|
+
""" Hierarchical relation which indicates that an enzyme is a member of a class of enzymes.
|
|
42
|
+
The EC number means that this can be automatically resolved, e.g. `1.2.3.4` *is_a* `1.2.3`
|
|
43
|
+
"""
|
|
44
|
+
# Attributes
|
|
45
|
+
src: SourceDatabase #: The source of the relation
|
|
46
|
+
|
|
47
|
+
# Inverse
|
|
48
|
+
inverse_main_relation = EnzymeIsA
|
|
49
|
+
|
|
50
|
+
# Database
|
|
51
|
+
entrytype_name = 'Has Instance'
|
|
52
|
+
_table_name = 'EnzymeHasInstance'
|
|
53
|
+
symmetric = False
|
|
54
|
+
source_entrytype = Enzyme
|
|
55
|
+
target_entrytype = Enzyme
|
|
56
|
+
_attribute_columns = [
|
|
57
|
+
col_src
|
|
58
|
+
]
|
|
59
|
+
_index = [0]
|
|
60
|
+
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
src: SourceDatabase,
|
|
64
|
+
recon_id_1: Optional[int] = None,
|
|
65
|
+
recon_id_2: Optional[int] = None
|
|
66
|
+
):
|
|
67
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
68
|
+
self.src = src
|
|
69
|
+
|
|
70
|
+
def _vis_str(self) -> str:
|
|
71
|
+
return f'has instance'
|
|
72
|
+
|
|
73
|
+
# Set Inverse
|
|
74
|
+
EnzymeIsA.has_inverse = EnzymeHasInstance
|
|
75
|
+
|
|
76
|
+
# New / Old id
|
|
77
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
78
|
+
class EnzymeHasNewID(Relation[Enzyme, Enzyme]):
|
|
79
|
+
""" Indicates correspondence between identifiers in different database versions. Can be used to resolve deprecated
|
|
80
|
+
identifiers.
|
|
81
|
+
"""
|
|
82
|
+
# Attributes
|
|
83
|
+
src: SourceDatabase
|
|
84
|
+
|
|
85
|
+
# Database
|
|
86
|
+
entrytype_name = 'Has New ID'
|
|
87
|
+
_table_name = 'EnzymeHasNewID'
|
|
88
|
+
symmetric = False
|
|
89
|
+
source_entrytype = Enzyme
|
|
90
|
+
target_entrytype = Enzyme
|
|
91
|
+
_attribute_columns = [
|
|
92
|
+
col_src
|
|
93
|
+
]
|
|
94
|
+
_index = [0]
|
|
95
|
+
|
|
96
|
+
def __init__(
|
|
97
|
+
self,
|
|
98
|
+
src: SourceDatabase,
|
|
99
|
+
recon_id_1: Optional[int] = None,
|
|
100
|
+
recon_id_2: Optional[int] = None
|
|
101
|
+
):
|
|
102
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
103
|
+
self.src = src
|
|
104
|
+
|
|
105
|
+
def _vis_str(self) -> str:
|
|
106
|
+
return f'new id'
|
|
107
|
+
|
|
108
|
+
class EnzymeHasOldID(InverseRelation[Enzyme, Enzyme]):
|
|
109
|
+
""" Indicates correspondence between identifiers in different database versions. Can be used to resolve deprecated
|
|
110
|
+
identifiers.
|
|
111
|
+
"""
|
|
112
|
+
# Attributes
|
|
113
|
+
src: SourceDatabase
|
|
114
|
+
|
|
115
|
+
# Inverse
|
|
116
|
+
inverse_main_relation = EnzymeHasNewID
|
|
117
|
+
|
|
118
|
+
# Database
|
|
119
|
+
entrytype_name = 'Has Old ID'
|
|
120
|
+
_table_name = 'EnzymeHasOldID'
|
|
121
|
+
symmetric = False
|
|
122
|
+
source_entrytype = Enzyme
|
|
123
|
+
target_entrytype = Enzyme
|
|
124
|
+
_attribute_columns = [
|
|
125
|
+
col_src
|
|
126
|
+
]
|
|
127
|
+
_index = [0]
|
|
128
|
+
|
|
129
|
+
def __init__(
|
|
130
|
+
self,
|
|
131
|
+
src: SourceDatabase,
|
|
132
|
+
recon_id_1: Optional[int] = None,
|
|
133
|
+
recon_id_2: Optional[int] = None
|
|
134
|
+
):
|
|
135
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
136
|
+
self.src = src
|
|
137
|
+
|
|
138
|
+
def _vis_str(self) -> str:
|
|
139
|
+
return f'old id'
|
|
140
|
+
|
|
141
|
+
# Set Inverse
|
|
142
|
+
EnzymeHasNewID.has_inverse = EnzymeHasOldID
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema.enums import SourceDatabase
|
|
4
|
+
from chemrecon.schema.db_object import Relation, col_src, InverseRelation
|
|
5
|
+
from chemrecon.schema.entry_types.reaction import Reaction
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# Is A / Has Instance
|
|
9
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
10
|
+
class ReactionIsA(Relation[Reaction, Reaction]):
|
|
11
|
+
""" Hierarchical relation which indicates that a reaction is a member of a class of reactions.
|
|
12
|
+
"""
|
|
13
|
+
# Attributes
|
|
14
|
+
src: SourceDatabase #: The source of the relation
|
|
15
|
+
|
|
16
|
+
# Database
|
|
17
|
+
entrytype_name = 'Is a'
|
|
18
|
+
_table_name = 'ReactionIsA'
|
|
19
|
+
symmetric = False
|
|
20
|
+
source_entrytype = Reaction
|
|
21
|
+
target_entrytype = Reaction
|
|
22
|
+
_attribute_columns = [
|
|
23
|
+
col_src
|
|
24
|
+
]
|
|
25
|
+
_index = [0]
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
src: SourceDatabase,
|
|
30
|
+
recon_id_1: Optional[int] = None,
|
|
31
|
+
recon_id_2: Optional[int] = None
|
|
32
|
+
):
|
|
33
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
34
|
+
self.src = src
|
|
35
|
+
|
|
36
|
+
def _vis_str(self) -> str:
|
|
37
|
+
return f'is a'
|
|
38
|
+
|
|
39
|
+
class ReactionHasInstance(InverseRelation[Reaction, Reaction]):
|
|
40
|
+
""" Hierarchical relation which indicates that a reaction is a member of a class of reactions.
|
|
41
|
+
"""
|
|
42
|
+
# Attributes
|
|
43
|
+
src: SourceDatabase #: The source of the relation
|
|
44
|
+
|
|
45
|
+
# Inverse
|
|
46
|
+
inverse_main_relation = ReactionIsA
|
|
47
|
+
|
|
48
|
+
# Database
|
|
49
|
+
entrytype_name = 'Has Instance'
|
|
50
|
+
_table_name = 'ReactionHasInstance'
|
|
51
|
+
symmetric = False
|
|
52
|
+
source_entrytype = Reaction
|
|
53
|
+
target_entrytype = Reaction
|
|
54
|
+
_attribute_columns = [
|
|
55
|
+
col_src
|
|
56
|
+
]
|
|
57
|
+
_index = [0]
|
|
58
|
+
|
|
59
|
+
def __init__(
|
|
60
|
+
self,
|
|
61
|
+
src: SourceDatabase,
|
|
62
|
+
recon_id_1: Optional[int] = None,
|
|
63
|
+
recon_id_2: Optional[int] = None
|
|
64
|
+
):
|
|
65
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
66
|
+
self.src = src
|
|
67
|
+
|
|
68
|
+
def _vis_str(self) -> str:
|
|
69
|
+
return f'has instance'
|
|
70
|
+
|
|
71
|
+
# Set Inverse
|
|
72
|
+
ReactionIsA.has_inverse = ReactionHasInstance
|
|
73
|
+
|
|
74
|
+
# New / Old id
|
|
75
|
+
# ----------------------------------------------------------------------------------------------------------------------
|
|
76
|
+
class ReactionHasNewID(Relation[Reaction, Reaction]):
|
|
77
|
+
""" Indicates correspondence between identifiers in different database versions. Can be used to resolve deprecated
|
|
78
|
+
identifiers.
|
|
79
|
+
"""
|
|
80
|
+
# Attributes
|
|
81
|
+
src: SourceDatabase #: The source of the relation
|
|
82
|
+
|
|
83
|
+
# Database
|
|
84
|
+
entrytype_name = 'Has New ID'
|
|
85
|
+
_table_name = 'ReactionHasNewID'
|
|
86
|
+
symmetric = False
|
|
87
|
+
source_entrytype = Reaction
|
|
88
|
+
target_entrytype = Reaction
|
|
89
|
+
_attribute_columns = [
|
|
90
|
+
col_src
|
|
91
|
+
]
|
|
92
|
+
_index = [0]
|
|
93
|
+
|
|
94
|
+
def __init__(
|
|
95
|
+
self,
|
|
96
|
+
src: SourceDatabase,
|
|
97
|
+
recon_id_1: Optional[int] = None,
|
|
98
|
+
recon_id_2: Optional[int] = None
|
|
99
|
+
):
|
|
100
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
101
|
+
self.src = src
|
|
102
|
+
|
|
103
|
+
def _vis_str(self) -> str:
|
|
104
|
+
return f'new id'
|
|
105
|
+
|
|
106
|
+
class ReactionHasOldID(InverseRelation[Reaction, Reaction]):
|
|
107
|
+
""" Indicates correspondence between identifiers in different database versions. Can be used to resolve deprecated
|
|
108
|
+
identifiers.
|
|
109
|
+
"""
|
|
110
|
+
# Attributes
|
|
111
|
+
src: SourceDatabase #: The source of the relation
|
|
112
|
+
|
|
113
|
+
# Inverse
|
|
114
|
+
inverse_main_relation = ReactionHasNewID
|
|
115
|
+
|
|
116
|
+
# Database
|
|
117
|
+
entrytype_name = 'Has Old ID'
|
|
118
|
+
_table_name = 'ReactionHasOldID'
|
|
119
|
+
symmetric = False
|
|
120
|
+
source_entrytype = Reaction
|
|
121
|
+
target_entrytype = Reaction
|
|
122
|
+
_attribute_columns = [
|
|
123
|
+
col_src
|
|
124
|
+
]
|
|
125
|
+
_index = [0]
|
|
126
|
+
|
|
127
|
+
def __init__(
|
|
128
|
+
self,
|
|
129
|
+
src: SourceDatabase,
|
|
130
|
+
recon_id_1: Optional[int] = None,
|
|
131
|
+
recon_id_2: Optional[int] = None
|
|
132
|
+
):
|
|
133
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
134
|
+
self.src = src
|
|
135
|
+
|
|
136
|
+
def _vis_str(self) -> str:
|
|
137
|
+
return f'old id'
|
|
138
|
+
|
|
139
|
+
# Set Inverse
|
|
140
|
+
ReactionHasNewID.has_inverse = ReactionHasOldID
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema import Relation, Reaction, AAMRepr, SourceDatabase
|
|
4
|
+
from chemrecon.schema.db_object import col_src
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ReactionHasAAMRepr(Relation[Reaction, AAMRepr]):
|
|
8
|
+
""" Relates a reaction entry to the given AAM representation (e.g. RXN file).
|
|
9
|
+
"""
|
|
10
|
+
# Attributes
|
|
11
|
+
src: SourceDatabase #: The source database containing this AAM.
|
|
12
|
+
|
|
13
|
+
# Database
|
|
14
|
+
entrytype_name = 'Reaction has AAMRepr'
|
|
15
|
+
_table_name = 'ReactionHasAAMRepr'
|
|
16
|
+
symmetric = False
|
|
17
|
+
source_entrytype = Reaction
|
|
18
|
+
target_entrytype = AAMRepr
|
|
19
|
+
_attribute_columns = [
|
|
20
|
+
col_src
|
|
21
|
+
]
|
|
22
|
+
_index = [0]
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
src: SourceDatabase = SourceDatabase.unknown,
|
|
27
|
+
recon_id_1: Optional[int] = None,
|
|
28
|
+
recon_id_2: Optional[int] = None
|
|
29
|
+
):
|
|
30
|
+
super().__init__(recon_id_1, recon_id_2)
|
|
31
|
+
self.src = src
|
|
32
|
+
|
|
33
|
+
def _vis_str(self) -> str:
|
|
34
|
+
return f'{self.src.name}'
|