Abstract Base Classes¶
Frame¶
AbstractFrame
¶
- 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
FormatVersionClause
and aOntologyClause
for compatibility purposes), followed by a various number of entity frames.- __new__(**kwargs)¶
AbstractEntityFrame
¶
- 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
id
property in any concrete subclass.- __new__(**kwargs)¶
- id¶
the identifier of the described entity.
- Type:
Ident
Clauses¶
AbstractClause
¶
- 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_tag
andraw_value
methods, 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."']}
- __new__(**kwargs)¶
- raw_tag()¶
Get the raw tag of the header clause.
- Returns:
str
– the header clause value 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 header clause.
- Returns:
str
– the header 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'