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,34 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema import Entry
|
|
4
|
+
from chemrecon.schema.db_object import Column, col_recon_id
|
|
5
|
+
|
|
6
|
+
class AAM(Entry):
|
|
7
|
+
""" Represents an atom-to-atom map.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# Attributes
|
|
11
|
+
reaction_smiles: str #: The canonical reaction SMILES string.
|
|
12
|
+
|
|
13
|
+
# Database
|
|
14
|
+
entrytype_name = 'AAM'
|
|
15
|
+
_table_name = 'AAM'
|
|
16
|
+
_columns = [
|
|
17
|
+
col_recon_id,
|
|
18
|
+
Column('reaction_smiles', str, index_hash = True),
|
|
19
|
+
]
|
|
20
|
+
_index = [1]
|
|
21
|
+
|
|
22
|
+
# Visualisation
|
|
23
|
+
_draw_colour = '7AFF78'
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
reaction_smiles: str,
|
|
28
|
+
recon_id: Optional[int] = None,
|
|
29
|
+
):
|
|
30
|
+
super().__init__(recon_id)
|
|
31
|
+
self.reaction_smiles = reaction_smiles
|
|
32
|
+
|
|
33
|
+
def _vis_str(self) -> str:
|
|
34
|
+
return self.reaction_smiles
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema import Entry, IdTypeAAMEnum
|
|
4
|
+
from chemrecon.schema.db_object import Column, col_recon_id, col_source_id_hashed
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AAMRepr(Entry):
|
|
8
|
+
""" Represents an enzyme entry. """
|
|
9
|
+
# Attributes
|
|
10
|
+
source_id: str #: Identifier string. (**index**)
|
|
11
|
+
id_type: IdTypeAAMEnum #: The type of the identifier string (e.g. Reaction SMILES). (**index**)
|
|
12
|
+
|
|
13
|
+
# Database
|
|
14
|
+
entrytype_name = 'AAMRepr'
|
|
15
|
+
_table_name = 'AAMRepr'
|
|
16
|
+
_columns = [
|
|
17
|
+
col_recon_id,
|
|
18
|
+
col_source_id_hashed,
|
|
19
|
+
Column('id_type', IdTypeAAMEnum),
|
|
20
|
+
]
|
|
21
|
+
_index = [1, 2]
|
|
22
|
+
|
|
23
|
+
# Visualisation
|
|
24
|
+
_draw_colour = '7AFF78'
|
|
25
|
+
|
|
26
|
+
def __init__(
|
|
27
|
+
self,
|
|
28
|
+
source_id: str,
|
|
29
|
+
id_type: IdTypeAAMEnum,
|
|
30
|
+
recon_id: Optional[int] = None,
|
|
31
|
+
):
|
|
32
|
+
super().__init__(recon_id)
|
|
33
|
+
self.source_id = source_id
|
|
34
|
+
self.id_type = id_type
|
|
35
|
+
|
|
36
|
+
def _vis_str(self) -> str:
|
|
37
|
+
return f'{self.id_type.name}: {self.source_id}'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema import SourceEntry
|
|
4
|
+
from chemrecon.schema.db_object import (
|
|
5
|
+
Column, col_name, col_properties, col_quality,
|
|
6
|
+
col_recon_id,
|
|
7
|
+
col_source_id,
|
|
8
|
+
)
|
|
9
|
+
from chemrecon.schema.enums import IdTypeCompoundEnum, Quality
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Compound(SourceEntry):
|
|
13
|
+
""" Represents a compound entry.
|
|
14
|
+
"""
|
|
15
|
+
# Attributes
|
|
16
|
+
source_id: str #: Identifier of the database entry. (**index**)
|
|
17
|
+
id_type: IdTypeCompoundEnum #: Source of the database entry. (**index**)
|
|
18
|
+
name: Optional[str] #: Name of the database entry. This May be the common name, IUPAC systematic name, or others.
|
|
19
|
+
quality: Optional[Quality] #: Indicates the quality of the entry, if this is specified by the source database.
|
|
20
|
+
properties: list[str] #: Additional properties
|
|
21
|
+
|
|
22
|
+
# Database
|
|
23
|
+
entrytype_name = 'Compound'
|
|
24
|
+
_table_name = 'Compound'
|
|
25
|
+
_columns = [
|
|
26
|
+
col_recon_id,
|
|
27
|
+
col_source_id,
|
|
28
|
+
Column('id_type', IdTypeCompoundEnum),
|
|
29
|
+
col_name,
|
|
30
|
+
col_quality,
|
|
31
|
+
col_properties,
|
|
32
|
+
]
|
|
33
|
+
_index = [1, 2]
|
|
34
|
+
|
|
35
|
+
# Visualisation
|
|
36
|
+
_draw_colour = 'C6FFFF'
|
|
37
|
+
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
source_id: str,
|
|
41
|
+
id_type: IdTypeCompoundEnum,
|
|
42
|
+
name: Optional[str] = None,
|
|
43
|
+
quality: Quality = None,
|
|
44
|
+
recon_id: Optional[int] = None,
|
|
45
|
+
properties: Optional[list[str]] = None,
|
|
46
|
+
):
|
|
47
|
+
super().__init__(recon_id)
|
|
48
|
+
self.source_id = source_id
|
|
49
|
+
self.id_type = id_type
|
|
50
|
+
self.name = name
|
|
51
|
+
self.quality = quality
|
|
52
|
+
self.properties = properties if properties else list()
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema import IdTypeEnzymeEnum, Quality
|
|
4
|
+
from chemrecon.schema.db_object import (
|
|
5
|
+
Column, SourceEntry, col_name, col_properties, col_quality,
|
|
6
|
+
col_recon_id,
|
|
7
|
+
col_source_id,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
class Enzyme(SourceEntry):
|
|
11
|
+
""" Represents an enzyme entry. """
|
|
12
|
+
# Attributes
|
|
13
|
+
source_id: str #: Identifier of the database entry. (**index**)
|
|
14
|
+
id_type: IdTypeEnzymeEnum #: Source of the database entry. Always ``EC`` as of the current version. (**index**)
|
|
15
|
+
name: Optional[str] #: Name of the enzyme.
|
|
16
|
+
quality: Optional[Quality] #: Indicates the quality of the entry, if this is specified by the source database.
|
|
17
|
+
properties: list[str] #: Additional properties
|
|
18
|
+
|
|
19
|
+
# Database
|
|
20
|
+
entrytype_name = 'Enzyme'
|
|
21
|
+
_table_name = 'Enzyme'
|
|
22
|
+
_columns = [
|
|
23
|
+
col_recon_id,
|
|
24
|
+
col_source_id,
|
|
25
|
+
Column('id_type', IdTypeEnzymeEnum),
|
|
26
|
+
col_name,
|
|
27
|
+
col_quality,
|
|
28
|
+
col_properties,
|
|
29
|
+
]
|
|
30
|
+
_index = [1, 2]
|
|
31
|
+
|
|
32
|
+
# Visualisation
|
|
33
|
+
_draw_colour = 'F8FF9B'
|
|
34
|
+
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
source_id: str,
|
|
38
|
+
id_type: IdTypeEnzymeEnum,
|
|
39
|
+
name: Optional[str] = None,
|
|
40
|
+
recon_id: Optional[int] = None,
|
|
41
|
+
quality: Optional[Quality] = None,
|
|
42
|
+
properties: Optional[list[str]] = None,
|
|
43
|
+
):
|
|
44
|
+
super().__init__(recon_id)
|
|
45
|
+
self.source_id = source_id
|
|
46
|
+
self.id_type = id_type
|
|
47
|
+
self.name = name
|
|
48
|
+
self.quality = quality
|
|
49
|
+
self.properties = properties if properties else list()
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema import Entry, FeatureEnum
|
|
4
|
+
from chemrecon.schema.db_object import Column, col_recon_id
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class MolStructure(Entry):
|
|
8
|
+
""" Abstract representation of a structure in SMILES format.
|
|
9
|
+
"""
|
|
10
|
+
# Attributes
|
|
11
|
+
smiles: str #: The canonical SMILES identifier.
|
|
12
|
+
std_feats: Optional[list[FeatureEnum]] #: The features w.r.t which this structure is standardized (see TODO).
|
|
13
|
+
molformula: Optional[str] #: The sum formula.
|
|
14
|
+
|
|
15
|
+
# Database
|
|
16
|
+
entrytype_name = 'MolStructure'
|
|
17
|
+
_table_name = 'MolStructure'
|
|
18
|
+
_columns = [
|
|
19
|
+
col_recon_id,
|
|
20
|
+
Column('smiles', str, index_hash = True),
|
|
21
|
+
Column('std_feats', list[FeatureEnum]),
|
|
22
|
+
Column('molformula', str),
|
|
23
|
+
]
|
|
24
|
+
_index = [1]
|
|
25
|
+
|
|
26
|
+
# Visualisation
|
|
27
|
+
_draw_colour = '00FFFF'
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
smiles: str,
|
|
32
|
+
std_feats: Optional[list[FeatureEnum]] = None,
|
|
33
|
+
molformula: Optional[str] = None,
|
|
34
|
+
recon_id: Optional[int] = None,
|
|
35
|
+
):
|
|
36
|
+
super().__init__(recon_id)
|
|
37
|
+
self.smiles = smiles
|
|
38
|
+
self.std_feats = std_feats
|
|
39
|
+
self.molformula = molformula
|
|
40
|
+
|
|
41
|
+
# Calculate std. features if none
|
|
42
|
+
if self.std_feats is None:
|
|
43
|
+
from chemrecon import mol_from_smiles
|
|
44
|
+
mol = mol_from_smiles(smiles = self.smiles)
|
|
45
|
+
self.std_feats = {feat.feature_enum for feat in mol.features}
|
|
46
|
+
|
|
47
|
+
# Calculate sum formula if not given
|
|
48
|
+
if self.molformula is None:
|
|
49
|
+
# TODO
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
def _vis_str(self) -> str:
|
|
53
|
+
return f'{self.smiles}\n({self._feat_str()})'
|
|
54
|
+
|
|
55
|
+
def _feat_str(self) -> str:
|
|
56
|
+
if self.std_feats is None:
|
|
57
|
+
return '?'
|
|
58
|
+
s: str = ''
|
|
59
|
+
s += 'F,' if FeatureEnum.F in self.std_feats else '-,'
|
|
60
|
+
s += 'I,' if FeatureEnum.I in self.std_feats else '-,'
|
|
61
|
+
s += 'C,' if FeatureEnum.C in self.std_feats else '-,'
|
|
62
|
+
s += 'T,' if FeatureEnum.T in self.std_feats else '-,'
|
|
63
|
+
s += 'S,' if FeatureEnum.S in self.std_feats else '-,'
|
|
64
|
+
return s
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema import Column, Entry, IdTypeStructureRepresentationEnum
|
|
4
|
+
from chemrecon.schema.db_object import col_recon_id, col_source_id_hashed
|
|
5
|
+
class MolStructureRepr(Entry):
|
|
6
|
+
""" Represents a representation of a structure, such as an S_SMILES string, S_MOLFILE or similar. """
|
|
7
|
+
# Attributes
|
|
8
|
+
source_id: str #: Identifier string. (**index**)
|
|
9
|
+
id_type: IdTypeStructureRepresentationEnum #: The type of the identifier string (e.g. SMILES, InChI). (**index**)
|
|
10
|
+
#: If marked as implicit, this molecular structure only exists implicitly in an atom-to-atom map, and is not
|
|
11
|
+
#: directly referenced by a known compound.
|
|
12
|
+
implicit: bool
|
|
13
|
+
|
|
14
|
+
# Database
|
|
15
|
+
entrytype_name = 'MolStructureRepr'
|
|
16
|
+
_table_name = 'MolStructureRepr'
|
|
17
|
+
_columns = [
|
|
18
|
+
col_recon_id,
|
|
19
|
+
col_source_id_hashed,
|
|
20
|
+
Column('id_type', IdTypeStructureRepresentationEnum),
|
|
21
|
+
Column('implicit', bool)
|
|
22
|
+
]
|
|
23
|
+
_index = [1, 2]
|
|
24
|
+
|
|
25
|
+
# Visualisation
|
|
26
|
+
_draw_colour = '7AFF78'
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
source_id: str,
|
|
31
|
+
implicit: bool,
|
|
32
|
+
id_type: IdTypeStructureRepresentationEnum,
|
|
33
|
+
recon_id: Optional[int] = None,
|
|
34
|
+
):
|
|
35
|
+
super().__init__(recon_id)
|
|
36
|
+
self.source_id = source_id
|
|
37
|
+
self.id_type = id_type
|
|
38
|
+
self.implicit = implicit
|
|
39
|
+
|
|
40
|
+
def _vis_str(self) -> str:
|
|
41
|
+
return f'{self.id_type.name}: {self.source_id}'
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema import IdTypeReactionEnum, Quality
|
|
4
|
+
from chemrecon.schema.db_object import (
|
|
5
|
+
Column, SourceEntry, col_name, col_properties, col_quality,
|
|
6
|
+
col_recon_id,
|
|
7
|
+
col_source_id,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
class Reaction(SourceEntry):
|
|
11
|
+
""" Represents a compound entry. """
|
|
12
|
+
# Attributes
|
|
13
|
+
source_id: str #: Identifier of the database entry. (**index**)
|
|
14
|
+
id_type: IdTypeReactionEnum #: Source of the database entry. (**index**)
|
|
15
|
+
name: Optional[str]
|
|
16
|
+
is_transport: Optional[bool] #: Whether the reaction is explicitly marked as a transport reaction.
|
|
17
|
+
is_reversible: Optional[bool] #: Whether the reaction is explicitly marked as reversible.
|
|
18
|
+
quality: Optional[Quality] #: Indicates the quality of the entry, if this is specified by the source database.
|
|
19
|
+
properties: list[str] #: Additional properties
|
|
20
|
+
|
|
21
|
+
# Database
|
|
22
|
+
entrytype_name = 'Reaction'
|
|
23
|
+
_table_name = 'Reaction'
|
|
24
|
+
_columns = [
|
|
25
|
+
col_recon_id,
|
|
26
|
+
col_source_id,
|
|
27
|
+
Column('id_type', IdTypeReactionEnum),
|
|
28
|
+
col_name,
|
|
29
|
+
Column('is_transport', bool),
|
|
30
|
+
Column('is_reversible', bool),
|
|
31
|
+
col_quality,
|
|
32
|
+
col_properties,
|
|
33
|
+
]
|
|
34
|
+
_index = [1, 2]
|
|
35
|
+
|
|
36
|
+
# Visualisation
|
|
37
|
+
_draw_colour = '9EFFA1'
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
source_id: str,
|
|
42
|
+
id_type: IdTypeReactionEnum,
|
|
43
|
+
name: Optional[str] = None,
|
|
44
|
+
is_transport: Optional[bool] = None,
|
|
45
|
+
is_reversible: Optional[bool] = None,
|
|
46
|
+
quality: Optional[Quality] = None,
|
|
47
|
+
recon_id: Optional[int] = None,
|
|
48
|
+
properties: Optional[list[str]] = None,
|
|
49
|
+
):
|
|
50
|
+
super().__init__(recon_id)
|
|
51
|
+
self.source_id = source_id
|
|
52
|
+
self.id_type = id_type
|
|
53
|
+
self.name = name
|
|
54
|
+
self.is_transport = is_transport
|
|
55
|
+
self.is_reversible = is_reversible
|
|
56
|
+
self.quality = quality
|
|
57
|
+
self.properties = properties if properties else list()
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
""" Enums and corresponding objects
|
|
2
|
+
"""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from enum import Enum
|
|
7
|
+
|
|
8
|
+
from chemrecon.core import id_types as id_types
|
|
9
|
+
from chemrecon.core.id_types import (
|
|
10
|
+
IdentifierType,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SourceDatabase(Enum):
|
|
15
|
+
unknown = 0
|
|
16
|
+
BIGG = 1
|
|
17
|
+
CHEBI = 2
|
|
18
|
+
ECMDB = 3
|
|
19
|
+
MCSA = 4
|
|
20
|
+
METAMDB = 5
|
|
21
|
+
METANETX = 6
|
|
22
|
+
PUBCHEM = 7
|
|
23
|
+
MANUALLY_ADDED = 8
|
|
24
|
+
AUTOMATIC = 9
|
|
25
|
+
|
|
26
|
+
def __str__(self):
|
|
27
|
+
return self.name
|
|
28
|
+
def __repr__(self):
|
|
29
|
+
return self.name
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Quality(Enum):
|
|
33
|
+
unknown = 0
|
|
34
|
+
automatic = 1
|
|
35
|
+
preliminary = 2
|
|
36
|
+
manual = 3
|
|
37
|
+
manual_curated = 4
|
|
38
|
+
|
|
39
|
+
def __str__(self):
|
|
40
|
+
return self.name
|
|
41
|
+
def __repr__(self):
|
|
42
|
+
return self.name
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class FeatureEnum(Enum):
|
|
46
|
+
F = 1
|
|
47
|
+
I = 2
|
|
48
|
+
C = 3
|
|
49
|
+
T = 4
|
|
50
|
+
S = 5
|
|
51
|
+
|
|
52
|
+
def __str__(self):
|
|
53
|
+
return self.name
|
|
54
|
+
def __repr__(self):
|
|
55
|
+
return self.name
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class IdTypeEnum(Enum):
|
|
59
|
+
pass
|
|
60
|
+
|
|
61
|
+
def __str__(self):
|
|
62
|
+
return self.name
|
|
63
|
+
def __repr__(self):
|
|
64
|
+
return self.name
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class IdTypeCompoundEnum(IdTypeEnum):
|
|
68
|
+
unknown = id_types.C_UNKNOWN
|
|
69
|
+
cname = id_types.C_NAME
|
|
70
|
+
mnx = id_types.C_MNX
|
|
71
|
+
bigg = id_types.C_BIGG
|
|
72
|
+
chebi = id_types.C_CHEBI
|
|
73
|
+
pubchem_cid = id_types.C_PUBCHEM
|
|
74
|
+
kegg = id_types.C_KEGG
|
|
75
|
+
ecmdb = id_types.C_ECMDB
|
|
76
|
+
inchikey = id_types.C_INCHIKEY
|
|
77
|
+
slm = id_types.C_SLM
|
|
78
|
+
envipath = id_types.C_ENVIPATH
|
|
79
|
+
lipidmaps = id_types.C_LIPIDMAPS
|
|
80
|
+
hmdb = id_types.C_HMDB
|
|
81
|
+
metacyc = id_types.C_METACYC
|
|
82
|
+
seed = id_types.C_SEED
|
|
83
|
+
sabiork = id_types.C_SABIORK
|
|
84
|
+
reactome = id_types.C_REACTOME
|
|
85
|
+
pdbe = id_types.C_PDBE
|
|
86
|
+
biocyc = id_types.C_BIOCYC
|
|
87
|
+
metamdb = id_types.C_METAMDB
|
|
88
|
+
brenda = id_types.C_BRENDA
|
|
89
|
+
|
|
90
|
+
class IdTypeStructureRepresentationEnum(IdTypeEnum):
|
|
91
|
+
unknown = id_types.S_UNKNOWN
|
|
92
|
+
smiles = id_types.S_SMILES
|
|
93
|
+
inchi = id_types.S_INCHI
|
|
94
|
+
molfile = id_types.S_MOLFILE
|
|
95
|
+
gml = id_types.S_GML
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class IdTypeReactionEnum(IdTypeEnum):
|
|
99
|
+
unknown = id_types.R_UNKNOWN
|
|
100
|
+
rname = id_types.R_NAME
|
|
101
|
+
mnx = id_types.R_MNX
|
|
102
|
+
metacyc = id_types.R_METACYC
|
|
103
|
+
bigg = id_types.R_BIGG
|
|
104
|
+
seed = id_types.R_SEED
|
|
105
|
+
kegg = id_types.R_KEGG
|
|
106
|
+
rhea = id_types.R_RHEA
|
|
107
|
+
sabiork = id_types.R_SABIORK
|
|
108
|
+
metamdb = id_types.R_METAMDB
|
|
109
|
+
mcsa = id_types.R_MCSA
|
|
110
|
+
brenda = id_types.R_BRENDA
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class IdTypeAAMEnum(IdTypeEnum):
|
|
114
|
+
unknown = id_types.A_UNKNOWN
|
|
115
|
+
reactionsmiles = id_types.A_REACTIONSMILES
|
|
116
|
+
rxn = id_types.A_RXN
|
|
117
|
+
gml_rule = id_types.A_GML_RULE
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class IdTypeEnzymeEnum(IdTypeEnum):
|
|
121
|
+
unknown = id_types.E_UNKNOWN
|
|
122
|
+
ename = id_types.E_NAME
|
|
123
|
+
ec = id_types.E_EC
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
# Enum registration
|
|
128
|
+
# ----------------------------------------------------------------------------------------------------------------
|
|
129
|
+
enum_register = [
|
|
130
|
+
SourceDatabase, Quality, FeatureEnum,
|
|
131
|
+
IdTypeCompoundEnum, IdTypeStructureRepresentationEnum,
|
|
132
|
+
IdTypeReactionEnum, IdTypeAAMEnum, IdTypeEnzymeEnum
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
# Set the corresponding enum type for each IdType
|
|
136
|
+
for member in IdTypeCompoundEnum:
|
|
137
|
+
if isinstance(member.value, IdentifierType):
|
|
138
|
+
member.value.enum_type = IdTypeCompoundEnum.__getitem__(member.name)
|
|
139
|
+
|
|
140
|
+
for member in IdTypeReactionEnum:
|
|
141
|
+
if isinstance(member.value, IdentifierType):
|
|
142
|
+
member.value.enum_type = IdTypeReactionEnum.__getitem__(member.name)
|
|
143
|
+
|
|
144
|
+
for member in IdTypeStructureRepresentationEnum:
|
|
145
|
+
if isinstance(member.value, IdentifierType):
|
|
146
|
+
member.value.enum_type = IdTypeStructureRepresentationEnum.__getitem__(member.name)
|
|
147
|
+
|
|
148
|
+
for member in IdTypeEnzymeEnum:
|
|
149
|
+
if isinstance(member.value, IdentifierType):
|
|
150
|
+
member.value.enum_type = IdTypeEnzymeEnum.__getitem__(member.name)
|
|
151
|
+
|
|
152
|
+
for member in IdTypeAAMEnum:
|
|
153
|
+
if isinstance(member.value, IdentifierType):
|
|
154
|
+
member.value.enum_type = IdTypeAAMEnum.__getitem__(member.name)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
""" Defines procedural entries which are generated using entry graphs.
|
|
2
|
+
"""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from abc import ABC
|
|
6
|
+
from typing import ClassVar, final, Optional
|
|
7
|
+
|
|
8
|
+
import chemrecon.entrygraph.scoring as scoring
|
|
9
|
+
|
|
10
|
+
import chemrecon.entrygraph.explore as explore
|
|
11
|
+
from chemrecon.schema.db_object import Entry, ProceduralRelation
|
|
12
|
+
from chemrecon.schema.db_object import col_score
|
|
13
|
+
from chemrecon.entrygraph.explorationprotocol import ExplorationProtocol
|
|
14
|
+
from chemrecon.entrygraph.entrygraph import EntryGraph
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ProceduralRelationEG[T1: Entry, T2: Entry](ProceduralRelation[T1, T2], ABC):
|
|
18
|
+
""" A procedural relation which is calculated based on an entrygraph of other relations
|
|
19
|
+
in the database.
|
|
20
|
+
Requires entrygraph to only accept entries of type T1 as initial entries, and the
|
|
21
|
+
scorer to score entries of type T2.
|
|
22
|
+
"""
|
|
23
|
+
# Attribute
|
|
24
|
+
score: float #: The score of the target entry in the entry graph.
|
|
25
|
+
|
|
26
|
+
# Defines the parameters from which the EG is generated
|
|
27
|
+
protocol: ClassVar[ExplorationProtocol]
|
|
28
|
+
entrygraph_scorer: ClassVar[scoring.Scorer]
|
|
29
|
+
|
|
30
|
+
# Necessary
|
|
31
|
+
symmetric = False
|
|
32
|
+
_attribute_columns = [
|
|
33
|
+
col_score
|
|
34
|
+
]
|
|
35
|
+
_index = []
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
recon_id_1: Optional[int] = None,
|
|
41
|
+
recon_id_2: Optional[int] = None,
|
|
42
|
+
score: float = 0.0
|
|
43
|
+
):
|
|
44
|
+
self.score = score
|
|
45
|
+
super().__init__(recon_id_1 = recon_id_1, recon_id_2 = recon_id_2)
|
|
46
|
+
|
|
47
|
+
@final
|
|
48
|
+
@classmethod
|
|
49
|
+
def generate(
|
|
50
|
+
cls,
|
|
51
|
+
take_entry: T1,
|
|
52
|
+
) -> list[tuple[ProceduralRelation[T1, T2], T2]]:
|
|
53
|
+
""" Generation of procedural relations relies on generating the associated entrygraph.
|
|
54
|
+
"""
|
|
55
|
+
eg = EntryGraph(
|
|
56
|
+
initial_entries = {take_entry}
|
|
57
|
+
)
|
|
58
|
+
explore.explore(eg, steps = 4, protocol = cls.protocol)
|
|
59
|
+
score = cls.entrygraph_scorer(eg)
|
|
60
|
+
return [
|
|
61
|
+
(cls(recon_id_1 = None, recon_id_2 = None, score = score), score_entry)
|
|
62
|
+
for score_entry, score in score.items()
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
def _vis_str(self) -> str:
|
|
66
|
+
return f'score: {self.score}'
|
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema.db_object import col_src
|
|
4
|
+
from chemrecon.schema.enums import SourceDatabase
|
|
5
|
+
from chemrecon.schema import Compound, MolStructure, ComposedRelation
|
|
6
|
+
from chemrecon.schema.entry_types.molstructure_repr import MolStructureRepr
|
|
7
|
+
from chemrecon.schema.relation_types_source.compound_has_structure_representation_relation import (
|
|
8
|
+
CompoundHasStructureRepresentation
|
|
9
|
+
)
|
|
10
|
+
from chemrecon.schema.relation_types_procedural.molstructure_convert_relation import MolStructureConvert
|
|
11
|
+
|
|
12
|
+
class CompoundHasMolStructure(ComposedRelation[Compound, MolStructure, MolStructureRepr]):
|
|
13
|
+
""" This relation gives the associated molecular structures of a compound in a standardized format.
|
|
14
|
+
This relation is composed of the `CompoundHasMolStructureRepr` relation and the `MolStructureConvert`
|
|
15
|
+
relations.
|
|
16
|
+
So if a compound entry includes an InChI, Molfile representation of a structure, this relation gives the same
|
|
17
|
+
structure in the standardized, SMILES-based format.
|
|
18
|
+
"""
|
|
19
|
+
# Attributes
|
|
20
|
+
src: SourceDatabase #: The source database containing this structure.
|
|
21
|
+
|
|
22
|
+
# Transitive
|
|
23
|
+
rel_type_1 = CompoundHasStructureRepresentation
|
|
24
|
+
rel_type_2 = MolStructureConvert
|
|
25
|
+
intermediate_entrytype = MolStructureRepr
|
|
26
|
+
|
|
27
|
+
# Database
|
|
28
|
+
entrytype_name = 'Compound has MolStructure'
|
|
29
|
+
_table_name = 'CompoundHasMolStructure'
|
|
30
|
+
symmetric = False
|
|
31
|
+
source_entrytype = Compound
|
|
32
|
+
target_entrytype = MolStructure
|
|
33
|
+
_attribute_columns = [
|
|
34
|
+
col_src
|
|
35
|
+
]
|
|
36
|
+
_index = [0]
|
|
37
|
+
|
|
38
|
+
# Filters
|
|
39
|
+
@classmethod
|
|
40
|
+
def filter_intermediate(cls, e: MolStructureRepr) -> bool:
|
|
41
|
+
if e.implicit:
|
|
42
|
+
return False
|
|
43
|
+
return True
|
|
44
|
+
|
|
45
|
+
def __init__(
|
|
46
|
+
self,
|
|
47
|
+
rel_1: CompoundHasStructureRepresentation,
|
|
48
|
+
rel_2: MolStructureConvert,
|
|
49
|
+
intermediate: MolStructureRepr,
|
|
50
|
+
recon_id_1: Optional[int] = None,
|
|
51
|
+
recon_id_2: Optional[int] = None
|
|
52
|
+
):
|
|
53
|
+
# Inherits src from rel1
|
|
54
|
+
self.src = rel_1.src
|
|
55
|
+
super().__init__(rel_1, rel_2, intermediate, recon_id_1, recon_id_2)
|
|
56
|
+
|
|
57
|
+
def _vis_str(self) -> str:
|
|
58
|
+
return f'{self.src.name}'
|
|
59
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from chemrecon.schema.db_object import col_src
|
|
4
|
+
from chemrecon.schema import Reaction, AAM, ComposedRelation
|
|
5
|
+
from chemrecon.schema.enums import SourceDatabase
|
|
6
|
+
from chemrecon.schema.entry_types.aam_repr import AAMRepr
|
|
7
|
+
from chemrecon.schema.relation_types_procedural.aam_convert_relation import \
|
|
8
|
+
AAMConvert
|
|
9
|
+
from chemrecon.schema.relation_types_source.reaction_has_aam_representation_relation import \
|
|
10
|
+
ReactionHasAAMRepr
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ReactionHasAAM(ComposedRelation[Reaction, AAM, AAMRepr]):
|
|
14
|
+
""" This relation gives the associated AAM of a reaction in a standardized format.
|
|
15
|
+
This relation is composed of the `ReactionHasAAMRepr` relation and the `AAMConvert` relations.
|
|
16
|
+
So if a reaction entry includes an RXN or GML representation of a map, this relation gives the same
|
|
17
|
+
map in the standardized, ReactionSMILES-based format.
|
|
18
|
+
"""
|
|
19
|
+
# Attributes
|
|
20
|
+
src: SourceDatabase #: The source database specifying this AAM.
|
|
21
|
+
|
|
22
|
+
# Transitive
|
|
23
|
+
rel_type_1 = ReactionHasAAMRepr
|
|
24
|
+
rel_type_2 = AAMConvert
|
|
25
|
+
intermediate_entrytype = AAMRepr
|
|
26
|
+
|
|
27
|
+
# Database
|
|
28
|
+
entrytype_name = 'Reaction has AAM'
|
|
29
|
+
_table_name = 'ReactionHasAAM'
|
|
30
|
+
symmetric = False
|
|
31
|
+
source_entrytype = Reaction
|
|
32
|
+
target_entrytype = AAM
|
|
33
|
+
_attribute_columns = [
|
|
34
|
+
col_src
|
|
35
|
+
]
|
|
36
|
+
_index = [0]
|
|
37
|
+
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
rel_1: ReactionHasAAMRepr,
|
|
41
|
+
rel_2: AAMConvert,
|
|
42
|
+
intermediate: AAMRepr,
|
|
43
|
+
recon_id_1: Optional[int] = None,
|
|
44
|
+
recon_id_2: Optional[int] = None
|
|
45
|
+
):
|
|
46
|
+
self.src = rel_1.src
|
|
47
|
+
super().__init__(rel_1, rel_2, intermediate, recon_id_1, recon_id_2)
|
|
48
|
+
|
|
49
|
+
def _vis_str(self) -> str:
|
|
50
|
+
return f'{self.src.name}'
|
|
File without changes
|