Checking empty descriptions

In this example, we use fastobo to create a small validation script which will report empty definitions in an OBO file. We also use requests in order to connect to the OBO library.

import fastobo
import requests

fastobo.load takes a file-handle, which can be accessed using the raw property of the Response object returned by requests.get:

res = requests.get("", stream=True)
doc = fastobo.load(res.raw)


Checking for definitions in entity frames is straightforward: all definition clauses have a definition property that returns the textual definition of the entity. We can use duck-typing here to check for empty definitions:

for frame in doc:
    for clause in frame:
            if not clause.definition:
                print("Empty definition of",
        except AttributeError: