Skip to content

subject.py

activate(schema_name, *, create_schema=True, create_tables=True, linking_module=True)

Activate this schema.

Parameters:

Name Type Description Default
schema_name str

schema name on the database server to activate the subject element

required
create_schema bool

when True (default), create schema in the database if it does not yet exist.

True
create_tables bool

when True (default), create tables in the database if they do not yet exist.

True
linking_module bool

a module name or a module containing the

True
required dependencies to activate the `subject` element
required

Dependencies:

Upstream tables

Source: The source of the material/resources (e.g. allele, animal) - typically refers to the vendor (e.g. Jackson Lab - JAX) Lab: The lab for which a particular animal belongs to Protocol: the protocol applicable to a particular animal (e.g. IACUC, IRB) User: the user associated with a particular animal

Source code in element_animal/subject.py
 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
def activate(
    schema_name: str,
    *,
    create_schema: bool = True,
    create_tables: bool = True,
    linking_module: bool = True,
):
    """Activate this schema.

    Args:
        schema_name (str): schema name on the database server to activate the
                        `subject` element
        create_schema (bool): when True (default), create schema in the
                            database if it does not yet exist.
        create_tables (bool): when True (default), create tables in the
                            database if they do not yet exist.
        linking_module (bool): a module name or a module containing the
        required dependencies to activate the `subject` element:

    Dependencies:
    Upstream tables:
        Source: The source of the material/resources
                    (e.g. allele, animal) - typically refers to the
                    vendor (e.g. Jackson Lab - JAX)
        Lab: The lab for which a particular animal belongs to
        Protocol: the protocol applicable to a particular animal
                    (e.g. IACUC, IRB)
        User: the user associated with a particular animal
    """

    if isinstance(linking_module, str):
        linking_module = importlib.import_module(linking_module)
    assert inspect.ismodule(
        linking_module
    ), "The argument 'linking_module' must be a module's name or a module"

    global _linking_module
    _linking_module = linking_module

    schema.activate(
        schema_name,
        create_schema=create_schema,
        create_tables=create_tables,
        add_objects=linking_module.__dict__,
    )

Strain

Bases: dj.Lookup

Genetic strain of an animal. (e.g. C57Bl/6).

Attributes:

Name Type Description
strain varchar(32)

Abbreviated strain name.

strain_standard_name varchar(32)

Formal name of a strain.

strain_desc varchar(255)

Optional. Description of this strain.

Source code in element_animal/subject.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@schema
class Strain(dj.Lookup):
    """Genetic strain of an animal. (e.g. C57Bl/6).

    Attributes:
        strain ( varchar(32) ): Abbreviated strain name.
        strain_standard_name ( varchar(32) ): Formal name of a strain.
        strain_desc ( varchar(255) ): Optional. Description of this strain.
    """

    definition = """
    strain                  : varchar(32)	# abbreviated strain name
    ---
    strain_standard_name    : varchar(32)   # formal name of a strain
    strain_desc=''          : varchar(255)	# description of this strain
    """

Allele

Bases: dj.Lookup

Store allele information.

Attributes:

Name Type Description
allele varchar(32)

Abbreviated allele name.

allele_standard_name varchar(255)

Optional. Standard name of an allele.

Source code in element_animal/subject.py
 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
@schema
class Allele(dj.Lookup):
    """Store allele information.

    Attributes:
        allele ( varchar(32) ): Abbreviated allele name.
        allele_standard_name ( varchar(255) ): Optional. Standard name of an allele.
    """

    definition = """
    allele                    : varchar(32)  # abbreviated allele name
    ---
    allele_standard_name=''   : varchar(255) # standard name of an allele
    """

    class Source(dj.Part):
        """Source of an allele.

        Attributes:
            Allele (foreign key): Allele key.
            source_identifier ( varchar(255) ): ID of the provider.
            source_url ( varchar(255) ): Optional. URL to the source information
            expression_data_url ( varchar(255) ): Optional. Link to the expression pattern from Allen institute brain atlas.
        """

        definition = """
        -> master
        ---
        -> Source
        source_identifier=''  : varchar(255)
        source_url=''         : varchar(255) # link to the line information
        expression_data_url='': varchar(255) # link to the expression pattern from Allen institute brain atlas
        """

Source

Bases: dj.Part

Source of an allele.

Attributes:

Name Type Description
Allele foreign key

Allele key.

source_identifier varchar(255)

ID of the provider.

source_url varchar(255)

Optional. URL to the source information

expression_data_url varchar(255)

Optional. Link to the expression pattern from Allen institute brain atlas.

Source code in element_animal/subject.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
class Source(dj.Part):
    """Source of an allele.

    Attributes:
        Allele (foreign key): Allele key.
        source_identifier ( varchar(255) ): ID of the provider.
        source_url ( varchar(255) ): Optional. URL to the source information
        expression_data_url ( varchar(255) ): Optional. Link to the expression pattern from Allen institute brain atlas.
    """

    definition = """
    -> master
    ---
    -> Source
    source_identifier=''  : varchar(255)
    source_url=''         : varchar(255) # link to the line information
    expression_data_url='': varchar(255) # link to the expression pattern from Allen institute brain atlas
    """

Line

Bases: dj.Lookup

Genetic line.

Attributes:

Name Type Description
line varchar(32)

Abbreviated name for the line.

species varchar(64)

Latin name preferred for NWB export.

line_description varchar(2000)

Optional. Description of the line.

target_phenotype varchar(255)

Optional. Targeted gene phenotype.

is_active boolean)

Whether the line is in active breeding.

Source code in element_animal/subject.py
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
@schema
class Line(dj.Lookup):
    """Genetic line.

    Attributes:
        line ( varchar(32) ): Abbreviated name for the line.
        species ( varchar(64) ): Latin name preferred for NWB export.
        line_description ( varchar(2000) ): Optional. Description of the line.
        target_phenotype ( varchar(255) ): Optional. Targeted gene phenotype.
        is_active (boolean) : Whether the line is in active breeding.
    """

    definition = """
    line                : varchar(32)  # abbreviated name for the line
    ---
    species=''          : varchar(64)  # Latin name preferred for NWB export
    line_description='' : varchar(2000)
    target_phenotype='' : varchar(255)
    is_active           : boolean	   # whether the line is in active breeding
    """

    class Allele(dj.Part):
        """Allele of the line.

        Attributes:
            Line (foreign key): Line key.
            Allele (foreign key): Allele key.
        """

        definition = """
        -> master
        -> Allele
        """

Allele

Bases: dj.Part

Allele of the line.

Attributes:

Name Type Description
Line foreign key

Line key.

Allele foreign key

Allele key.

Source code in element_animal/subject.py
130
131
132
133
134
135
136
137
138
139
140
141
class Allele(dj.Part):
    """Allele of the line.

    Attributes:
        Line (foreign key): Line key.
        Allele (foreign key): Allele key.
    """

    definition = """
    -> master
    -> Allele
    """

Subject

Bases: dj.Manual

Animal subject information.

Attributes:

Name Type Description
subject varchar(8)

Subject ID.

subject_nickname varchar(8)

Subject nickname.

sex enum

'M', 'F', or 'U'; Male, Female, or Unknown.

subject_birth_date date

Birth date of the subject.

subject_description varchar(1024)

Description of the subject.

Source code in element_animal/subject.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
@schema
class Subject(dj.Manual):
    """Animal subject information.

    Attributes:
        subject ( varchar(8) ): Subject ID.
        subject_nickname ( varchar(8) ): Subject nickname.
        sex (enum): 'M', 'F', or 'U'; Male, Female, or Unknown.
        subject_birth_date (date): Birth date of the subject.
        subject_description ( varchar(1024) ): Description of the subject.
    """

    definition = """
    subject                 : varchar(8)
    ---
    subject_nickname=''     : varchar(64)
    sex                     : enum('M', 'F', 'U')
    subject_birth_date      : date
    subject_description=''  : varchar(1024)
    """

    class Protocol(dj.Part):
        """Protocol under which this subject animal is used.

        Attributes:
            Subject (foreign key): Subject key.
            Protocol (foreign key): Protocol key.
        """

        definition = """
        -> master
        -> Protocol
        """

    class User(dj.Part):
        """Individual responsible for experiment or management of the subject.

        Attributes:
            Subject (foreign key): Subject key.
            User (foreign key): User key.
        """

        definition = """
        -> master
        -> User
        """

    class Line(dj.Part):
        """Genetic line of the subject.

        Attributes:
            Subject (foreign key): Subject key.
            Line (foreign key): Line key.
        """

        definition = """
        -> master
        ---
        -> Line
        """

    class Strain(dj.Part):
        """Genetic strain of the subject.

        Attributes:
            Subject (foreign key): Subject key.
            Strain (foreign key): Strain key.
        """

        definition = """
        -> master
        ---
        -> Strain
        """

    class Source(dj.Part):
        """Source (e.g., vendor) of the subject.

        Attributes:
            Subject (foreign key): Subject key.
            Source (foreign key): Source key.
        """

        definition = """
        -> master
        ---
        -> Source
        """

    class Lab(dj.Part):
        """Lab where the subject belongs.

        Attributes:
            Subject (foreign key): Subject key.
            Lab (foreign key): Lab key.
            subject_alias ( varchar(32) ): Alias for lab if different from id.
        """

        definition = """
        -> master
        -> Lab
        ---
        subject_alias='' : varchar(32) # alias for lab if different from id.
        """

Protocol

Bases: dj.Part

Protocol under which this subject animal is used.

Attributes:

Name Type Description
Subject foreign key

Subject key.

Protocol foreign key

Protocol key.

Source code in element_animal/subject.py
165
166
167
168
169
170
171
172
173
174
175
176
class Protocol(dj.Part):
    """Protocol under which this subject animal is used.

    Attributes:
        Subject (foreign key): Subject key.
        Protocol (foreign key): Protocol key.
    """

    definition = """
    -> master
    -> Protocol
    """

User

Bases: dj.Part

Individual responsible for experiment or management of the subject.

Attributes:

Name Type Description
Subject foreign key

Subject key.

User foreign key

User key.

Source code in element_animal/subject.py
178
179
180
181
182
183
184
185
186
187
188
189
class User(dj.Part):
    """Individual responsible for experiment or management of the subject.

    Attributes:
        Subject (foreign key): Subject key.
        User (foreign key): User key.
    """

    definition = """
    -> master
    -> User
    """

Line

Bases: dj.Part

Genetic line of the subject.

Attributes:

Name Type Description
Subject foreign key

Subject key.

Line foreign key

Line key.

Source code in element_animal/subject.py
191
192
193
194
195
196
197
198
199
200
201
202
203
class Line(dj.Part):
    """Genetic line of the subject.

    Attributes:
        Subject (foreign key): Subject key.
        Line (foreign key): Line key.
    """

    definition = """
    -> master
    ---
    -> Line
    """

Strain

Bases: dj.Part

Genetic strain of the subject.

Attributes:

Name Type Description
Subject foreign key

Subject key.

Strain foreign key

Strain key.

Source code in element_animal/subject.py
205
206
207
208
209
210
211
212
213
214
215
216
217
class Strain(dj.Part):
    """Genetic strain of the subject.

    Attributes:
        Subject (foreign key): Subject key.
        Strain (foreign key): Strain key.
    """

    definition = """
    -> master
    ---
    -> Strain
    """

Source

Bases: dj.Part

Source (e.g., vendor) of the subject.

Attributes:

Name Type Description
Subject foreign key

Subject key.

Source foreign key

Source key.

Source code in element_animal/subject.py
219
220
221
222
223
224
225
226
227
228
229
230
231
class Source(dj.Part):
    """Source (e.g., vendor) of the subject.

    Attributes:
        Subject (foreign key): Subject key.
        Source (foreign key): Source key.
    """

    definition = """
    -> master
    ---
    -> Source
    """

Lab

Bases: dj.Part

Lab where the subject belongs.

Attributes:

Name Type Description
Subject foreign key

Subject key.

Lab foreign key

Lab key.

subject_alias varchar(32)

Alias for lab if different from id.

Source code in element_animal/subject.py
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
class Lab(dj.Part):
    """Lab where the subject belongs.

    Attributes:
        Subject (foreign key): Subject key.
        Lab (foreign key): Lab key.
        subject_alias ( varchar(32) ): Alias for lab if different from id.
    """

    definition = """
    -> master
    -> Lab
    ---
    subject_alias='' : varchar(32) # alias for lab if different from id.
    """

SubjectDeath

Bases: dj.Manual

Subject death information.

Attributes:

Name Type Description
Subject foreign key

Subject key.

date_date date)

Death date.

Source code in element_animal/subject.py
250
251
252
253
254
255
256
257
258
259
260
261
262
263
@schema
class SubjectDeath(dj.Manual):
    """Subject death information.

    Attributes:
        Subject (foreign key): Subject key.
        date_date (date) : Death date.
    """

    definition = """
    -> Subject
    ---
    death_date  : date       # death date
    """

SubjectCull

Bases: dj.Manual

Subject culling information.

Attributes:

Name Type Description
SubjectDeath foreign key

SubjectDeath key.

cull_method varchar(255)

Optional. Culling method (e.g., cervical dislocation)

cull_reason varchar(255)

Optional. Reason for culling.

cull_notes varchar(1000)

Optional. Description of the culling.

Source code in element_animal/subject.py
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
@schema
class SubjectCull(dj.Manual):
    """Subject culling information.

    Attributes:
        SubjectDeath (foreign key): SubjectDeath key.
        cull_method ( varchar(255) ): Optional. Culling method (e.g., cervical dislocation)
        cull_reason ( varchar(255) ): Optional. Reason for culling.
        cull_notes ( varchar(1000) ): Optional. Description of the culling.
    """

    definition = """
    -> SubjectDeath
    ---
    cull_method='': varchar(255)
    cull_reason='': varchar(255)
    cull_notes='' : varchar(1000)
    """

Zygosity

Bases: dj.Manual

Information about zygosity of a subject.

Attributes:

Name Type Description
Subject foreign key

Subject key.

Allele foreign key

Allele key.

zygosity Present or Absent or Homozygous or Heterozygous

Similarity of an allele.

Source code in element_animal/subject.py
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
@schema
class Zygosity(dj.Manual):
    """Information about zygosity of a subject.

    Attributes:
        Subject (foreign key): Subject key.
        Allele (foreign key): Allele key.
        zygosity (Present or Absent or Homozygous or Heterozygous): Similarity of an allele.
    """

    definition = """
    -> Subject
    -> Allele
    ---
    zygosity : enum("Present", "Absent", "Homozygous", "Heterozygous")
    """