* class OBOEntry, ajout de l'attribut stanza self["stanza"]
* class OBOTerm: * ajout de la propriété stanza + sa méthode getter * test obsolete: suppression de la contrainte 'is_a'... slot pas obligatoire pour un term obsolete * methode getReplaceBy renommée en getReplacedBy
This commit is contained in:
@ -526,6 +526,8 @@ class OBOEntry(dict):
|
||||
if not self.isHeader:
|
||||
self.stanzaName = lines[0].strip()[1:-1]
|
||||
lines=lines[1:]
|
||||
self["stanza"] = [stanza.strip()]
|
||||
|
||||
## whatever the stanza is.
|
||||
for line in lines:
|
||||
## each line is a couple : tag / value
|
||||
@ -557,6 +559,7 @@ class OBOTerm(OBOEntry):
|
||||
OBOEntry.__init__(self, stanza)
|
||||
|
||||
assert self.stanzaName=='Term'
|
||||
assert 'stanza' in self
|
||||
assert 'id' in self and len(self['id'])==1,"An OBOTerm must have an id"
|
||||
assert 'name' in self and len(self['name'])==1,"An OBOTerm must have a name"
|
||||
assert 'namespace' not in self or len(self['namespace'])==1, "Only one namespace is allowed for an OBO term"
|
||||
@ -568,7 +571,7 @@ class OBOTerm(OBOEntry):
|
||||
assert 'intersection_of' not in self or len(self['intersection_of'])>=2,"Only one intersection relationship is allowed for an OBO term"
|
||||
|
||||
if self._isObsolete():
|
||||
assert 'is_a' not in self
|
||||
#assert 'is_a' not in self
|
||||
assert 'relationship' not in self
|
||||
assert 'inverse_of' not in self
|
||||
assert 'disjoint_from' not in self
|
||||
@ -578,6 +581,9 @@ class OBOTerm(OBOEntry):
|
||||
assert 'replaced_by' not in self or self._isObsolete()
|
||||
assert 'consider' not in self or self._isObsolete()
|
||||
|
||||
def _getStanza(self):
|
||||
return self['stanza'][0]
|
||||
|
||||
## make-up functions.
|
||||
def _getDefinition(self):
|
||||
if 'def' in self:
|
||||
@ -641,7 +647,7 @@ class OBOTerm(OBOEntry):
|
||||
def _isObsolete(self):
|
||||
return 'is_obsolete' in self and str(self['is_obsolete'][0])=='true'
|
||||
|
||||
def _getReplaceBy(self):
|
||||
def _getReplacedBy(self):
|
||||
if 'replaced_by' in self:
|
||||
return list(set(self.get('replaced_by',None)))
|
||||
return None
|
||||
@ -652,6 +658,7 @@ class OBOTerm(OBOEntry):
|
||||
return None
|
||||
|
||||
## automatically make-up !
|
||||
stanza = property(_getStanza,None,None)
|
||||
definition = property(_getDefinition,None,None)
|
||||
id = property(_getId,None,None)
|
||||
namespace = property(_getNamespace,None,None)
|
||||
@ -667,7 +674,7 @@ class OBOTerm(OBOEntry):
|
||||
intersection_of = property(_getIntersection,None,None)
|
||||
disjoint_from = property(_getDisjonction,None,None)
|
||||
is_obsolete = property(_isObsolete,None,None)
|
||||
replaced_by = property(_getReplaceBy,None,None)
|
||||
replaced_by = property(_getReplacedBy,None,None)
|
||||
consider = property(_getConsider,None,None)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user