Skip to content

Commit

Permalink
Add references attribute to various classes
Browse files Browse the repository at this point in the history
  • Loading branch information
YinHoon committed Sep 13, 2018
2 parents 653da7c + 95b06d8 commit 27fb419
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
5 changes: 3 additions & 2 deletions wc_kb/__init__.py
Expand Up @@ -14,9 +14,9 @@
PolymerSpeciesType,
ComplexSpeciesType,
DnaSpeciesType,
RnaType,
RnaType,
PolymerLocus,
GeneType,
GeneType,
Reaction,
Species,
SpeciesCoefficient,
Expand All @@ -34,6 +34,7 @@
RateLawEquation,
Reference,
DatabaseReference)

from .prokaryote_schema import (RnaSpeciesType,
ProteinSpeciesType,
GeneLocus,
Expand Down
13 changes: 7 additions & 6 deletions wc_kb/core.py
Expand Up @@ -480,11 +480,12 @@ def deserialize(self, value, objects, decoded=None):

spec_type_id = spec_coeff_match[5]

try:
try:
if spec_type_id in objects[ProteinSpeciesType]:
spec_type = objects[ProteinSpeciesType][spec_type_id]
elif spec_type_id in objects[RnaSpeciesType]:
spec_type = objects[RnaSpeciesType][spec_type_id]

elif spec_type_id in objects[ComplexSpeciesType]:
spec_type = objects[ComplexSpeciesType][spec_type_id]
elif spec_type_id in objects[DnaSpeciesType]:
Expand Down Expand Up @@ -728,8 +729,8 @@ class KnowledgeBaseObject(obj_model.Model):
"""
id = obj_model.SlugAttribute(primary=True, unique=True)
name = obj_model.StringAttribute()
comments = obj_model.StringAttribute()
comments = obj_model.StringAttribute()


class KnowledgeBase(KnowledgeBaseObject):
""" A knowledge base
Expand Down Expand Up @@ -768,7 +769,7 @@ class Cell(KnowledgeBaseObject):
knowledge_base (:obj:`KnowledgeBase`): knowledge base
taxon (:obj:`int`): NCBI taxon identifier
Related attributes:
Related attributes:
compartments (:obj:`list` of :obj:`Compartment`): compartments
species_types (:obj:`list` of :obj:`SpeciesType`): species types
observables (:obj:'list' or :obj: 'Observable') : observables
Expand All @@ -782,7 +783,7 @@ class Cell(KnowledgeBaseObject):
class Meta(obj_model.Model.Meta):
attribute_order = ('id', 'name', 'taxon', 'comments')
tabular_orientation = obj_model.TabularOrientation.column


class Compartment(KnowledgeBaseObject):
""" Knowledge of a subcellular compartment
Expand All @@ -791,7 +792,7 @@ class Compartment(KnowledgeBaseObject):
cell (:obj:`Cell`): cell
volumetric_fraction (:obj:`float`): average volumetric fraction relative to the cell volume
references (:obj:`list` of :obj:`Reference`): references
Related attributes:
reaction_participants (:obj:`list` of :obj:`ReactionParticipant`): reaction participants
"""
Expand Down
12 changes: 6 additions & 6 deletions wc_kb/io.py
Expand Up @@ -54,7 +54,7 @@ def run(self, knowledge_base, core_path, seq_path, set_repo_metadata_from_path=T
knowledge_base (:obj:`core.KnowledgeBase`): knowledge base
core_path (:obj:`str`): path to save core knowledge base
seq_path (:obj:`str`): path to save genome sequence
set_repo_metadata_from_path (:obj:`bool`, optional): if :obj:`True`, set the Git repository metadata (URL,
set_repo_metadata_from_path (:obj:`bool`, optional): if :obj:`True`, set the Git repository metadata (URL,
branch, revision) for the knowledge base from the parent directory of :obj:`core_path`
Raises:
Expand Down Expand Up @@ -119,7 +119,7 @@ def run(self, knowledge_base, core_path, seq_path, set_repo_metadata_from_path=T

@classmethod
def validate_implicit_relationships(cls):
""" Check that relationships to :obj:`core.KnowledgeBase` and :obj:`core.Cell` do not need to be explicitly written to
""" Check that relationships to :obj:`core.KnowledgeBase` and :obj:`core.Cell` do not need to be explicitly written to
workbooks because they can be inferred by :obj:`Reader.run`
Raises:
Expand Down Expand Up @@ -150,13 +150,13 @@ def validate_implicit_relationships(cls):
class Reader(object):
""" Read knowledge base from file(s) """

@wc_utils.cache.memoize(filename_args=[1, 2])
#@wc_utils.cache.memoize(filename_args=[1, 2])
def run(self, core_path, seq_path, strict=True):
""" Read knowledge base from file(s)
Args:
core_path (:obj:`str`): path to core knowledge base
seq_path (:obj:`str`): path to genome sequence
seq_path (:obj:`str`): path to genome sequence
strict (:obj:`bool`, optional): if :obj:`True`, validate that the the model file(s) strictly follow the
:obj:`obj_model` serialization format:
Expand All @@ -171,7 +171,7 @@ def run(self, core_path, seq_path, strict=True):
:obj:`core.KnowledgeBase`: knowledge base
Raises:
:obj:`ValueError`: if :obj:`core_path`
:obj:`ValueError`: if :obj:`core_path`
* Defines multiple knowledge bases or cells
* Represents objects that cannot be linked to a knowledge base and/or cell
Expand Down Expand Up @@ -284,7 +284,7 @@ def create_template(core_path, seq_path, set_repo_metadata_from_path=True):
Args:
core_path (:obj:`str`): path to save temploate of core knowledge base
seq_path (:obj:`str`): path to save genome sequence
set_repo_metadata_from_path (:obj:`bool`, optional): if :obj:`True`, set the Git repository metadata (URL,
set_repo_metadata_from_path (:obj:`bool`, optional): if :obj:`True`, set the Git repository metadata (URL,
branch, revision) for the knowledge base from the parent directory of :obj:`core_path`
"""
kb = core.KnowledgeBase(
Expand Down
2 changes: 1 addition & 1 deletion wc_kb/prokaryote_schema.py
Expand Up @@ -294,4 +294,4 @@ class GeneLocus(schema_core.PolymerLocus):
class Meta(obj_model.Model.Meta):
attribute_order = ('id', 'polymer', 'name', 'symbol',
'type', 'strand', 'start', 'end', 'comments', 'references')

0 comments on commit 27fb419

Please sign in to comment.