Skip to content

Commit

Permalink
Update test and apply precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
cokelaer committed Jan 26, 2025
1 parent 76c5c48 commit e0fd316
Show file tree
Hide file tree
Showing 23 changed files with 836 additions and 578 deletions.
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

files: '\.(py|rst|sh)$'
fail_fast: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
#- id: check-executables-have-shebangs
- id: check-ast

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
args: ["-j8", "--ignore=E203,E501,W503,E722", "--max-line-length=120", "--exit-zero"]

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
args: ["--line-length=120"]
exclude: E501

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"] # solves conflicts between black and isort

957 changes: 610 additions & 347 deletions poetry.lock

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
[project]
name = "bioservices"
version = "1.13.0"
description = "Access to Biological Web Services from Python"
authors = ["Thomas Cokelaer <[email protected]>"]
authors = [{name="Thomas Cokelaer", email="[email protected]"}]
license = "GPLv3"
readme = ["README.rst", "LICENSE"]
keywords = ["BioServices", "WebServices", "Biology", "BioDBNet", "ChEBI", "UniChem", "Kegg", "KEGG", "BioModels", "EUtils", "UniProt", "PICR", "ArrayExpress", "MUSCLE", "QuickGO", "PDB", "PSICQUIC", "Blast", "BioMART", "PantherDB", "BioGRID", "MIRIAM", "BioMart", "GeneProf", "ChEMBL", "ChemSpider", "HGNC", "PathwayCommons", "Rhea", "Ensembl"]
readme = "README.rst"
keywords = ["BioServices", "WebServices", "Biology", "ChEBI", "UniChem", "Kegg", "KEGG", "BioModels", "EUtils", "UniProt", "PICR", "ArrayExpress", "MUSCLE", "QuickGO", "PDB", "PSICQUIC", "Blast", "BioMART", "PantherDB", "BioGRID", "MIRIAM", "BioMart", "GeneProf", "ChEMBL", "ChemSpider", "HGNC", "PathwayCommons", "Rhea", "Ensembl"]

classifiers = [
"Development Status :: 5 - Production/Stable",
Expand All @@ -29,8 +29,28 @@ classifiers = [
"Topic :: Scientific/Engineering :: Information Analysis",
]

requires-python = ">=3.8,<4.0"
dependencies = [
"click (>=8.1.8,<9.0.0)",
"appdirs (>=1.4.4,<2.0.0)",
"matplotlib (<4)",
"easydev (>=0.13.3,<0.14.0)",
"tqdm (>=4.67.1,<5.0.0)",
"rich-click (>=1.8.5,<2.0.0)",
"colorlog (>=6.9.0,<7.0.0)",
"beautifulsoup4 (>=4.12.3,<5.0.0)",
"grequests (>=0.7.0,<0.8.0)",
"requests (>=2.32.3,<3.0.0)",
"lxml (>=5.3.0,<6.0.0)",
"requests-cache (>=1.2.1,<2.0.0)",
"suds-community (>=1.2.0,<2.0.0)",
"wrapt (>=1.17.2,<2.0.0)",
"xmltodict (>=0.14.2,<0.15.0)",
"pandas (<2.2)"

[tool.poetry.scripts]
]

[project.scripts]
bioservices = "bioservices.main:main"


Expand All @@ -42,26 +62,6 @@ Documentation = "https://bioesrvices.readthedocs.io"



[tool.poetry.dependencies]
python = "^3.8"
appdirs = "^1.4.4"
click = "^8.1.7"
easydev = "^0.12.1"
matplotlib = "<4"
tqdm = "^4.66.1"
rich-click = "^1.7.2"
beautifulsoup4 = "^4.12.3"
colorlog = "^6.8.2"
grequests = "^0.7.0"
requests = "^2.31.0"
pandas = ">=0.21.1"
lxml = "^5.1.0"
xmltodict = "^0.13.0"
wrapt = "^1.16.0"
requests-cache = "^1.1.1"
suds-community = "^1.1.2"


[tool.poetry.group.dev.dependencies]
pytest = "^8"
pytest-cov = "^4.1.0"
Expand Down
11 changes: 6 additions & 5 deletions src/bioservices/biomart.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
.. note:: SOAP and REST are available. We use REST for the wrapping.
"""
from io import StringIO
from bioservices import REST, BioServicesError
from functools import wraps
from bioservices import logger
from io import StringIO

from bioservices import REST, BioServicesError, logger

logger.name = __name__
import pandas as pd
Expand Down Expand Up @@ -359,8 +359,9 @@ def filters(self, dataset):
scrofa,Taeniopygia guttata ,Xenopus tropicalis]
"""
if dataset not in [x for k in self.valid_attributes.keys() for x in self.valid_attributes[k]]:
raise ValueError("provided dataset (%s) is not found. see valid_attributes" % dataset)
valid_attributes = sorted([x for k in self.valid_attributes.keys() for x in self.valid_attributes[k]])
if dataset not in valid_attributes:
raise ValueError(f"provided dataset ({dataset}) is not found. see valid_attributes {valid_attributes}")
ret = self.http_get("?type=filters&dataset=%s" % dataset, frmt="txt")
ret = [x for x in ret.split("\n") if len(x)]
results = {}
Expand Down
15 changes: 7 additions & 8 deletions src/bioservices/ensembl.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"""
from bioservices.services import REST
from bioservices import logger
from bioservices.services import REST

logger.name = __name__

Expand Down Expand Up @@ -189,13 +189,13 @@ def get_genetree_by_member_symbol(
def get_genetree_by_member_id(
self,
identifier,
species,
frmt="json",
aligned=False,
db_type="core",
object_type=None,
nh_format="simple",
sequence="protein",
species="homo_sapiens",
compara="multi",
):
"""Retrieves a gene tree containing the gene identified by a symbol
Expand All @@ -211,7 +211,7 @@ def get_genetree_by_member_id(
:
get_genetree_by_member_id('ENSG00000157764', frmt='phyloxml')
get_genetree_by_member_id('ENSG00000157764', 'human', frmt='phyloxml')
"""
Expand All @@ -222,7 +222,7 @@ def get_genetree_by_member_id(
self.check_sequence(sequence)

res = self.services.http_get(
"genetree/member/id/" + identifier,
f"genetree/member/id/{species}/{identifier}",
frmt=frmt,
headers=self.services.get_headers(content=frmt),
params={
Expand Down Expand Up @@ -356,23 +356,23 @@ def get_alignment_by_region(
)
return res

def get_homology_by_id(
def get_homology_by_species_and_id(
self,
identifier,
species,
frmt="json",
aligned=True,
compara="multi",
format=None,
sequence=None,
species=None,
target_species=None,
target_taxon=None,
type="all",
):
"""Retrieves homology information (orthologs) by Ensembl gene id"""
self._check_frmt(frmt, ["xml"])
res = self.services.http_get(
"homology/id/{0}".format(identifier),
f"homology/id/{species}/{identifier}",
frmt=frmt,
headers=self.services.get_headers(content=frmt),
params={
Expand All @@ -381,7 +381,6 @@ def get_homology_by_id(
"compara": compara,
"format": format,
"sequence": sequence,
"species": species,
"target_species": target_species,
"target_taxon": target_taxon,
"type": type,
Expand Down
4 changes: 2 additions & 2 deletions src/bioservices/ncbiblast.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import sys
import time

from bioservices.services import REST
from bioservices import logger
from bioservices.services import REST

logger.name = __name__

Expand Down Expand Up @@ -346,7 +346,7 @@ def get_result_types(self, jobid):
"""
if self.get_status(jobid) != "FINISHED":
self.services.logging.warning("waiting for the job to be finished. May take a while")
self.wait(jobid, verbose=False)
self.wait(jobid)
url = "resulttypes/" + jobid
res = self.services.http_get(
url,
Expand Down
Loading

0 comments on commit e0fd316

Please sign in to comment.