-
Notifications
You must be signed in to change notification settings - Fork 11
/
__init__.py
161 lines (149 loc) · 5.97 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
from emannotationschemas.schemas.synapse import SynapseSchema
from emannotationschemas.schemas.synapse import NoCenterSynapse
from emannotationschemas.schemas.synapse import PlasticSynapse
from emannotationschemas.schemas.synapse import ValidSynapse
from emannotationschemas.schemas.synapse import BuhmannSynapseSchema
from emannotationschemas.schemas.synapse import BuhmannEcksteinSynapseSchema
from emannotationschemas.schemas.synapse import NoCleftSynapse
from emannotationschemas.schemas.bouton_shape import BoutonShape
from emannotationschemas.schemas.presynaptic_bouton_type import PresynapticBoutonType
from emannotationschemas.schemas.base import (
ReferenceAnnotation,
ReferenceTagAnnotation,
ReferenceInteger,
)
from emannotationschemas.schemas.functional_coregistration import (
FunctionalCoregistration,
FunctionalUnitCoregistration,
FunctionalUnitCoregistrationExtended,
)
from emannotationschemas.schemas.functional_props import FunctionalPropertiesBCM
from emannotationschemas.schemas.postsynaptic_compartment import PostsynapticCompartment
from emannotationschemas.schemas.base import (
FlatSegmentationReferenceSinglePoint,
RepresentativePoint,
)
from emannotationschemas.schemas.cell_type_local import CellTypeLocal, CellTypeReference
from emannotationschemas.schemas.bound_text_tag import (
BoundTagAnnotation,
BoundDoubleTagAnnotation,
Bound2TagAnnotation,
BoundTagAnnotationUser,
BoundDoubleTagAnnotationUser,
Bound2TagAnnotationUser,
)
from emannotationschemas.schemas.glia_contact import GliaContact
from emannotationschemas.schemas.contact import Contact
from emannotationschemas.schemas.extended_classical_cell_type import (
ExtendedClassicalCellType,
)
from emannotationschemas.schemas.nucleus_detection import NucleusDetection
from emannotationschemas.schemas.derived_spatial_point import (
DerivedSpatialPoint,
DerivedTag,
DerivedNumeric,
)
from emannotationschemas.schemas.proofreading import (
CompartmentProofreadStatus,
ProofreadStatus,
ProofreadingBoolStatusUser,
CompartmentProofreadStatusStrategy,
)
from emannotationschemas.schemas.neuropil import FlyNeuropil
from emannotationschemas.schemas.groups import SimpleGroup
from emannotationschemas.schemas.fly_cell_types import FlyCellType, FlyCellTypeExt
from emannotationschemas.schemas.braincircuits import (
BrainCircuitsBoundTagAnnotationUser,
)
from emannotationschemas.schemas.bound_bool_tag import (
BoundBoolAnnotation,
BoundBoolWithValid,
BoundTagWithValid,
SpatialPointBoolWithValid,
)
from emannotationschemas.schemas.reference_text_float import (
ReferenceTagFloat,
)
from emannotationschemas.errors import UnknownAnnotationTypeException
from emannotationschemas.flatten import create_flattened_schema
__version__ = "5.17.0"
type_mapping = {
"synapse": SynapseSchema,
"nocleft_synapse": NoCleftSynapse,
"nocenter_synapse": NoCenterSynapse,
"fly_synapse": BuhmannSynapseSchema,
"fly_nt_synapse": BuhmannEcksteinSynapseSchema,
"bouton_shape": BoutonShape,
"presynaptic_bouton_type": PresynapticBoutonType,
"postsynaptic_compartment": PostsynapticCompartment,
"microns_func_coreg": FunctionalCoregistration,
"microns_func_unit_coreg": FunctionalUnitCoregistration,
"func_unit_ext_coreg": FunctionalUnitCoregistrationExtended,
"func_properties_bcm": FunctionalPropertiesBCM,
"simple_reference": ReferenceAnnotation,
"reference_tag": ReferenceTagAnnotation,
"cell_type_local": CellTypeLocal,
"cell_type_reference": CellTypeReference,
"nucleus_detection": NucleusDetection,
"bound_tag": BoundTagAnnotation,
"bound_double_tag": BoundDoubleTagAnnotation,
"bound_2tag": Bound2TagAnnotation,
"bound_tag_user": BoundTagAnnotationUser,
"bound_double_tag_user": BoundDoubleTagAnnotationUser,
"bound_2tag_user": Bound2TagAnnotationUser,
"extended_classical_cell_type": ExtendedClassicalCellType,
"plastic_synapse": PlasticSynapse,
"glia_contact": GliaContact,
"contact": Contact,
"derived_spatial_point": DerivedSpatialPoint,
"derived_tag": DerivedTag,
"derived_numeric_value": DerivedNumeric,
"proofread_status": ProofreadStatus,
"compartment_proofread_status": CompartmentProofreadStatus,
"proofreading_boolstatus_user": ProofreadingBoolStatusUser,
"fly_neuropil": FlyNeuropil,
"reference_point": FlatSegmentationReferenceSinglePoint,
"representative_point": RepresentativePoint,
"reference_synapse_valid": ValidSynapse,
"reference_simple_group": SimpleGroup,
"fly_cell_type": FlyCellType,
"fly_cell_type_ext": FlyCellTypeExt,
"braincircuits_annotation_user": BrainCircuitsBoundTagAnnotationUser,
"bound_tag_bool": BoundBoolAnnotation,
"bound_tag_bool_valid": BoundBoolWithValid,
"bound_tag_valid": BoundTagWithValid,
"pt_bool_valid": SpatialPointBoolWithValid,
"reference_integer": ReferenceInteger,
"reference_tag_float": ReferenceTagFloat,
"compartment_proofread_status_strategy": CompartmentProofreadStatusStrategy,
}
def get_types():
return [k for k in type_mapping.keys()]
def get_schema(schema_type: str):
"""Get schema class object by keyword, only
returns an object that is listed in :data:`type_mapping` dict
Parameters
----------
schema_type : str
Key name of schema in :data:`type_mapping`
Returns
-------
obj
marshmallow schema object
Raises
------
UnknownAnnotationTypeException
Key argument is not in :data:`type_mapping` dict
"""
try:
return type_mapping[schema_type]
except KeyError:
msg = f"Schema type: {schema_type} is not a known annotation type"
raise UnknownAnnotationTypeException(msg)
def get_flat_schema(schema_type: str):
try:
Schema = type_mapping[schema_type]
return create_flattened_schema(Schema)
except KeyError as e:
msg = f"Schema type: {schema_type} is not a known annotation type: {e}"
raise UnknownAnnotationTypeException(msg)