This page contains the API documentation for becas.py, the single module packaged by becas-python that allows you to use the becas API programmatically from your Python modules.
For instructions on how to use the becas API from a command-line tool, read the Command-line interface documentation.
Comprehensive documentation about the becas API is available at its dedicated page.
You are required to authenticate in order to use the becas API. This can be done through the email and tool parameters, which you should set before invoking any of the annotation functions:
import becas
becas.email = 'you@example.com' # required
becas.tool = 'your-tool-name' # optional, defaults to 'becas-python'
You can set these parameters from your modules to configure becas-python behaviour.
Seconds to wait before timing out a request
Whether to use HTTPS or plain HTTP
These constants are provided for your reference.
Semantic groups usable as keys of a groups dict
Output formats available for the export_text() function
The following API client functions are available. Read more about the available API methods in the becas API calls reference.
Annotate text with biomedical concepts.
Parameters: |
|
---|---|
Returns: | dict with annotation results. |
Usage:
>>> import becas
>>> becas.email = 'you@example.com'
>>> results = becas.annotate_text('BRCA1 is a human caretaker gene.')
Export text annotated with biomedical concepts in JSON, XML, A1 or CONLL.
Parameters: |
|
---|---|
Returns: | unicode string with annotation results. |
Usage:
>>> import becas
>>> becas.email = 'you@example.com'
>>> text = 'BRCA1 is a human caretaker gene.'
>>> json_results = becas.export_text(text, 'json')
>>> iexml_results = becas.export_text(text, 'xml')
>>> a1_results = becas.export_text(text, 'a1')
>>> conll_results = becas.export_text(text, 'conll')
Annotate PubMed publication with biomedical concepts.
Parameters: |
|
---|---|
Returns: | dict with annotation results. |
Usage:
>>> import becas
>>> becas.email = 'you@example.com'
>>> results = becas.annotate_publication(23225384)
Export PubMed publication as MEDLINE IeXML annotated with biomedical concepts.
Parameters: |
|
---|---|
Returns: | unicode string with IeXML annotation results. |
Usage:
>>> import becas
>>> becas.email = 'you@example.com'
>>> results = becas.export_publication(23225384)
If something goes wrong, one of these exceptions will be raised.
Bases: exceptions.RuntimeError
There was an ambiguous exception that occurred while handling your request.
Bases: becas.BecasException
You need to authenticate your requests with your email and optionally a tool name.
As an example, if your email address is you@example.com, you can specify it as follows:
>>> import becas
>>> becas.email = 'you@example.com'
In case of excessive usage of the becas API, UA.PT Bioinformatics will attempt to contact a user at the email address provided before blocking access to the services.
Bases: becas.BecasException, exceptions.ValueError
You provided an invalid groups dictionary.
Bases: becas.BecasException, exceptions.ValueError
You provided an invalid export format.
Bases: becas.BecasException, exceptions.ValueError
You provided too much text to annotate. Try again with less text.
Bases: becas.BecasException
You performed too many requests in a short amount of time. Wait wait seconds before trying again.
Bases: becas.BecasException, exceptions.ValueError
The publication you requested was not found in PubMed.
Bases: becas.BecasException
The annotation service is currently unavailable.
Bases: becas.BecasException
A Connection error occurred.
Bases: becas.ConnectionError
An SSL error occurred.
Bases: becas.BecasException
The request timed out.
This documentation was automatically generated from the source code using sphinx.
becas.py is a rather small module. You can read the annotated source at GitHub.