Skip to content

Commit a7cf6ee

Browse files
authored
Merge pull request #41 from CBroz1/dev
Add project schema to main
2 parents d64224c + 26e6e5d commit a7cf6ee

File tree

5 files changed

+279
-44
lines changed

5 files changed

+279
-44
lines changed

CHANGELOG.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,26 @@
22

33
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
44

5+
## [0.2.0] - 2022-12-12
6+
+ Add - `project` schema for project/study/experiment related tables
7+
58
## [0.1.2] - 2022-10-17
6-
### Updated
7-
+ CICD for triggering PyPI release
9+
+ Update - CICD for triggering PyPI release
810

911
## [0.1.1] - 2022-05-10
10-
### Added
11-
+ Adopted black formatting into code base
12+
+ Add - Adopted black formatting into code base
1213

1314
## [0.1.0b1] - 2022-01-28
14-
### Added
15-
+ Added functions to generate dictionaries for NWB export.
16-
15+
+ Add - Functions to generate dictionaries for NWB export.
1716

1817
## [0.1.0b0] - 2021-05-07
19-
### Added
20-
+ First beta release
21-
18+
+ Add - First beta release
2219

2320
## [0.1.0a1] - 2021-04-30
24-
### Added
25-
+ Added GitHub Action release process
26-
+ Added `lab` schema
21+
+ Add - GitHub Action release process
22+
+ Add - `lab` schema
2723

24+
[0.2.0]: https://github.com/datajoint/element-lab/releases/tag/0.2.0
2825
[0.1.2]: https://github.com/datajoint/element-lab/releases/tag/0.1.2
2926
[0.1.1]: https://github.com/datajoint/element-lab/releases/tag/0.1.1
3027
[0.1.0b1]: https://github.com/datajoint/element-lab/releases/tag/0.1.0b1

element_lab/export/nwb.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
import logging
12
from element_lab import lab
23

4+
logger = logging.getLogger("datajoint")
5+
6+
logger.warning(
7+
'Element Lab\'s "project" schema does not yet feature NWB export.'
8+
+ "Please use lab.Project and lab.Protocol tables"
9+
)
10+
311

412
def _lab_to_nwb_dict(lab_key: dict) -> dict:
513
"""Generate a dictionary containing all relevant lab and institution info.
@@ -61,7 +69,7 @@ def element_lab_to_nwb_dict(
6169
lab_key: dict = None, project_key: dict = None, protocol_key: dict = None
6270
) -> dict:
6371
"""Generate a NWB-compliant dictionary object for lab metadata
64-
72+
6573
Generate a dictionary object containing all relevant lab information used
6674
when generating an NWB file at the session level.
6775
All parameters optional, but should only specify one of respective type.

element_lab/lab.py

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import logging
2+
13
import datajoint as dj
24

5+
logger = logging.getLogger("datajoint")
6+
37
schema = dj.Schema()
48

59

@@ -19,44 +23,68 @@ def activate(schema_name: str, create_schema: bool = True, create_tables: bool =
1923
)
2024

2125

26+
@schema
27+
class Organization(dj.Manual):
28+
"""Top-level list of all organizations involved in any of the projects.
29+
30+
Attributes:
31+
organization ( varchar(24) ): Abbreviated organization name.
32+
org_name ( varchar(255) ): Full organization name.
33+
org_address ( varchar(512), optional ): Address of the organization.
34+
org_comment ( varchar(1024), optional ): Additional notes on the organization.
35+
"""
36+
37+
definition = """# Top-level list of all organizations involved in any of the projects
38+
organization : varchar(24) # Abbreviated organization name
39+
---
40+
org_name : varchar(255) # Full organization name
41+
org_address='' : varchar(512) # Address of the organization
42+
org_comment='' : varchar(1024) # Additional notes on the organization
43+
"""
44+
45+
2246
@schema
2347
class Lab(dj.Lookup):
2448
"""Table for storing general lab info.
2549
2650
Attributes:
2751
lab ( varchar(24) ): Abbreviated lab name.
2852
lab_name ( varchar(255) ): Full lab name.
29-
institution ( varchar(255) ): Name of the affiliation institution.
3053
address ( varchar(255) ): Physical lab address.
31-
time_zone ( varchar(64) ): If using NWB export, use 'UTC±X' format
54+
time_zone ( varchar(64) ): 'UTC±X' format or timezone, e.g., America/New_York.
55+
If using NWB export, use 'UTC±X' format.
3256
"""
3357

34-
definition = """
35-
lab : varchar(24) # abbreviated lab name
58+
definition = """# Table for storing general lab info.
59+
lab : varchar(24) # Abbreviated lab name
3660
---
37-
lab_name : varchar(255) # full lab name
38-
institution : varchar(255)
39-
address : varchar(255)
40-
time_zone : varchar(64) # 'UTC±X' format for NWB export
61+
lab_name : varchar(255) # Full lab name
62+
address : varchar(255) # Physical lab address
63+
time_zone : varchar(64) # 'UTC±X' format or timezone, e.g., America/New_York
4164
"""
4265

66+
class Organization(dj.Part):
67+
definition = """
68+
-> master
69+
-> Organization
70+
"""
71+
4372

4473
@schema
4574
class Location(dj.Lookup):
46-
"""Location of research (e.g., animal housing or experimental rigs)
75+
"""Location of research (e.g., animal housing or experimental rigs).
4776
4877
Attributes:
4978
Lab (foreign key): Lab key.
5079
location ( varchar(32) ): Location of a space related to the lab.
5180
location_description ( varchar(255), optional ): Description of the location.
5281
"""
5382

54-
definition = """
55-
# location of research (e.g., animal housing or experimental rigs)
83+
definition = """# location of research (e.g., animal housing or experimental rigs)
5684
-> Lab
57-
location : varchar(32)
85+
location : varchar(32) # Location of a space related to the lab
5886
---
59-
location_description='' : varchar(255)
87+
location_description='' : varchar(255) # Description of the location
6088
"""
6189

6290

@@ -65,11 +93,11 @@ class UserRole(dj.Lookup):
6593
"""Roles assigned to a user or a job title.
6694
6795
Attributes:
68-
user_role ( varchar(16) ): Role within the lab (e.g., PI, Postdoc, etc.).
96+
user_role ( varchar(24) ): Role within the lab (e.g., PI, Postdoc, etc.).
6997
"""
7098

71-
definition = """
72-
user_role : varchar(16) # Role within the lab (e.g., PI, Postdoc, etc.)
99+
definition = """# Roles assigned to a user or a job title.
100+
user_role : varchar(24) # Role within the lab (e.g., PI, Postdoc, etc.)
73101
"""
74102

75103

@@ -79,15 +107,17 @@ class User(dj.Lookup):
79107
80108
Attributes:
81109
user ( varchar(32) ): User name.
82-
user_email ( varchar(128) ): User email address.
83-
user_cellphone ( varchar(32) ): User cellphone number.
110+
user_email ( varchar(128), optional ): User email address.
111+
user_cellphone ( varchar(32), optional ): User cellphone number.
112+
user_fullname ( varchar(64), optional ): User full name
84113
"""
85114

86-
definition = """
87-
user : varchar(32)
115+
definition = """# Table for storing user information.
116+
user : varchar(32) # username, short identifier
88117
---
89118
user_email='' : varchar(128)
90119
user_cellphone='' : varchar(32)
120+
user_fullname='' : varchar(64) # Full name used to uniquely identify an individual
91121
"""
92122

93123

@@ -101,7 +131,7 @@ class LabMembership(dj.Lookup):
101131
UserRole (foreign key): Optional. UserRole primary key.
102132
"""
103133

104-
definition = """
134+
definition = """# Store lab membership information using three lookup tables.
105135
-> Lab
106136
-> User
107137
---
@@ -117,26 +147,26 @@ class ProtocolType(dj.Lookup):
117147
protocol_type ( varchar(32) ): Protocol types (e.g., IACUC, IRB, etc.).
118148
"""
119149

120-
definition = """
121-
protocol_type : varchar(32)
150+
definition = """# Type of protocol or issuing agency
151+
protocol_type : varchar(32) # Protocol types (e.g., IACUC, IRB, etc.)
122152
"""
123153

124154

125155
@schema
126156
class Protocol(dj.Lookup):
127-
"""Protocol specifics (e.g., protocol number and title).
157+
"""Protocol approved by institutions (e.g. IACUC, IRB), or experimental protocol.
128158
129159
Attributes:
130-
protocol ( varchar(16) ): Protocol identifier.
160+
protocol ( varchar(36) ): Protocol identifier.
131161
ProtocolType (foreign key): ProtocolType key.
132-
protocol_description( varchar(255) ): Optional. Description of the protocol.
162+
protocol_description( varchar(255), optional ): Description of the protocol.
133163
"""
134164

135-
definition = """
136-
protocol : varchar(16)
165+
definition = """# Protocol approved by institutions (e.g. IACUC, IRB), or experimental protocol.
166+
protocol : varchar(36) # Protocol identifier.
137167
---
138168
-> ProtocolType
139-
protocol_description='' : varchar(255)
169+
protocol_description='' : varchar(255) # Description of the protocol
140170
"""
141171

142172

@@ -149,6 +179,11 @@ class Project(dj.Lookup):
149179
project_description ( varchar(1024) ): Description about the project.
150180
"""
151181

182+
logger.warning(
183+
"lab.Project and related tables will be removed in a future version of"
184+
+ " Element Lab. Please use the project schema."
185+
)
186+
152187
definition = """
153188
project : varchar(32)
154189
---

0 commit comments

Comments
 (0)