Skip to content

Commit

Permalink
Modified observable deserialization to work with child SpeciesTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalshaikh42 committed Aug 8, 2018
1 parent 909c22a commit 842f83f
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions wc_kb/core.py
Expand Up @@ -474,11 +474,23 @@ def deserialize(self, value, objects, decoded=None):
spec_type_errors = []

spec_type_id = spec_coeff_match[5]
if spec_type_id in objects[SpeciesType]:
spec_type = objects[SpeciesType][spec_type_id]
else:
spec_type_errors.append(
'Undefined species type "{}"'.format(spec_type_id))

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]:
spec_type = objects[DnaSpeciesType][spec_type_id]
elif spec_type_id in objects[MetaboliteSpeciesType]:
spec_type = objects[MetaboliteSpeciesType][spec_type_id]
else:
spec_type_errors.append(
'Undefined species type "{}"'.format(spec_type_id))
except KeyError:
pass

compartment_id = spec_coeff_match[6]
if compartment_id in objects[Compartment]:
Expand Down Expand Up @@ -1096,7 +1108,7 @@ def get_len(self):
return abs(self.start - self.end) + 1


class Observable(KnowledgeBaseObject):
class Observable(six.with_metaclass(obj_model.abstract.AbstractModelMeta, KnowledgeBaseObject)):
"""Knowledge of an observable to include in a model
Attributes:
Expand Down

0 comments on commit 842f83f

Please sign in to comment.