Documentation and Help
Using the API
Besides our web service for searching, retrieving, and exporting data we also provide an API interface to, for example, automate workflows that require obtaining certain tRNA sequences. In order to keep our service responsive and fair, we limit API requests to 1 request per second per client. Note that repeatedly violating this limit might result in a temporary lock-out from the tRNAdb service. Please ensure your use of the API respects these limits (for example, via waiting/sleep after every request).
Querying the API
The API provides nearly equal search parameters as the Search form and can
be reached with POST request at https://www.tdb.bioinf.uni-leipzig.de/api.
A POST request with JSON content-type is expected. The following JSON contains all supported fields, and field types:
{
'database': <list, string>,
'organism': <list, string>,
'clade': <list, string>,
'ncbi_id': <string, integer, list>'
'amino_acid': <list, string>,
'anticodon': <list, string>,
'sequence': <dictionary {'0': <string>, '1': <string>, ..., '16': <string>}, string>,
'structure': <dictionary {'0': <string>, '1': <string>, ... , '16': <string>}, string>,
'reference': <string>,
'trna_id': <list, string>,
'id': <list, integer>
'sprinzl_id': <list, string>,
'page_size': <integer>,
'page_offset': <integer>
}
In particular, you need to pay attention to the 'page_offset' and 'page_size' parameters. If you do not specify these two, the API will always return the first (at most) 1000 matching entries. These two parameters are explained in more detail below
Query Parameters
| Field | Usage/Parameters | Example |
|---|---|---|
database |
restricts which datasource the tRNA should be retrieved from, i.e., nuclear tRNAs sequences (trna), nuclear tRNA RNA sequences (trna_rna), mitochondrial tRNA sequences (mttrna), and mitochondrial tRNA RNA sequences (mttrna_rna). Datasources can be supplied as a single string (single datasource) or as a list of strings (multiple datasources). |
'database': ['trna', 'mttrna'] matches nuclear tRNA sequences as well as mitochondrial tRNA sequences while no nuclear tRNA RNA sequences/mitochondrial tRNA RNA sequences are returned. |
organism |
matches species names, synonyms for species inluded. Species names can be either single species as a string, or a list of species strings. Either way, synonyms and partially matching organisms are matched, i.e. "canis" matches "Canis Latrans", "Canis Lupus", etc.. If you want precise matching, please use the ncbi_id together with NCBI Taxonomy IDs. | organism: ['Homo Nea'] matches tRNA belonging to "Homo Sapiens Neanderthalensis". |
clade |
matches species, family, order, ..., kingdom, etc.. Clades can be supplied as a string (matching a single clade) or as a list (matching multiple clades). Partial matches are also allowed. | clade: ['Hominidae'] returns tRNA for any species belonging to the family of great apes. |
ncbi_id |
restricts the search to tRNA belonging to the species with the supplied NCBI Taxonomy ID. Individual taxonomy ids (as string or integer) as well as a list of taxonomy IDs (as string or integer) can be queried. | clade: [8801, 9838] matches tRNA entries belonging to the african ostrich and the one-humped camel. |
amino_acid |
restricts the search to tRNAs for specific amino acids. You have to use the three-letter codes for amino acids (Ala, Arg, Asn, Asp, Cys, fMet, Gln, Glu, Gly, His, Ile, Ile2, iMet, Ini, Leu, Leu1, Leu2, Lys, Met, Phe, Pro, Pyr, Sec, Ser, Ser1, Ser2, Thr, Trp, Tyr, Val). A single amino acid (string) or multiple amino acids (list of strings) can be matched. | 'amino_acid':['Ala', 'Cys', 'His'] matches tRNA for Alanine, Cysteine, or Histidine. |
anticodon |
restricts the search to tRNAs with specific anticodons. When a single string is supplied, wobble bases are supported (in case only two nucleotides are provided). If a list is supplied, only exact matches are considered. | 'anticodon': 'AC' returns tRNAs with anticodons starting with "AC", e.g, "ACT, ACG, ACA, ...". 'anticodon': 'ACT' matches only tRNAs with the "ACT" anticodon. 'anticodon': ['ACG', 'ACA'] matches tRNAs with "ACG" or "ACA" as anticodon. |
sequence |
resticts the search to tRNA sequence motifs. If a string is supplied, only tRNAs matching the full motif are returned. If a dictionary is supplied, the corresponding regions of the tRNAs in the database are matched. See the region section below for an explaination of the dictionary region format. | 'sequence': {3: 'AGCT', 10: 'AAAT'} matches tRNAs which D-Stems contains motif "AGCT" and which V-Region contains motif "AAAT". |
structure |
restricts the search to certain tRNA structures. If a string is supplied, only tRNAs matching the full structure motif are returned. If a dictionary is supplied, the corresponding structure regions of the tRNAs in the database are matched. See the region section below for an explaination of the dictionary region format. "=" encode standard watson-crick basepairs (e.g., G-C, A-T/A-U), "*" encode wobble basepairs (e.g., G-U), and "." encode unpaired bases | 'structure': {3: '***', 5: '***'} matches tRNAs which D-Stem contain three consecutive wobble pairs on each side. 'structure': {3: '**=-'} returns tRNAs which D-stem contains two wobble pairs followed by a single watson-crick basepair and an unpaired nucleotide. |
reference |
restricts the search to tRNA from a certain source. The sources are the Reference/Database fields you can see on the individual results page. This can be genome accessions, data sources like gtRNAdb, or publication references. Note that partial matches are allowed. | 'reference': 'gtRNAdb' matches all entries included from gtRNAdb. 'reference': 'GCA_000786425.1' matches all entries that match the GenBank accession "GCA_000786425.1". |
trna_id |
restricts the search to tRNA with a specific ID. Either a single tRNAdb ID (string) or a list of multiple tRNAdb IDs can be supplied. | trna_id: ['tdbD00013523', 'tdbD00013524', 'tdbD00013525'] matches tRNA with (one of) the three supplied IDs. |
trna_id |
restricts the search to tRNA with a specific internal ID - this is the ID field on the results pages. Either a single ID (integer), or a list of IDs (list) can be supplied. Note that this ID is only unique in combination with the 'database' field. |
'id': [1, 2, 3] matches tRNA with (one of) the three supplied internal IDs. |
sprinzl_id |
restricts the search to tRNA with a specific SprinzlID (sourced originally from the Sprinzl tRNA database in 2009). Either a single SprinzlID (string), or a list of multiple SprinzlIDs can be supplied. | trna_id: ['DA3680'] matches the tRNA with SprinzlID 'DA3680'. |
page_size |
How many entries the API should return. This is limited at 1000. | 'page_size': 100, 'page_offset:0 returns the first 1-100 results matching the query. 'page_size': 100, 'page_offset:1 returns the 101st-200th entries matching the query. |
page_offset |
Which "offset" of matching entries is returned. Think of it like a book page containing <page_size> entries. The 0th page contains the first 1 to <page_size> entries, the 1st page contains the <page_size>+1 to 2 * <page_size> entries, etc. To retrieve all results matching a query you can repeat the same query with |
See example above. |
Regions:
For querying sequence and structure we utilize the conserved structural regions of tRNAs.
Simply put, they are numbered by occurencce from 5'->3' end of the tRNA.
"Empty Regions" in this context are not necessarily empty, but contain nucleotides that do not strictly
belong into any of the other structural regions. Indices in the table below are exactly as one would query the API
for the 'sequence' and 'structure' fields.
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Empty Region | Acceptor Stem | Empty Region | D-Stem | D-Loop | D-Stem | Empty Region | Anticodon Stem | Anticodon Loop | Anticodon Stem | Variable Region | T-Stem | T-Loop | T-Stem | Acceptor Stem | Empty Region | CCA |
API Response
When you POST a valid JSON to https://www.tdb.bioinf.uni-leipzig.de/api, the server will answer with a JSON in this shape:
{
'total_results': <integer>,
'page_offset': <integer>,
'page_size': <integer,
'results': [
{<dictionary>},
{<dictionary>},
...
]
}
total_resultsis an integer value that describes how many tRNAdb entries match the query in total. Note that only up to 1000 entries can be retrieved with a single query.'page_offset'is the page number of results that the 'results' field contains. See "Query Parameters" above for more information.'page_size'is the maximum number of results per page of results retrieved.'results'is a list that contains dictionaries (JSON) of individual entries that match the query.
In case your request JSON was malformed, the server responds with a JSON that describes the error that occured.
This JSON could, for example, look something like this: {'error': 'Some fields not supported: some_field'}. If the
'results' list does not contain any entries (or 'total_results is zero), your request does not match any tRNAs in the database.
Entry Fields
Every entry that is returned by the API in the 'results' field is a JSON that contains the following keys/values:
| Key | Value Description |
|---|---|
'sequence': |
nucleotide sequence of the tRNA. tRNA RNA sequences contain special characters for modified nucleotides |
'structure': |
dot-bracket structure of the tRNA |
'aligned_sequence': |
sequence aligned to the global alignment (global alignment is region-wise, sequence based) |
'aligned_structure': |
structure aligned to the global alignment (global alignment is region-wise, sequence based) |
'amino_acid': |
three letter code of the amino acid the tRNA is for |
'annotated_aligned_sequence': |
sequence aligned to the global alignment, regions split by @-character |
'annotated_aligned_structure': |
strucutre aligned to the global sequence alignment, regions split by @-character |
'annotated_sequence': |
raw sequence, regions split by @-character |
'annotated_structure': |
dot-bracket structure, regions split by @-character |
'anticodon': |
anticodon nucleotides. Three characters |
'database': |
database origin, i.e. "tRNA DNA", "tRNA RNA", "mt-tRNA DNA", "mt-tRNA RNA" |
'id': |
internal ID, unique together with "database" |
'parent_clades: |
taxonomic lineage from NCBI taxonomy. Hierarchical comma separated list of taxonomic lineage from species, ..., domain-of-life |
'reference': |
this can be genome accessions, data sources like gtRNAdb, or publication references, ... |
'sprinzl_id': |
SprinzlID, if available |
'tRNAdb_version': |
version number; version at which the particular tRNA has been added to tRNAdb |
'version_details': |
version description |
'taxon_embl_code': |
EMBL Code of the organism the tRNA is from |
'taxon_id': |
NCBI taxonomy ID of the organism the tRNA is from |
'taxon_name': |
species name of the organism the tRNA is from |
'taxon_synonyms': |
synonyms of taxon_name |
'trnadb_id': |
tRNAdb ID, unique and consistent |
Simple Python Example
Using python for the sake of an easy and readable example, a simple request querying the tRNAdb API for human nuclear Alanine tRNAs could look like this:
import requests
import json
request_dict = {
"database": "trna",
"amino_acid": "Ala",
"organism": "Human",
"page_size": 1000,
"page_offset": 0
}
api_server = "https://tdb.bioinf.uni-leipzig.de/api"
api_response = requests.post(
api_server,
json=request_dict,
timeout=10
)
response_data = json.loads(api_response.text)
print()
print("Total results matching query:", response_data["total_results"])
# get the first entry
entry = response_data["results"][0]
print()
print("The first matching entry:")
# output every field name and field data for the first entry
for k in entry.keys():
print(k, ":", entry[k])