In the web-application interface we 'log in' to gain access to our personal data. When using the web-service API we speak of authentication as the process whereby your requests are mapped to a particular user account.
The recommended manner of authentication is through the use of API tokens; you can get yours by visiting the appropriate section of the web-application (http://www.flymine.org/query/mymine?tab=api). The token is a long string which is unique across the mine - since its use is equivalent to your password, remember to keep it safe.
You can authenticate with a mine as follows:
If the URL for the mine is incorrect, or the token is, an error will be thrown.
While it is also possible to use your username and password to authenticate with the webservice, this is strongly discouraged. This is due to the security implications of transmitting your password, not to mention storing it on disk, in order to use it in code.
One of the main reasons to use the webservices is to read and manipulate the data important to you, and lists are the main way to manage this.
To read the set of lists you have access to:
To calculate the enrichment results for a given list:
Creating a list from a file with identifiers in it is as straight-forward as naming that file. This is done like so:
If the identifiers are already in memory, in anything iterable, then that can be used instead. In the following case, a string will be built up by reading the results of a database query.
Lists can be combined with standard set operations, which are overloaded in the languages that support such features:
We should have enough pieces now to put together a simple workflow that demonstrates the kinds of operations we want to put together and how they may be combined.
Try and develop a script which will:
- Read all the files in a directory.
- Create a list for each one from their contents, named after the file.
- Find the pathways for which the genes in each list are enriched above a certain threshold.
- Create a list of those pathways.
One can query for features in a region as follows:
The items can be saved in a list and then used in any other query.
The interface for creating queries borrows syntax and terminology from other DB query libraries.