Abstract Base Classes#
Frame#
- class fastobo.abc.AbstractFrame(collections.abc.MutableSeq)#
An abstract OBO frame, storing a sequence of various clauses.
An OBO document contains a header frame (which may be empty, but should at least contain a
FormatVersionClauseand aOntologyClausefor compatibility purposes), followed by a various number of entity frames.
- class fastobo.abc.AbstractEntityFrame(AbstractFrame)#
An abstract entity frame, which clauses define an entity.
Entity frames define OBO entities, which can be classes (terms), relations (typedefs) and instances. All OBO entities have an identifier, which is supposedly unique, that can be accessed through the
idproperty in any concrete subclass.- id#
the identifier of the described entity.
- Type:
Ident
Clauses#
- class fastobo.abc.AbstractClause#
An abstract clause.
An OBO clause is a tag/value pair, with additional syntax requirements depending on the tag. The raw tag and raw value of an OBO clause can be accessed with the
raw_tagandraw_valuemethods, for instance to convert a frame into a Pythondict.Example
>>> d = {} >>> for clause in ms[1]: ... d.setdefault(clause.raw_tag(), []).append(clause.raw_value()) >>> pprint(d) {'def': ['"A reference number relevant to the sample under study."'], 'is_a': ['MS:1000548'], 'name': ['sample number'], 'xref': ['value-type:xsd\\:string "The allowed value-type for this CV term."']}
- raw_tag()#
Get the raw tag of the clause.
- Returns:
str– the clause tag as it was extracted from the OBO header, stripped from trailing qualifiers and comment.
Example
>>> clause = fastobo.header.OntologyClause("test") >>> clause.raw_tag() 'ontology' >>> str(clause) 'ontology: test'
- raw_value()#
Get the raw value of the clause.
- Returns:
str– the clause value as it was extracted from the OBO header, stripped from trailing qualifiers and comment.
Example
>>> dt = datetime.datetime(2019, 4, 29, 21, 52) >>> clause = fastobo.header.DateClause(dt) >>> clause.date datetime.datetime(2019, 4, 29, 21, 52) >>> clause.raw_value() '29:04:2019 21:52'
- class fastobo.abc.AbstractEntityClause(AbstractClause)#
An abstract entity clause.