ensimpl_snps.fetch package

Submodules

ensimpl_snps.fetch.get module

ensimpl_snps.fetch.get.meta(version, species_id)

Get the database meta information..

Parameters:
  • version (int) – Ensembl version.
  • species_id (str) – Ensembl species identifier.
Returns:

A dict with the following keys:
  • assembly
  • assembly_patch
  • species
  • version

Return type:

dict

ensimpl_snps.fetch.search module

ensimpl_snps.fetch.search.by_ids(ids, version, species)

Perform the search for ids.

Parameters:
  • ids (list) – A list of ids to look for.
  • version (int) – The Ensembl version.
  • species (str) – The Ensembl species identifier.
Returns:

A dict withe keys return snps and snps_not_found.

Return type:

dict

Raises:

ValueError – When ids is empty.

ensimpl_snps.fetch.search.by_region(region, version, species, limit=None)

Perform the search by region.

Parameters:
  • region (str) – The region to look for SNPs.
  • version (int) – The Ensembl version number.
  • species (str) – The Ensembl species identifier.
  • limit (int, optional) – Maximum number of SNPs to return, None for all.
Returns:

All the SNPs in region. Each element is another list with the following values:

  • chromosome
  • position
  • SNP identifier
  • reference allele
  • alternate allele

Return type:

list

Raises:

ValueError – When region is empty.

ensimpl_snps.fetch.utils module

class ensimpl_snps.fetch.utils.Region

Bases: object

Encapsulates a genomic region.

chromosome

str – The chromosome name.

start_position

int – The start position.

end_position

int – The end position.

ensimpl_snps.fetch.utils.connect_to_database(version, species)

Connect to the Ensimpl database.

Parameters:
  • version (int) – The Ensembl version number.
  • species (str) – The Ensembl species identifier.
Returns:

a connection to the database

ensimpl_snps.fetch.utils.get_multiplier(factor)

Get multiplying factor.

The factor value should be ‘mb’, ‘m’, or ‘k’ and the correct multiplier will be returned.

Parameters:factor (str) – One of ‘mb’, ‘m’, or ‘k’.
Returns:The multiplying value.
Return type:int
ensimpl_snps.fetch.utils.get_tabix_file(version, species)

Get the tabix file.

Parameters:
  • version (int) – The Ensembl version number.
  • species (str) – The Ensembl species identifier.
Returns:

A file location.

Return type:

str

ensimpl_snps.fetch.utils.nvl(value, default)

Returns value if value has a value, else default.

Parameters:
  • value – The value to evaluate.
  • default – The default value.
Returns:

Either value or default.

ensimpl_snps.fetch.utils.nvli(value, default)

Returns value as an int if value can be converted, else default.

Parameters:
  • value – The value to evaluate and convert to an it.
  • default – The default value.
Returns:

Either value or default.

ensimpl_snps.fetch.utils.str_to_region(location)

Parse a string into a genomic location.

Parameters:location (str) – The genomic location (range).
Returns:A region object.
Return type:Region
Raises:ValueError – If location is invalid.

Module contents