From 129945d1189da4c80d59c555384a223e2e2b2835 Mon Sep 17 00:00:00 2001 From: kushalbakshi Date: Mon, 14 Aug 2023 17:01:38 -0500 Subject: [PATCH 01/13] Edit existing docstrings + add injection schema --- element_animal/injection.py | 129 ++++++++++++++++++++++++++++++++++++ element_animal/subject.py | 2 +- element_animal/surgery.py | 40 ++++++----- 3 files changed, 155 insertions(+), 16 deletions(-) create mode 100644 element_animal/injection.py diff --git a/element_animal/injection.py b/element_animal/injection.py new file mode 100644 index 0000000..4b60aa7 --- /dev/null +++ b/element_animal/injection.py @@ -0,0 +1,129 @@ +import importlib +import inspect + +import datajoint as dj + +from . import surgery + +schema = dj.Schema() + +_linking_module = None + + +def activate( + injection_schema_name: str, + surgery_schema_name: str = None, + *, + 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: + User: the who conducted a particular surgery/implantation + """ + + 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 + + surgery.activate( + surgery_schema_name, + create_schema=create_schema, + create_tables=create_tables, + linking_module=linking_module, + ) + schema.activate( + injection_schema_name, + create_schema=create_schema, + create_tables=create_tables, + add_objects=linking_module.__dict__, + ) + + +@schema +class AAVSerotype(dj.Lookup): + definition = """ + aav_serotype: varchar(10) + """ + contents = zip( + [ + "AAV1", + "AAV2", + "AAV4", + "AAV5", + "AAV6", + "AAV7", + "AAV8", + "AAV9", + "AAV2/1", + "AAV2/5", + "AAV2/9", + "AAVrg", + "AAV/DJ", + "pAAV", + ] + ) + + +@schema +class MicroInjectionDevice(dj.Lookup): + definition = """ + micro_injection_device: varchar(12) + """ + contents = zip( + [ + "Nanoject", + "Picospritzer", + ] + ) + + +@schema +class InjectionProtocol(dj.Manual): + definition = """ + -> MicroInjectionDevice + protocol_id : int + --- + volume_per_pulse : float + injection_rate : float + interpulse_delay : float + """ + + +@schema +class VirusName(dj.Manual): + definition = """ + virus_name: varchar(64) # Full virus name. Ex: AAV1.CAG.Flex.ArchT.GFP. + """ + + +@schema +class Injection(dj.Manual): + definition = """ + -> surgery.Implantation + -> VirusName + -> surgery.BrainRegion + --- + -> [nullable] AAVSerotype + -> [nullable] InjectionProtocol + titer : varchar(16) + total_volume : float + """ diff --git a/element_animal/subject.py b/element_animal/subject.py index f706105..d258df3 100644 --- a/element_animal/subject.py +++ b/element_animal/subject.py @@ -147,7 +147,7 @@ class Subject(dj.Manual): Attributes: subject ( varchar(8) ): Subject ID. - subject_nickname ( varchar(8) ): Subject nickname. + subject_nickname ( varchar(64) ): 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. diff --git a/element_animal/surgery.py b/element_animal/surgery.py index d3e8ae2..62ca7f3 100644 --- a/element_animal/surgery.py +++ b/element_animal/surgery.py @@ -132,21 +132,15 @@ class Implantation(dj.Manual): """Implantation of a device Attributes: - Session (foreign key): Session primary key - location_id (int): ID of of brain location - ap ( float ): In mm, Anterior/posterior; Anterior Positive - ap_reference (projected attribute): Coordinate reference - ml ( float ): In mm, medial axis; Right Positive - ml_reference (projected attribute): Coordinate reference - dv ( float ): In mm, dorso-ventral axis. Ventral negative - dv_reference (projected attribute): Coordinate reference - theta ( float, nullable ): Elevation in degrees. - Rotation about ml-axis [0, 180] relative to z-axis - phi ( float, nullable ): Azimuth in degrees. - Rotations about dv-axis [0, 360] relative to x-axis - beta ( float, nullable ): Rotation about shank in degrees. - Rotation about the shank [-180, 180]. Clockwise is increasing. - 0 is the probe-front facing anterior + Subject (foreign key): Subject primary key. + implant_date (datetime): ID of brain location. + ImplantationType (foreign key): ImplantationType primary key. + region_acronym ( projected attribute, varchar(32) ): Brain region + shorthand from BrainRegion. + hemisphere ( projected attribute, varchar(8) ): Brain region hemisphere + from Hemisphere. + user ( projected attribute, varchar(32) ): User who performed the surgery. + implant_comment ( varchar(1024) ): Comments about the implant. """ definition = """ @@ -161,6 +155,22 @@ class Implantation(dj.Manual): """ class Coordinate(dj.Part): + """Coordinates of the Implantation Device. + + Attributes: + Implantation (foreign key): Primary keys from Implantation. + ap ( float ): In mm, Anterior/posterior; Anterior Positive. + ap_reference (projected attribute): Coordinate reference. + ml ( float ): In mm, medial axis; Right Positive. + ml_reference (projected attribute): Coordinate reference. + dv ( float ): In mm, dorso-ventral axis. Ventral negative. + dv_reference (projected attribute): Coordinate reference. + theta ( float, nullable ): Elevation in degrees. Rotation about ml-axis [0, 180] relative to z-axis. + phi ( float, nullable ): Azimuth in degrees. Rotations about dv-axis [0, 360] relative to x-axis. + beta ( float, nullable ): Rotation about shank in degrees. Rotation + about the shank [-180, 180]. Clockwise is increasing. 0 is the probe-front facing anterior. + """ + definition = """ -> master --- From 56b2109ba6d6b2ae80fc1d6a32a7d8bce92ba88b Mon Sep 17 00:00:00 2001 From: Kushal Bakshi <52367253+kushalbakshi@users.noreply.github.com> Date: Wed, 23 Aug 2023 15:07:46 -0500 Subject: [PATCH 02/13] Apply suggestions from code review Co-authored-by: Kabilar Gunalan --- element_animal/injection.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/element_animal/injection.py b/element_animal/injection.py index 4b60aa7..5793b8a 100644 --- a/element_animal/injection.py +++ b/element_animal/injection.py @@ -59,9 +59,9 @@ def activate( @schema -class AAVSerotype(dj.Lookup): +class VirusSerotype(dj.Lookup): definition = """ - aav_serotype: varchar(10) + virus_serotype: varchar(10) """ contents = zip( [ @@ -99,9 +99,9 @@ class MicroInjectionDevice(dj.Lookup): @schema class InjectionProtocol(dj.Manual): definition = """ - -> MicroInjectionDevice protocol_id : int --- + -> MicroInjectionDevice volume_per_pulse : float injection_rate : float interpulse_delay : float @@ -112,6 +112,8 @@ class InjectionProtocol(dj.Manual): class VirusName(dj.Manual): definition = """ virus_name: varchar(64) # Full virus name. Ex: AAV1.CAG.Flex.ArchT.GFP. + --- + -> VirusSerotype """ @@ -120,10 +122,9 @@ class Injection(dj.Manual): definition = """ -> surgery.Implantation -> VirusName - -> surgery.BrainRegion + -> InjectionProtocol --- - -> [nullable] AAVSerotype - -> [nullable] InjectionProtocol titer : varchar(16) total_volume : float + injection_comment='' : varchar(1024) """ From 679540158c920e05435dca5533ceb0961f023daf Mon Sep 17 00:00:00 2001 From: kushalbakshi Date: Wed, 23 Aug 2023 16:27:31 -0500 Subject: [PATCH 03/13] Update docstrings, requirements, docs, version --- CHANGELOG.md | 5 + docs/src/concepts.md | 13 +++ element_animal/injection.py | 58 ++++++++--- element_animal/version.py | 2 +- images/injection_diagram.svg | 187 +++++++++++++++++++++++++++++++++++ requirements.txt | 1 + 6 files changed, 251 insertions(+), 15 deletions(-) create mode 100644 images/injection_diagram.svg diff --git a/CHANGELOG.md b/CHANGELOG.md index 893dab6..a2abfe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention. +## [0.2.0] - 2023-08-23 + ++ Add - `injection` schema + ## [0.1.8] - 2023-06-20 + Update - GitHub Actions workflows @@ -58,6 +62,7 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and + Add - `subject` schema + Add - `genotyping` schema +[0.2.0]: https://github.com/datajoint/element-animal/releases/tag/0.2.0 [0.1.8]: https://github.com/datajoint/element-animal/releases/tag/0.1.8 [0.1.7]: https://github.com/datajoint/element-animal/releases/tag/0.1.7 [0.1.6]: https://github.com/datajoint/element-animal/releases/tag/0.1.6 diff --git a/docs/src/concepts.md b/docs/src/concepts.md index 52f772e..38e00c9 100644 --- a/docs/src/concepts.md +++ b/docs/src/concepts.md @@ -56,6 +56,10 @@ There are three modules in `element-animal`: ![Surgery schema diagram](https://raw.githubusercontent.com/datajoint/element-animal/main/images/surgery_diagram.svg) +### Injection Diagram + +![Injection schema diagram](https://raw.githubusercontent.com/datajoint/element-animal/main/images/injection_diagram.svg) + ## `subject` schema ([API docs](https://datajoint.com/docs/elements/element-animal/api/element_animal/subject)) - Although not required, most choose to connect the `Session` table to a `Subject` table. @@ -93,3 +97,12 @@ There are three modules in `element-animal`: | Hemisphere | Brain region hemisphere | | ImplantationType | Type of implantation | | Implantation | Implantation of a device | + +### `injection` schema ([API docs](https://datajoint.com/docs/elements/element-animal/api/element_animal/injection)) + +| Table | Description | +| ------------------- | -------------------------------------------------------------- | +| VirusSerotype | Virus serotype | +| InjectionProtocol | Injection device protocol | +| VirusName | Full virus name | +| Injection | Information about the virus injection | diff --git a/element_animal/injection.py b/element_animal/injection.py index 5793b8a..1e57dd2 100644 --- a/element_animal/injection.py +++ b/element_animal/injection.py @@ -3,6 +3,7 @@ import datajoint as dj +from element_lab import lab from . import surgery schema = dj.Schema() @@ -13,6 +14,7 @@ def activate( injection_schema_name: str, surgery_schema_name: str = None, + lab_schema_name: str = None, *, create_schema: bool = True, create_tables: bool = True, @@ -44,6 +46,11 @@ def activate( global _linking_module _linking_module = linking_module + lab.activate( + lab_schema_name, + create_schema=create_schema, + create_tables=create_tables, + ) surgery.activate( surgery_schema_name, create_schema=create_schema, @@ -60,6 +67,12 @@ def activate( @schema class VirusSerotype(dj.Lookup): + """Virus serotype. + + Attributes: + virus_serotype (str): Virus serotype. + """ + definition = """ virus_serotype: varchar(10) """ @@ -84,24 +97,22 @@ class VirusSerotype(dj.Lookup): @schema -class MicroInjectionDevice(dj.Lookup): - definition = """ - micro_injection_device: varchar(12) +class InjectionProtocol(dj.Manual): + """Injection device protocol. + + Attributes: + protocol_id (int): Unique protocol ID. + lab.Device (foreign key): Primary key from lab.Device. + volume_per_pulse (float): Volume dispensed per microinjector pulse. + injection_rate (float): Rate at which injectate is dispensed. + interpulse_delay (float): Delay between injection pulses. Set to 0 if + injection is a single pulse. """ - contents = zip( - [ - "Nanoject", - "Picospritzer", - ] - ) - -@schema -class InjectionProtocol(dj.Manual): definition = """ protocol_id : int --- - -> MicroInjectionDevice + -> lab.Device volume_per_pulse : float injection_rate : float interpulse_delay : float @@ -110,15 +121,34 @@ class InjectionProtocol(dj.Manual): @schema class VirusName(dj.Manual): + """Full virus name. + + Attributes: + virus_name (str): Full virus name. Ex: AAV1.CAG.Flex.ArchT.GFP. + VirusSerotype (foreign key, nullable): Primary key from VirusSerotype. + """ + definition = """ virus_name: varchar(64) # Full virus name. Ex: AAV1.CAG.Flex.ArchT.GFP. --- - -> VirusSerotype + -> [nullable] VirusSerotype """ @schema class Injection(dj.Manual): + """Information about the virus injection. + + Attributes: + surgery.Implantation (foreign key): Primary key from + surgery.Implantation. + VirusName (foreign key): Primary key from VirusName. + InjectionProtocol (foreign key): Primary key from InjectionProtocol. + titer (str): Titer of injectate at the current injection site. + total_volume (float): Total volume injected at the current injection site. + injection_comment (str): Comments about the virus injection. + """ + definition = """ -> surgery.Implantation -> VirusName diff --git a/element_animal/version.py b/element_animal/version.py index 10bc5c5..8667345 100644 --- a/element_animal/version.py +++ b/element_animal/version.py @@ -1,2 +1,2 @@ """Package metadata.""" -__version__ = "0.1.8" +__version__ = "0.2.0" diff --git a/images/injection_diagram.svg b/images/injection_diagram.svg new file mode 100644 index 0000000..1e11c50 --- /dev/null +++ b/images/injection_diagram.svg @@ -0,0 +1,187 @@ + + +%3 + + +28 + +28 + + +surgery.Implantation.Coordinate + + +surgery.Implantation.Coordinate + + + + +28->surgery.Implantation.Coordinate + + + +24 + +24 + + +surgery.Implantation + + +surgery.Implantation + + + + +24->surgery.Implantation + + + +29 + +29 + + +29->surgery.Implantation.Coordinate + + + +25 + +25 + + +25->surgery.Implantation + + + +27 + +27 + + +27->surgery.Implantation.Coordinate + + + +injection.VirusSerotype + + +injection.VirusSerotype + + + + +injection.VirusName + + +injection.VirusName + + + + +injection.VirusSerotype->injection.VirusName + + + +injection.MicroInjectionDevice + + +injection.MicroInjectionDevice + + + + +injection.InjectionProtocol + + +injection.InjectionProtocol + + + + +injection.MicroInjectionDevice->injection.InjectionProtocol + + + +surgery.Hemisphere + + +surgery.Hemisphere + + + + +surgery.Hemisphere->25 + + + +surgery.BrainRegion + + +surgery.BrainRegion + + + + +surgery.BrainRegion->24 + + + +surgery.ImplantationType + + +surgery.ImplantationType + + + + +surgery.ImplantationType->surgery.Implantation + + + +injection.Injection + + +injection.Injection + + + + +injection.VirusName->injection.Injection + + + +injection.InjectionProtocol->injection.Injection + + + +surgery.CoordinateReference + + +surgery.CoordinateReference + + + + +surgery.CoordinateReference->28 + + + +surgery.CoordinateReference->29 + + + +surgery.CoordinateReference->27 + + + +surgery.Implantation->surgery.Implantation.Coordinate + + + +surgery.Implantation->injection.Injection + + + + \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 41a088b..4f7998f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ datajoint>=0.13 +element-lab pynwb>=1.4.0 From e78dfe461bf82de9bb77df3d9fa8cea50c0deb55 Mon Sep 17 00:00:00 2001 From: kushalbakshi Date: Wed, 23 Aug 2023 16:32:54 -0500 Subject: [PATCH 04/13] Attempt 1: Modify for formatting --- element_animal/injection.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/element_animal/injection.py b/element_animal/injection.py index 1e57dd2..7299024 100644 --- a/element_animal/injection.py +++ b/element_animal/injection.py @@ -145,7 +145,8 @@ class Injection(dj.Manual): VirusName (foreign key): Primary key from VirusName. InjectionProtocol (foreign key): Primary key from InjectionProtocol. titer (str): Titer of injectate at the current injection site. - total_volume (float): Total volume injected at the current injection site. + total_volume (float): Total volume injected at the current injection + site. injection_comment (str): Comments about the virus injection. """ From 6d7b1355c165d420dce5f9998c6a633cfec5e818 Mon Sep 17 00:00:00 2001 From: kushalbakshi Date: Wed, 23 Aug 2023 16:40:14 -0500 Subject: [PATCH 05/13] Attempt 2: Modify for formatting --- element_animal/injection.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/element_animal/injection.py b/element_animal/injection.py index 7299024..dfabe20 100644 --- a/element_animal/injection.py +++ b/element_animal/injection.py @@ -129,7 +129,7 @@ class VirusName(dj.Manual): """ definition = """ - virus_name: varchar(64) # Full virus name. Ex: AAV1.CAG.Flex.ArchT.GFP. + virus_name: varchar(64) # Full virus name. Ex: AAV1.CAG.Flex.ArchT.GFP. --- -> [nullable] VirusSerotype """ @@ -145,8 +145,7 @@ class Injection(dj.Manual): VirusName (foreign key): Primary key from VirusName. InjectionProtocol (foreign key): Primary key from InjectionProtocol. titer (str): Titer of injectate at the current injection site. - total_volume (float): Total volume injected at the current injection - site. + total_volume (float): Total volume injected at the current injection site. injection_comment (str): Comments about the virus injection. """ From 7b2dd72bd6d1c59110c95bb5825a4356dadce166 Mon Sep 17 00:00:00 2001 From: kushalbakshi Date: Wed, 23 Aug 2023 16:56:15 -0500 Subject: [PATCH 06/13] Attempt 3: formatting with local pre-commit --- element_animal/injection.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/element_animal/injection.py b/element_animal/injection.py index dfabe20..c744ab9 100644 --- a/element_animal/injection.py +++ b/element_animal/injection.py @@ -7,7 +7,6 @@ from . import surgery schema = dj.Schema() - _linking_module = None @@ -99,7 +98,7 @@ class VirusSerotype(dj.Lookup): @schema class InjectionProtocol(dj.Manual): """Injection device protocol. - + Attributes: protocol_id (int): Unique protocol ID. lab.Device (foreign key): Primary key from lab.Device. @@ -145,8 +144,8 @@ class Injection(dj.Manual): VirusName (foreign key): Primary key from VirusName. InjectionProtocol (foreign key): Primary key from InjectionProtocol. titer (str): Titer of injectate at the current injection site. - total_volume (float): Total volume injected at the current injection site. - injection_comment (str): Comments about the virus injection. + total_volume (float): Total volume injected at the current injection site. + injection_comment (str): Comments about the virus injection. """ definition = """ From ba04bae87173f659dd62cd0aed83f89907d045ec Mon Sep 17 00:00:00 2001 From: Kushal Bakshi <52367253+kushalbakshi@users.noreply.github.com> Date: Thu, 24 Aug 2023 12:57:52 -0500 Subject: [PATCH 07/13] Apply suggestions from code review Co-authored-by: Kabilar Gunalan --- element_animal/surgery.py | 4 ++-- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/element_animal/surgery.py b/element_animal/surgery.py index 62ca7f3..63ebfd4 100644 --- a/element_animal/surgery.py +++ b/element_animal/surgery.py @@ -133,14 +133,14 @@ class Implantation(dj.Manual): Attributes: Subject (foreign key): Subject primary key. - implant_date (datetime): ID of brain location. + implant_date (datetime): Date and time of implantation surgery. ImplantationType (foreign key): ImplantationType primary key. region_acronym ( projected attribute, varchar(32) ): Brain region shorthand from BrainRegion. hemisphere ( projected attribute, varchar(8) ): Brain region hemisphere from Hemisphere. user ( projected attribute, varchar(32) ): User who performed the surgery. - implant_comment ( varchar(1024) ): Comments about the implant. + implant_comment ( varchar(1024), optional ): Comments about the implant. """ definition = """ diff --git a/requirements.txt b/requirements.txt index 4f7998f..db7fa11 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ datajoint>=0.13 -element-lab +element-lab>=0.3.0 pynwb>=1.4.0 From bf0b25c6fc222f466ffb3f87234c75bd1b3119f7 Mon Sep 17 00:00:00 2001 From: kushalbakshi Date: Thu, 24 Aug 2023 13:02:03 -0500 Subject: [PATCH 08/13] Add `lab.Device` to schema diagram --- images/injection_diagram.svg | 238 +++++++++++++++++------------------ 1 file changed, 119 insertions(+), 119 deletions(-) diff --git a/images/injection_diagram.svg b/images/injection_diagram.svg index 1e11c50..2ea9c25 100644 --- a/images/injection_diagram.svg +++ b/images/injection_diagram.svg @@ -1,187 +1,187 @@ - + %3 - - -28 + + +19 + +19 + + +surgery.Implantation + + +surgery.Implantation + + + + +19->surgery.Implantation + + + +23 -28 +23 -surgery.Implantation.Coordinate - +surgery.Implantation.Coordinate + surgery.Implantation.Coordinate - -28->surgery.Implantation.Coordinate + +23->surgery.Implantation.Coordinate - -24 + +18 -24 - - -surgery.Implantation - - -surgery.Implantation - +18 + +18->surgery.Implantation + - -24->surgery.Implantation - - - -29 + +21 -29 +21 - -29->surgery.Implantation.Coordinate + +21->surgery.Implantation.Coordinate - -25 - -25 - - -25->surgery.Implantation - - - -27 + +22 -27 +22 - -27->surgery.Implantation.Coordinate + +22->surgery.Implantation.Coordinate - -injection.VirusSerotype - - -injection.VirusSerotype + +lab.Device + + +lab.Device - -injection.VirusName - - -injection.VirusName + +injection.InjectionProtocol + + +injection.InjectionProtocol - -injection.VirusSerotype->injection.VirusName - - - -injection.MicroInjectionDevice - - -injection.MicroInjectionDevice + +lab.Device->injection.InjectionProtocol + + + +injection.VirusName + + +injection.VirusName - -injection.InjectionProtocol - - -injection.InjectionProtocol + +injection.Injection + + +injection.Injection - -injection.MicroInjectionDevice->injection.InjectionProtocol - + +injection.VirusName->injection.Injection + + + +surgery.Implantation->surgery.Implantation.Coordinate + + + +surgery.Implantation->injection.Injection + -surgery.Hemisphere - - -surgery.Hemisphere +surgery.Hemisphere + + +surgery.Hemisphere - -surgery.Hemisphere->25 - + +surgery.Hemisphere->19 + -surgery.BrainRegion - - -surgery.BrainRegion +surgery.BrainRegion + + +surgery.BrainRegion - -surgery.BrainRegion->24 - + +surgery.BrainRegion->18 + - -surgery.ImplantationType - - -surgery.ImplantationType + +injection.VirusSerotype + + +injection.VirusSerotype - -surgery.ImplantationType->surgery.Implantation - + +injection.VirusSerotype->injection.VirusName + - -injection.Injection - - -injection.Injection - + +injection.InjectionProtocol->injection.Injection + + +surgery.ImplantationType + + +surgery.ImplantationType + - -injection.VirusName->injection.Injection - - -injection.InjectionProtocol->injection.Injection - + +surgery.ImplantationType->surgery.Implantation + -surgery.CoordinateReference - +surgery.CoordinateReference + surgery.CoordinateReference - -surgery.CoordinateReference->28 + +surgery.CoordinateReference->23 - -surgery.CoordinateReference->29 + +surgery.CoordinateReference->21 - -surgery.CoordinateReference->27 + +surgery.CoordinateReference->22 - -surgery.Implantation->surgery.Implantation.Coordinate - - - -surgery.Implantation->injection.Injection - - \ No newline at end of file From f771cfebdfe3fbab8bda946c4bbfa21d01fd402a Mon Sep 17 00:00:00 2001 From: kushalbakshi Date: Mon, 11 Sep 2023 17:30:51 -0500 Subject: [PATCH 09/13] Update `Device` as a `linking_module` into the element --- CHANGELOG.md | 1 + element_animal/genotyping.py | 17 +++++++++-------- element_animal/injection.py | 15 +++++++-------- element_animal/subject.py | 8 ++++---- element_animal/surgery.py | 8 ++++---- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2abfe8..9a2e994 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and ## [0.2.0] - 2023-08-23 + Add - `injection` schema ++ Update - docstrings, `linking_module` within each `activate` function ## [0.1.8] - 2023-06-20 diff --git a/element_animal/genotyping.py b/element_animal/genotyping.py index 1bb0820..8bb07bf 100644 --- a/element_animal/genotyping.py +++ b/element_animal/genotyping.py @@ -6,14 +6,15 @@ from . import subject schema = dj.schema() +_linking_module = None def activate( - genotyping_schema_name, - subject_schema_name=None, - create_schema=True, - create_tables=True, - linking_module=None, + genotyping_schema_name: str, + subject_schema_name: str = None, + create_schema: bool = True, + create_tables: bool = True, + linking_module: str = None, ): """Activate this schema. @@ -26,8 +27,8 @@ def activate( database if it does not yet exist. create_tables (bool, optional): when True (default), create tables in the database if they do not yet exist. - linking_module (bool, optional): a module name or a module containing the - required dependencies to activate the `subject` element: + linking_module (str): A module name or a module containing the required + dependencies to activate the `genotyping` module. Dependencies: Upstream tables: @@ -56,7 +57,7 @@ def activate( genotyping_schema_name, create_schema=create_schema, create_tables=create_tables, - add_objects=linking_module.__dict__, + add_objects=_linking_module.__dict__, ) diff --git a/element_animal/injection.py b/element_animal/injection.py index c744ab9..9ebeeca 100644 --- a/element_animal/injection.py +++ b/element_animal/injection.py @@ -3,7 +3,6 @@ import datajoint as dj -from element_lab import lab from . import surgery schema = dj.Schema() @@ -17,7 +16,7 @@ def activate( *, create_schema: bool = True, create_tables: bool = True, - linking_module: bool = True, + linking_module: str = None, ): """Activate this schema. @@ -28,12 +27,12 @@ def activate( 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: + linking_module (str): A module name or a module containing the required + dependencies to activate the `injection` module. Dependencies: Upstream tables: - User: the who conducted a particular surgery/implantation + Device: table from `element-lab`. """ if isinstance(linking_module, str): @@ -54,13 +53,13 @@ def activate( surgery_schema_name, create_schema=create_schema, create_tables=create_tables, - linking_module=linking_module, + linking_module=_linking_module, ) schema.activate( injection_schema_name, create_schema=create_schema, create_tables=create_tables, - add_objects=linking_module.__dict__, + add_objects=_linking_module.__dict__, ) @@ -111,7 +110,7 @@ class InjectionProtocol(dj.Manual): definition = """ protocol_id : int --- - -> lab.Device + -> Device volume_per_pulse : float injection_rate : float interpulse_delay : float diff --git a/element_animal/subject.py b/element_animal/subject.py index d258df3..7eca71b 100644 --- a/element_animal/subject.py +++ b/element_animal/subject.py @@ -11,7 +11,7 @@ def activate( *, create_schema: bool = True, create_tables: bool = True, - linking_module: bool = True, + linking_module: str = None, ): """Activate this schema. @@ -22,8 +22,8 @@ def activate( 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: + linking_module (str): A module name or a module containing the required + dependencies to activate the `subject` module. Dependencies: Upstream tables: @@ -49,7 +49,7 @@ def activate( schema_name, create_schema=create_schema, create_tables=create_tables, - add_objects=linking_module.__dict__, + add_objects=_linking_module.__dict__, ) diff --git a/element_animal/surgery.py b/element_animal/surgery.py index 63ebfd4..48b0644 100644 --- a/element_animal/surgery.py +++ b/element_animal/surgery.py @@ -16,7 +16,7 @@ def activate( *, create_schema: bool = True, create_tables: bool = True, - linking_module: bool = True, + linking_module: str = None, ): """Activate this schema. @@ -27,8 +27,8 @@ def activate( 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: + linking_module (str): A module name or a module containing the required + dependencies to activate the `surgery` module. Dependencies: Upstream tables: @@ -54,7 +54,7 @@ def activate( surgery_schema_name, create_schema=create_schema, create_tables=create_tables, - add_objects=linking_module.__dict__, + add_objects=_linking_module.__dict__, ) From 9eec2c01cf0d6f1450a5cb94311fc7a0a51f599c Mon Sep 17 00:00:00 2001 From: Kushal Bakshi <52367253+kushalbakshi@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:01:18 -0500 Subject: [PATCH 10/13] Update requirements.txt Co-authored-by: Kabilar Gunalan --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index db7fa11..41a088b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ datajoint>=0.13 -element-lab>=0.3.0 pynwb>=1.4.0 From 5ef30a1bf708afaede433188a8d696efafe054e1 Mon Sep 17 00:00:00 2001 From: Kushal Bakshi <52367253+kushalbakshi@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:01:35 -0500 Subject: [PATCH 11/13] Update element_animal/injection.py Co-authored-by: Kabilar Gunalan --- element_animal/injection.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/element_animal/injection.py b/element_animal/injection.py index 9ebeeca..ee73184 100644 --- a/element_animal/injection.py +++ b/element_animal/injection.py @@ -44,11 +44,6 @@ def activate( global _linking_module _linking_module = linking_module - lab.activate( - lab_schema_name, - create_schema=create_schema, - create_tables=create_tables, - ) surgery.activate( surgery_schema_name, create_schema=create_schema, From d8d05577f040f966fd1f58cca37a5240db70caad Mon Sep 17 00:00:00 2001 From: kushalbakshi Date: Tue, 3 Oct 2023 10:02:03 -0500 Subject: [PATCH 12/13] Remove incorrect `linking_module` type --- element_animal/genotyping.py | 2 +- element_animal/injection.py | 2 +- element_animal/subject.py | 2 +- element_animal/surgery.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/element_animal/genotyping.py b/element_animal/genotyping.py index 8bb07bf..cd42346 100644 --- a/element_animal/genotyping.py +++ b/element_animal/genotyping.py @@ -14,7 +14,7 @@ def activate( subject_schema_name: str = None, create_schema: bool = True, create_tables: bool = True, - linking_module: str = None, + linking_module = None, ): """Activate this schema. diff --git a/element_animal/injection.py b/element_animal/injection.py index ee73184..2e12bd4 100644 --- a/element_animal/injection.py +++ b/element_animal/injection.py @@ -16,7 +16,7 @@ def activate( *, create_schema: bool = True, create_tables: bool = True, - linking_module: str = None, + linking_module = None, ): """Activate this schema. diff --git a/element_animal/subject.py b/element_animal/subject.py index 7eca71b..61c3da3 100644 --- a/element_animal/subject.py +++ b/element_animal/subject.py @@ -11,7 +11,7 @@ def activate( *, create_schema: bool = True, create_tables: bool = True, - linking_module: str = None, + linking_module = None, ): """Activate this schema. diff --git a/element_animal/surgery.py b/element_animal/surgery.py index 48b0644..a08b7d5 100644 --- a/element_animal/surgery.py +++ b/element_animal/surgery.py @@ -16,7 +16,7 @@ def activate( *, create_schema: bool = True, create_tables: bool = True, - linking_module: str = None, + linking_module = None, ): """Activate this schema. From 400c93a398c77c7eb6cc38ddf6ee44df131f6613 Mon Sep 17 00:00:00 2001 From: kushalbakshi Date: Tue, 3 Oct 2023 10:07:56 -0500 Subject: [PATCH 13/13] Black formatting --- element_animal/genotyping.py | 2 +- element_animal/injection.py | 2 +- element_animal/subject.py | 2 +- element_animal/surgery.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/element_animal/genotyping.py b/element_animal/genotyping.py index cd42346..45fabce 100644 --- a/element_animal/genotyping.py +++ b/element_animal/genotyping.py @@ -14,7 +14,7 @@ def activate( subject_schema_name: str = None, create_schema: bool = True, create_tables: bool = True, - linking_module = None, + linking_module=None, ): """Activate this schema. diff --git a/element_animal/injection.py b/element_animal/injection.py index 2e12bd4..af9ab0f 100644 --- a/element_animal/injection.py +++ b/element_animal/injection.py @@ -16,7 +16,7 @@ def activate( *, create_schema: bool = True, create_tables: bool = True, - linking_module = None, + linking_module=None, ): """Activate this schema. diff --git a/element_animal/subject.py b/element_animal/subject.py index 61c3da3..35034ee 100644 --- a/element_animal/subject.py +++ b/element_animal/subject.py @@ -11,7 +11,7 @@ def activate( *, create_schema: bool = True, create_tables: bool = True, - linking_module = None, + linking_module=None, ): """Activate this schema. diff --git a/element_animal/surgery.py b/element_animal/surgery.py index a08b7d5..27ad3d3 100644 --- a/element_animal/surgery.py +++ b/element_animal/surgery.py @@ -16,7 +16,7 @@ def activate( *, create_schema: bool = True, create_tables: bool = True, - linking_module = None, + linking_module=None, ): """Activate this schema.