API

Python Module

Entry points

These functions are available after you import apybiomart and should be used as the main entry points for apybiomart. If you want more control, you can use the internal classes described below.

async apybiomart.apybiomart.aquery(attributes: List[str], filters: Dict[str, Union[str, int, list, tuple, bool]], dataset: str = 'hsapiens_gene_ensembl', save: bool = False, output: str = 'apybiomart_aquery.csv') → pandas.core.frame.DataFrame[source]

Launch asynchronous query using the given attributes, filters and dataset.

Parameters
  • attributes – list of attributes to include

  • filters – dict of filter name : value to filter results

  • dataset – BioMart dataset name (default: “hsapiens_gene_ensembl”)

  • save – save results to a CSV file [default: False]

  • output – output filename if saving results [default: ‘apybiomart_aquery.csv’]

apybiomart.apybiomart.find_attributes(dataset: str = 'hsapiens_gene_ensembl', save: bool = False, output: str = 'apybiomart_attributes.csv') → pandas.core.frame.DataFrame[source]

Retrieve and list available attributes for a given mart.

Parameters
  • dataset – BioMart dataset name (default: “hsapiens_gene_ensembl”)

  • save – save results to a CSV file [default: False]

  • output – output filename if saving results [default: ‘apybiomart_attributes.csv’]

apybiomart.apybiomart.find_datasets(mart: str = 'ENSEMBL_MART_ENSEMBL', save: bool = False, output: str = 'apybiomart_datasets.csv') → pandas.core.frame.DataFrame[source]

Retrieve and list available datasets for a given mart.

Parameters
  • mart – BioMart mart name (default: “ENSEMBL_MART_ENSEMBL”)

  • save – save results to a CSV file [default: False]

  • output – output filename if saving results [default: ‘apybiomart_datasets.csv’]

apybiomart.apybiomart.find_filters(dataset: str = 'hsapiens_gene_ensembl', save: bool = False, output: str = 'apybiomart_filters.csv') → pandas.core.frame.DataFrame[source]

Retrieve and list available filters for a given mart.

Parameters
  • dataset – BioMart dataset name (default: “hsapiens_gene_ensembl”)

  • save – save results to a CSV file [default: False]

  • output – output filename if saving results [default: ‘apybiomart_filters.csv’]

apybiomart.apybiomart.find_marts(save: bool = False, output: str = 'apybiomart_marts.csv') → pandas.core.frame.DataFrame[source]

Retrieve and list available marts.

Parameters
  • save – save results to a CSV file [default: False]

  • output – output filename if saving results [default: ‘apybiomart_marts.csv’]

apybiomart.apybiomart.query(attributes: List[str], filters: Dict[str, Union[str, int, list, tuple, bool]], dataset: str = 'hsapiens_gene_ensembl', save: bool = False, output: str = 'apybiomart_query.csv') → pandas.core.frame.DataFrame[source]

Launch synchronous query using the given attributes, filters and dataset.

Parameters
  • attributes – list of attributes to include

  • filters – dict of filter name : value to filter results

  • dataset – BioMart dataset name (default: “hsapiens_gene_ensembl”)

  • save – save results to a CSV file [default: False]

  • output – output filename if saving results [default: ‘apybiomart_query.csv’]

Internal classes

These are the internal classes used by apybiomart, and can be imported with from apybiomart.classes import <ClassName>. Use them if you want more control over the application.

class apybiomart.classes.AttributesServer(dataset: str, save: bool = False, output: str = 'apybiomart_attributes.csv')[source]

Class used to retrieve and list available attributes for a dataset.

dataset

BioMart dataset name

find_attributes() → pandas.core.frame.DataFrame[source]

Return the list of available attributes for a specific dataset as a dataframe.

class apybiomart.classes.DatasetServer(mart: str, save: bool = False, output: str = 'apybiomart_datasets.csv')[source]

Class used to retrieve and list available datasets for a mart.

mart

BioMart mart name

find_datasets() → pandas.core.frame.DataFrame[source]

Return the list of available datasets for a specific mart as a dataframe.

class apybiomart.classes.FiltersServer(dataset: str, save: bool = False, output: str = 'apybiomart_filters.csv')[source]

Class used to retrieve and list available filters for a dataset.

dataset

BioMart dataset name

find_filters() → pandas.core.frame.DataFrame[source]

Return the list of available filters for a specific dataset as a dataframe.

class apybiomart.classes.MartServer(save: bool = False, output: str = 'apybiomart_marts.csv')[source]

Class used to retrieve and list available marts.

find_marts() → pandas.core.frame.DataFrame[source]

Return the list of available marts as a dataframe.

Returns

pd.DataFrame

class apybiomart.classes.Query(attributes: List[str], filters: Dict[str, Union[str, int, list, tuple, bool]], dataset: str, save: bool = False, output: str = 'apybiomart_query.csv')[source]

Class used to perform either synchronous or asynchronous queries on BioMart.

attributes

list of attributes to include

filters

dict of filter name : value to filter results

dataset

BioMart dataset name

async aquery() → pandas.core.frame.DataFrame[source]

Perform asynchronous query.

Return the result of the query based on the given attributes, filters and optional dataset using Server.get_async(), as a pandas DataFrame.

query() → pandas.core.frame.DataFrame[source]

Perform synchronous query.

Return the result of the query based on the given attributes, filters and optional dataset using Server.get_sync(), as a pandas DataFrame.


Command Line Interface