Skip to content

lab.py

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

Activate this schema

Parameters:

Name Type Description Default
schema_name str

schema name on the database server to activate the lab 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 schema tables in the database if they do not yet exist.

True
Source code in element_lab/lab.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def activate(schema_name: str, create_schema: bool = True, create_tables: bool = True):
    """Activate this schema

    Args:
        schema_name (str): schema name on the database server to activate the `lab` 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 schema tables in the database
                             if they do not yet exist.
    """

    schema.activate(
        schema_name, create_schema=create_schema, create_tables=create_tables
    )

Organization

Bases: dj.Manual

Top-level list of all organizations involved in any of the projects.

Attributes:

Name Type Description
organization varchar(24)

Abbreviated organization name.

org_name varchar(255)

Full organization name.

org_address varchar(512), optional

Address of the organization.

org_comment varchar(1024), optional

Additional notes on the organization.

Source code in element_lab/lab.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@schema
class Organization(dj.Manual):
    """Top-level list of all organizations involved in any of the projects.

    Attributes:
        organization ( varchar(24) ): Abbreviated organization name.
        org_name ( varchar(255) ): Full organization name.
        org_address ( varchar(512), optional ): Address of the organization.
        org_comment ( varchar(1024), optional ): Additional notes on the organization.
    """

    definition = """# Top-level list of all organizations involved in any of the projects
    organization      : varchar(24)   # Abbreviated organization name
    ---
    org_name          : varchar(255)  # Full organization name
    org_address=''    : varchar(512)  # Address of the organization
    org_comment=''    : varchar(1024) # Additional notes on the organization
    """

Lab

Bases: dj.Lookup

Table for storing general lab info.

Attributes:

Name Type Description
lab varchar(24)

Abbreviated lab name.

lab_name varchar(255)

Full lab name.

address varchar(255)

Physical lab address.

time_zone varchar(64)

'UTC±X' format or timezone, e.g., America/New_York. If using NWB export, use 'UTC±X' format.

Source code in element_lab/lab.py
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
@schema
class Lab(dj.Lookup):
    """Table for storing general lab info.

    Attributes:
        lab ( varchar(24) ): Abbreviated lab name.
        lab_name ( varchar(255) ): Full lab name.
        address ( varchar(255) ): Physical lab address.
        time_zone ( varchar(64) ): 'UTC±X' format or timezone, e.g., America/New_York.
            If using NWB export, use 'UTC±X' format.
    """

    definition = """# Table for storing general lab info.
    lab             : varchar(24)    # Abbreviated lab name
    ---
    lab_name        : varchar(255)   # Full lab name
    address         : varchar(255)    # Physical lab address
    time_zone       : varchar(64)    # 'UTC±X' format or timezone, e.g., America/New_York
    """

    class Organization(dj.Part):
        definition = """
        -> master
        -> Organization
        """

Location

Bases: dj.Lookup

Location of research (e.g., animal housing or experimental rigs).

Attributes:

Name Type Description
Lab foreign key

Lab key.

location varchar(32)

Location of a space related to the lab.

location_description varchar(255), optional

Description of the location.

Source code in element_lab/lab.py
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
@schema
class Location(dj.Lookup):
    """Location of research (e.g., animal housing or experimental rigs).

    Attributes:
        Lab (foreign key): Lab key.
        location ( varchar(32) ): Location of a space related to the lab.
        location_description ( varchar(255), optional ): Description of the location.
    """

    definition = """# location of research (e.g., animal housing or experimental rigs)
    -> Lab
    location                   : varchar(32)   # Location of a space related to the lab
    ---
    location_description=''    : varchar(255)  # Description of the location
    """

UserRole

Bases: dj.Lookup

Roles assigned to a user or a job title.

Attributes:

Name Type Description
user_role varchar(24)

Role within the lab (e.g., PI, Postdoc, etc.).

Source code in element_lab/lab.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
@schema
class UserRole(dj.Lookup):
    """Roles assigned to a user or a job title.

    Attributes:
        user_role ( varchar(24) ): Role within the lab (e.g., PI, Postdoc, etc.).
    """

    definition = """# Roles assigned to a user or a job title.
    user_role           : varchar(24) # Role within the lab (e.g., PI, Postdoc, etc.)
    """

User

Bases: dj.Lookup

Table for storing user information.

Attributes:

Name Type Description
user varchar(32)

User name.

user_email varchar(128), optional

User email address.

user_cellphone varchar(32), optional

User cellphone number.

user_fullname varchar(64), optional

User full name

Source code in element_lab/lab.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
@schema
class User(dj.Lookup):
    """Table for storing user information.

    Attributes:
        user ( varchar(32) ): User name.
        user_email ( varchar(128), optional ): User email address.
        user_cellphone ( varchar(32), optional ): User cellphone number.
        user_fullname ( varchar(64), optional ): User full name
    """

    definition = """# Table for storing user information.
    user                : varchar(32)  # username, short identifier
    ---
    user_email=''       : varchar(128)
    user_cellphone=''   : varchar(32)
    user_fullname=''    : varchar(64)  # Full name used to uniquely identify an individual
    """

LabMembership

Bases: dj.Lookup

Store lab membership information using three lookup tables.

Attributes:

Name Type Description
Lab foreign key

Lab key.

User foreign key

User key.

UserRole foreign key

Optional. UserRole primary key.

Source code in element_lab/lab.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
@schema
class LabMembership(dj.Lookup):
    """Store lab membership information using three lookup tables.

    Attributes:
        Lab (foreign key): Lab key.
        User (foreign key): User key.
        UserRole (foreign key): Optional. UserRole primary key.
    """

    definition = """# Store lab membership information using three lookup tables.
    -> Lab
    -> User
    ---
    -> [nullable] UserRole
    """

ProtocolType

Bases: dj.Lookup

Type of protocol or issuing agency.

Attributes:

Name Type Description
protocol_type varchar(32)

Protocol types (e.g., IACUC, IRB, etc.).

Source code in element_lab/lab.py
142
143
144
145
146
147
148
149
150
151
152
@schema
class ProtocolType(dj.Lookup):
    """Type of protocol or issuing agency.

    Attributes:
        protocol_type ( varchar(32) ): Protocol types (e.g., IACUC, IRB, etc.).
    """

    definition = """# Type of protocol or issuing agency
    protocol_type           : varchar(32)  # Protocol types (e.g., IACUC, IRB, etc.)
    """

Protocol

Bases: dj.Lookup

Protocol approved by institutions (e.g. IACUC, IRB), or experimental protocol.

Attributes:

Name Type Description
protocol varchar(36)

Protocol identifier.

ProtocolType foreign key

ProtocolType key.

protocol_description( varchar(255), optional

Description of the protocol.

Source code in element_lab/lab.py
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
@schema
class Protocol(dj.Lookup):
    """Protocol approved by institutions (e.g. IACUC, IRB), or experimental protocol.

    Attributes:
        protocol ( varchar(36) ): Protocol identifier.
        ProtocolType (foreign key): ProtocolType key.
        protocol_description( varchar(255), optional ): Description of the protocol.
    """

    definition = """# Protocol approved by institutions (e.g. IACUC, IRB), or experimental protocol.
    protocol                : varchar(36)   # Protocol identifier.
    ---
    -> ProtocolType
    protocol_description='' : varchar(255)  # Description of the protocol
    """

Project

Bases: dj.Lookup

Projects within a lab.

Attributes:

Name Type Description
project varchar(32)

Project identifier.

project_description varchar(1024)

Description about the project.

Source code in element_lab/lab.py
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
@schema
class Project(dj.Lookup):
    """Projects within a lab.

    Attributes:
        project ( varchar(32) ): Project identifier.
        project_description ( varchar(1024) ): Description about the project.
    """

    logger.warning(
        "lab.Project and related tables will be removed in a future version of"
        + " Element Lab. Please use the project schema."
    )

    definition = """
    project                 : varchar(32)
    ---
    project_description=''  : varchar(1024)
    """

ProjectKeywords

Bases: dj.Manual

Project keywords or meta-information.

Attributes:

Name Type Description
Project foreign key

Project key.

keyword varchar(32)

Descriptive keyword about the project.

Source code in element_lab/lab.py
194
195
196
197
198
199
200
201
202
203
204
205
206
@schema
class ProjectKeywords(dj.Manual):
    """Project keywords or meta-information.

    Attributes:
        Project (foreign key): Project key.
        keyword ( varchar(32) ): Descriptive keyword about the project.
    """

    definition = """
    -> Project
    keyword:    varchar(32)
    """

ProjectPublication

Bases: dj.Manual

Project's resulting publications.

Attributes:

Name Type Description
Project foreign key

Project key.

publication varchar(256)

Name of the published paper.

Source code in element_lab/lab.py
209
210
211
212
213
214
215
216
217
218
219
220
221
@schema
class ProjectPublication(dj.Manual):
    """Project's resulting publications.

    Attributes:
        Project (foreign key): Project key.
        publication ( varchar(256) ): Name of the published paper.
    """

    definition = """
    -> Project
    publication:    varchar(256)
    """

ProjectSourceCode

Bases: dj.Manual

URL to source code for replication.

Attributes:

Name Type Description
Project foreign key

Project key.

repository_url varchar(256)

URL to the code repository.

repository_name varchar(32)

Name of the repository.

Source code in element_lab/lab.py
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
@schema
class ProjectSourceCode(dj.Manual):
    """URL to source code for replication.

    Attributes:
        Project (foreign key): Project key.
        repository_url ( varchar(256) ): URL to the code repository.
        repository_name ( varchar(32) ): Name of the repository.
    """

    definition = """
    -> Project
    repository_url     : varchar(256)
    ---
    repository_name='' : varchar(32)
    """

ProjectUser

Bases: dj.Manual

Users participating in the project.

Attributes:

Name Type Description
Project foreign key

Project key.

User foreign key

User key.

Source code in element_lab/lab.py
242
243
244
245
246
247
248
249
250
251
252
253
254
@schema
class ProjectUser(dj.Manual):
    """Users participating in the project.

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

    definition = """
    -> Project
    -> User
    """

Source

Bases: dj.Lookup

Source or supplier of subject animals.

Attributes:

Name Type Description
source varchar(32)

Abbreviated source name.

source_name varchar(255)

Source name.

contact_details varchar(255)

Optional. Phone number and/or email.

source_description varchar(255)

Optional. Description of the source.

Source code in element_lab/lab.py
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
@schema
class Source(dj.Lookup):
    """Source or supplier of subject animals.

    Attributes:
        source ( varchar(32) ): Abbreviated source name.
        source_name ( varchar(255) ): Source name.
        contact_details ( varchar(255) ): Optional. Phone number and/or email.
        source_description ( varchar(255) ): Optional. Description of the source.
    """

    definition = """
    source                : varchar(32)  # abbreviated source name
    ---
    source_name           : varchar(255)
    contact_details=''    : varchar(255)
    source_description='' : varchar(255)
    """

Device

Bases: dj.Lookup

Devices within the lab.

Attributes:

Name Type Description
device varchar(32)

Device short name.

modality varchar(64)

Modality for which this device is used.

description varchar(256)

Optional. Description of the device.

Source code in element_lab/lab.py
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
@schema
class Device(dj.Lookup):
    """Devices within the lab.

    Attributes:
        device ( varchar(32) ): Device short name.
        modality ( varchar(64) ): Modality for which this device is used.
        description ( varchar(256) ): Optional. Description of the device.
    """

    definition = """
    device             : varchar(32)
    ---
    modality           : varchar(64)
    description=''     : varchar(256)
    """