Skip to content

Commit

Permalink
Apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ivirshup committed Apr 2, 2024
1 parent 992f75c commit 88ca186
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
29 changes: 14 additions & 15 deletions docs/notebooks/basic_usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
}
],
"source": [
"gf.ensembl.list_ensdb_annotations(species='Mmusculus')"
"gf.ensembl.list_ensdb_annotations(species=\"Mmusculus\")"
]
},
{
Expand Down Expand Up @@ -854,7 +854,8 @@
],
"source": [
"ensdb.genes(\n",
" filter=gf.filters.GeneBioTypeFilter(\"lncRNA\") & gf.filters.GeneRangesFilter(\"1:10000-20000\")\n",
" filter=gf.filters.GeneBioTypeFilter(\"lncRNA\")\n",
" & gf.filters.GeneRangesFilter(\"1:10000-20000\")\n",
")"
]
},
Expand Down Expand Up @@ -1128,6 +1129,7 @@
"source": [
"import pandas as pd\n",
"import scanpy as sc\n",
"\n",
"pbmc = sc.datasets.pbmc3k()"
]
},
Expand Down Expand Up @@ -1214,19 +1216,16 @@
"metadata": {},
"outputs": [],
"source": [
"pbmc.var = (\n",
" pd.merge(\n",
" (\n",
" pbmc.var\n",
" .reset_index()\n",
" .rename(columns={\"gene_ids\": \"gene_id\", \"index\": \"orig_gene_name\"})\n",
" ),\n",
" genes,\n",
" on=\"gene_id\",\n",
" how=\"left\",\n",
" )\n",
" .set_index(\"gene_id\")\n",
")"
"pbmc.var = pd.merge(\n",
" (\n",
" pbmc.var.reset_index().rename(\n",
" columns={\"gene_ids\": \"gene_id\", \"index\": \"orig_gene_name\"}\n",
" )\n",
" ),\n",
" genes,\n",
" on=\"gene_id\",\n",
" how=\"left\",\n",
").set_index(\"gene_id\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/genomic_features/_core/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class CanonicalTxFilter(AbstractFilterExpr):
>>> ensdb.transcripts(filter=gf.filters.CanonicalTxFilter())
>>> ensdb.exons(
... cols=["tx_id", "exon_id", "seq_name", "exon_seq_start", "exon_seq_end"],
... filter=gf.filters.CanonicalTxFilter()
... filter=gf.filters.CanonicalTxFilter(),
... )
"""

Expand Down
15 changes: 13 additions & 2 deletions tests/test_list_ensdb_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@

import genomic_features as gf

SPECIES = ['Scerevisiae', 'Mmusculus_nzohlltj', 'Ggallus', 'Hsapiens', 'Mmusculus', 'Celegans']
SPECIES = [
"Scerevisiae",
"Mmusculus_nzohlltj",
"Ggallus",
"Hsapiens",
"Mmusculus",
"Celegans",
]


def test_ensdb_versions():
species_versions = gf.ensembl.list_ensdb_annotations("Hsapiens")
Expand All @@ -13,16 +21,19 @@ def test_ensdb_versions():
species_versions = gf.ensembl.list_ensdb_annotations("Rnorvegicus")
assert isinstance(species_versions, pd.DataFrame)


def test_missing_species():
# test error is raised when species is not found
with pytest.raises(ValueError):
gf.ensembl.list_ensdb_annotations("Homo sapiens")


def test_unique_versions():
# Check that different mouse strains are not considered the same species
species_versions = gf.ensembl.list_ensdb_annotations("Mmusculus")
assert species_versions.Ensembl_version.is_unique


def test_all_species():
species_versions = gf.ensembl.list_ensdb_annotations()
assert pd.Series(SPECIES).isin(species_versions['Species']).all()
assert pd.Series(SPECIES).isin(species_versions["Species"]).all()

0 comments on commit 88ca186

Please sign in to comment.