Skip to content

Commit

Permalink
Add attributes to RegulatoryModule class to cover available data
Browse files Browse the repository at this point in the history
  • Loading branch information
YinHoon committed Dec 27, 2018
1 parent 84f6edc commit ef387b2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 15 deletions.
Binary file modified tests/fixtures/eukaryote_core.xlsx
Binary file not shown.
29 changes: 23 additions & 6 deletions tests/test_eukaryote_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,29 @@ def test_constructor(self):
promoter = eukaryote_schema.RegulatoryElementLocus(polymer=dna1, start=6, end=8)
enhancer = eukaryote_schema.RegulatoryElementLocus(polymer=dna1, start=2, end=4)

tf = eukaryote_schema.ProteinSpeciesType(id='tf')

reg_module1 = eukaryote_schema.RegulatoryModule(gene=gene1,
regulatory_elements=[promoter, enhancer])
reg_module2 = eukaryote_schema.RegulatoryModule(gene=gene2,
regulatory_elements=[enhancer])
regulatory_element=promoter, binding_factor=tf,
type=eukaryote_schema.RegulationType.proximal,
direction=eukaryote_schema.RegulatoryDirection.positive)
reg_module2 = eukaryote_schema.RegulatoryModule(gene=gene1,
regulatory_element=enhancer, binding_factor=tf,
type=eukaryote_schema.RegulationType.distal,
direction=eukaryote_schema.RegulatoryDirection.negative)
reg_module3 = eukaryote_schema.RegulatoryModule(id='rm3', name='reg_module3',
gene=gene2, regulatory_element=enhancer)

self.assertEqual(reg_module1.gene, gene1)
self.assertEqual(reg_module1.regulatory_elements, [promoter, enhancer])
self.assertEqual(reg_module2.gene, gene2)
self.assertEqual(reg_module2.regulatory_elements, [enhancer])
self.assertEqual(reg_module1.regulatory_element, promoter)
self.assertEqual(reg_module1.binding_factor, tf)
self.assertEqual(reg_module1.type.value, 1)
self.assertEqual(reg_module1.direction.value, 1)
self.assertEqual(reg_module2.gene, gene1)
self.assertEqual(reg_module2.regulatory_element, enhancer)
self.assertEqual(reg_module2.binding_factor, tf)
self.assertEqual(reg_module2.type.value, 2)
self.assertEqual(reg_module2.direction.value, -1)
self.assertEqual(reg_module3.id, 'rm3')
self.assertEqual(reg_module3.name, 'reg_module3')
self.assertEqual(set([i.gene for i in enhancer.regulatory_modules]), set([gene1, gene2]))
43 changes: 34 additions & 9 deletions wc_kb/eukaryote_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,26 @@ class RegulatoryElementType(enum.Enum):


class ActivityLevel(enum.Enum):
""" Activity level of regulatory element"""
active = 1
poised = 2
repressed = 3
inactive = 4
na = 5


class RegulationType(enum.Enum):
""" Type of regulation between a regulatory element and a gene """
proximal = 1
distal = 2


class RegulatoryDirection(enum.Enum):
""" The direction of regulation """
positive = 1
negative = -1


#####################
#####################
# Locus types
Expand All @@ -50,7 +63,7 @@ class GeneLocus(core.PolymerLocus):
Related attributes:
rna (:obj:`list` of :obj:`PreRnaSpeciesType`): rna
regulatory_modules (:obj:`RegulatoryModule`): regulatory_modules
regulatory_modules (:obj:`list` of `RegulatoryModule`): regulatory_modules
"""
symbol = obj_model.StringAttribute()
type = obj_model.EnumAttribute(core.GeneType)
Expand Down Expand Up @@ -108,30 +121,41 @@ class RegulatoryElementLocus(core.PolymerLocus):
motif_features = obj_model.ManyToManyAttribute('ProteinSpeciesType', related_name='regulatory_elements')

class Meta(obj_model.Model.Meta):
attribute_order = ('id', 'polymer', 'name', 'type', 'activity',
attribute_order = ('id', 'polymer', 'name', 'type', 'activity', 'strand',
'start', 'end', 'bound_start', 'bound_end', 'motif_features',
'comments', 'references', 'database_references')


class RegulatoryModule(obj_model.Model):
""" Knowledge about regulatory modules
Attributes:
Attributes:
id (:obj:`str`): identifier
name (:obj:`str`): name
gene (:obj:`GeneLocus`): gene
regulatory_elements (:obj:`list` of :obj:`RegulatoryElementLocus`): regulatory elements
regulatory_element (:obj:`RegulatoryElementLocus`): regulatory element
binding_factor (:obj:`ProteinSpeciesType`): binding factor
type (:obj:`RegulationType`): type of regulation (proximal or distal)
direction (:obj:`RegulatoryDirection`): direction of regulation
comments (:obj:`str`): comments
references (:obj:`list` of :obj:`Reference`): references
database_references (:obj:`list` of :obj:`DatabaseReference`): database references
"""
gene = obj_model.OneToOneAttribute(GeneLocus, related_name='regulatory_modules')
regulatory_elements = obj_model.ManyToManyAttribute(
id = obj_model.SlugAttribute(primary=True, unique=True)
name = obj_model.StringAttribute()
gene = obj_model.ManyToOneAttribute(GeneLocus, related_name='regulatory_modules')
regulatory_element = obj_model.ManyToOneAttribute(
RegulatoryElementLocus, related_name='regulatory_modules')
binding_factor = obj_model.ManyToOneAttribute('ProteinSpeciesType', related_name='regulatory_modules')
type = obj_model.EnumAttribute(RegulationType)
direction = obj_model.EnumAttribute(RegulatoryDirection)
comments = obj_model.LongStringAttribute()
references = obj_model.ManyToManyAttribute(core.Reference, related_name='regulatory_modules')
database_references = core.DatabaseReferenceAttribute(related_name='regulatory_modules')

class Meta(obj_model.Model.Meta):
attribute_order = ('gene', 'regulatory_elements', 'comments', 'references', 'database_references')
attribute_order = ('id', 'name', 'gene', 'regulatory_element', 'binding_factor', 'type',
'direction', 'comments', 'references', 'database_references')


#####################
Expand Down Expand Up @@ -314,10 +338,11 @@ class ProteinSpeciesType(core.PolymerSpeciesType):
Attributes:
uniprot (:obj:`str`): uniprot id
transcript (:obj:`TranscriptSpeciesType`): transcript
coding_regions (:obj:1list` of :obj:`CdsLocus`): CDS Loci
coding_regions (:obj:`list` of :obj:`CdsLocus`): CDS Loci
Related attributes:
regulatory_elements (:obj:`RegulatoryElementLocus`): protein binding sites
regulatory_elements (:obj:`list` of `RegulatoryElementLocus`): potential binding sites
regulatory_modules (:obj:`list` of `RegulatoryModule`): regulatory DNA binding sites
"""

uniprot = obj_model.StringAttribute()
Expand Down

0 comments on commit ef387b2

Please sign in to comment.