ensembl#

Retrieve information using the Ensembl API

ensembl.get(gene, species=None, analysis='lookup', extra_ext='', server='https://rest.ensembl.org')#

Retrieve Ensembl gene information for a gene

Parameters#

gene: str

Gene symbol (name) if species is given, else gene Ensembl identifier

species: str

E.g. ‘human’, ‘homo_sapiens’ or ‘mouse’, if None then gene expects Ensembl identifier

analysis: {‘lookup’, ‘sequence’, ‘archive’, …}

Type of API request, see https://rest.ensembl.org for details

extra_ext: str

Extra options to be appended to request. E.g. ‘expand=1;format=condensed’

server: str

The server to do the request, defaults to latest Ensembl server. E.g. for accessing the human assembly GRCh37 use ‘https://grch37.rest.ensembl.org

Returns#

info: dict

The requested information as dictionary

Raises#

HTTPError:

If request has not been successful

ensembl.get_gene_names(genes, server='https://rest.ensembl.org')#

Retrieve Ensembl gene names for list of ensembl identifiers

Parameters#

genes: list(str)

Gene Ensembl identifiers

server: str

The server to do the request, defaults to latest Ensembl server. E.g. for accessing the human assembly GRCh37 use ‘https://grch37.rest.ensembl.org

Returns#

names: dict

The requested names of the genes with the Ensembl identifiers as keys and the corresponding gene names as values

Raises#

HTTPError:

If request has not been successful

ensembl.get_homology(genes, species=None, target_species=None, return_names=False, server='https://rest.ensembl.org')#

Retrieve Ensembl gene homology for a list of genes

Parameters#

genes: list(str)

Gene symbols (names) if species is given, else gene Ensembl identifiers

species: str

E.g. ‘human’, ‘homo_sapiens’ or ‘mouse’, if None then genes expects Ensembl identifiers

target_species: str

The species of the target, if same as ‘species’ or None then paralogues are searched, else orthologues.

server: str

The server to do the request, defaults to latest Ensembl server. E.g. for accessing the human assembly GRCh37 use ‘https://grch37.rest.ensembl.org

Returns#

homology: dict

The homology as dictionary where the keys are the ‘genes’ of the source species and the values are lists of Ensembl identifiers or gene names (if ‘return_names’ is True) of the target species.

Raises#

HTTPError:

If request has not been successful

ensembl.post(genes, species=None, analysis='lookup', extra_ext='', server='https://rest.ensembl.org')#

Retrieve Ensembl gene information for a list of genes

Parameters#

genes: list(str)

Gene symbols (names) if species is given, else gene Ensembl identifiers

species: str

E.g. ‘human’, ‘homo_sapiens’ or ‘mouse’, if None then genes expects Ensembl identifiers

analysis: {‘lookup’, ‘sequence’, ‘archive’, …}

Type of API request, see https://rest.ensembl.org for details

extra_ext: str

Extra options to be appended to request. E.g. ‘expand=1;format=condensed’

server: str

The server to do the request, defaults to latest Ensembl server. E.g. for accessing the human assembly GRCh37 use ‘https://grch37.rest.ensembl.org

Returns#

info: dict

The requested information as dictionary of dictionaries with the given genes as keys

Raises#

HTTPError:

If request has not been successful

ValueError:

If given ‘extra_ext’ has non-valid options