Skip to content

Commit

Permalink
added table for Species
Browse files Browse the repository at this point in the history
  • Loading branch information
Thinh Nguyen committed Nov 28, 2023
1 parent 1775d38 commit 72bf262
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
3 changes: 2 additions & 1 deletion element_animal/export/nwb.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def subject_to_nwb(session_key: dict):
pynwb.file.Subject: NWB object
"""
subject_query = subject.Subject & session_key
subject_query = subject_query.join(subject.Subject.Species, left=True)
subject_query = subject_query.join(subject.Subject.Line, left=True)
subject_query = subject_query.join(subject.Subject.Strain, left=True)
subject_query = subject_query.join(subject.Subject.Source, left=True)
Expand All @@ -29,7 +30,7 @@ def subject_to_nwb(session_key: dict):
datetime.strptime("00:00:00", "%H:%M:%S").time(),
),
description=json.dumps(subject_info, default=str),
species=str((subject.Line & subject_query).fetch("species")),
species=str((subject.Species & subject_query).fetch("species")),
genotype=" x ".join(
(subject.Line.Allele * subject.Subject.Line & subject_query).fetch("allele")
),
Expand Down
29 changes: 27 additions & 2 deletions element_animal/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ def activate(
)


@schema
class Species(dj.Lookup):
"""Animal species
Attributes:
species ( varchar(64) ): Animal species, Latin name preferred for NWB export
"""

definition = """ # Animal species
species: varchar(64) # Animal species, Latin name preferred for NWB export
"""


@schema
class Strain(dj.Lookup):
"""Genetic strain of an animal. (e.g. C57Bl/6).
Expand Down Expand Up @@ -112,7 +125,6 @@ class Line(dj.Lookup):
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.
Expand All @@ -121,7 +133,6 @@ class Line(dj.Lookup):
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
Expand Down Expand Up @@ -188,6 +199,20 @@ class User(dj.Part):
-> User
"""

class Species(dj.Part):
"""Species of the subject.
Attributes:
Subject (foreign key): Subject key.
Species (foreign key): Species key.
"""

definition = """
-> master
---
-> Species
"""

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

0 comments on commit 72bf262

Please sign in to comment.