Skip to content

Commit

Permalink
perf: Update python version and its dependencies (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivadym authored Aug 10, 2023
1 parent 4a0f88b commit 99fe9f2
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 82 deletions.
3 changes: 3 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ tag_name = v{new_version}
[bumpversion:file:docs/install.rst]

[bumpversion:file:docs/balsamic_methods.rst]

[bumpversion:file:setup.py]

search = {current_version}
replace = {new_version}
2 changes: 1 addition & 1 deletion .github/workflows/black_linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.11'
- uses: psf/black@stable
with:
options: "--check --verbose"
Expand Down
4 changes: 2 additions & 2 deletions .pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[pytest]
testpaths = tests testpaths = tests
addopts = -v -x addopts = -v -x
testpaths = tests
addopts = -v -x
norecursedirs = '.*' 'dist' 'CVS' '_darcs' '{arch}' '*.egg' 'venv'
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: 2
build:
os: "ubuntu-20.04"
tools:
python: "3.7"
python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand Down
6 changes: 1 addition & 5 deletions BALSAMIC/assets/scripts/edit_vcf_info.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# vim: syntax=python tabstop=4 expandtab
# coding: utf-8

""" Script to include variant caller information to the VCF info field and output to new VCF file """
""" Script to include variant caller information to the VCF info field and output to new VCF file."""

import click
import gzip
from cyvcf2 import VCF, Writer


Expand Down
7 changes: 3 additions & 4 deletions BALSAMIC/assets/scripts/generate_cnv_report.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env python
"""Script to generate CNV reports."""
import os
from pathlib import Path
from typing import List, Tuple

import click

from fpdf import FPDF
from PIL import Image
from fpdf import FPDF


@click.command(short_help="Merge statistics and plots into a single CNV report")
Expand Down Expand Up @@ -113,7 +112,7 @@ def add_plots_to_pdf(pdf: PDF, plot_paths: List[Path]) -> PDF:

# Image position & resizing
img = Image.open(path)
img.thumbnail(img_size, Image.ANTIALIAS)
img.thumbnail(img_size, Image.LANCZOS)
pdf.image(img, img_xy[0], img_xy[1])

return pdf
Expand Down
3 changes: 1 addition & 2 deletions BALSAMIC/conda/balsamic.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
channels:
- conda-forge
- bioconda
- defaults

dependencies:
- conda-forge::python=3.7
- conda-forge::python=3.11
- conda-forge::pip
- conda-forge::pygraphviz
1 change: 0 additions & 1 deletion BALSAMIC/containers/balsamic/balsamic.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
conda env update -n base --file "${1}".yaml
pip install --no-cache-dir fpdf2==2.4.6
7 changes: 3 additions & 4 deletions BALSAMIC/containers/balsamic/balsamic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ channels:
- defaults

dependencies:
- conda-forge::python=3.7
- conda-forge::pip
- conda-forge::pygraphviz
- conda-forge::pillow
- conda-forge::python=3.11
- conda-forge::pip==23.2.1
- conda-forge::pygraphviz==1.11
14 changes: 1 addition & 13 deletions BALSAMIC/utils/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,6 @@ def get_swegen_sv(config: dict) -> str:
return Path(config["reference"]["swegen_sv_frequency"]).as_posix()


def get_toml(annotation: dict) -> str:
"""Returns annotation in toml format
Args:
annotation: a dict containing annotation resource
Returns:
toml_annotation: a string in toml format
"""
return toml.dumps(annotation)


def dump_toml(annotations: list) -> str:
"""Returns list of converted annotation in toml format
Expand All @@ -430,5 +418,5 @@ def dump_toml(annotations: list) -> str:
"""
toml_annotations = ""
for annotation in annotations:
toml_annotations += get_toml(annotation)
toml_annotations += toml.dumps(annotation)
return toml_annotations
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Changed:
* Balsamic init workflow refactoring https://github.com/Clinical-Genomics/BALSAMIC/pull/1188
* Updated cryptography version to 41.0.2 https://github.com/Clinical-Genomics/BALSAMIC/pull/1205
* Refactor snakemake executable command generation https://github/Clinical-Genomics/BALSAMIC/pull/1211
* Updated Python version to 3.11 and its dependencies https://github.com/Clinical-Genomics/BALSAMIC/pull/1216

Fixed:
^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Create a conda environment:

.. code-block::
conda create -n balsamic_doc -c bioconda -c conda-forge python=3.7 pip pygraphviz
conda create -n balsamic_doc -c bioconda -c conda-forge python=3.11 pip pygraphviz
conda activate balsamic_doc
Install Sphinx and extensions:
Expand Down
10 changes: 5 additions & 5 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Software Requirements
~~~~~~~~~~~~~~~~~~~~~

- Conda >=version 4.5.0: For detailed software and python requirements please see ``setup.py`` and ``BALSAMIC/conda/balsamic.yaml``
- Singularity >=version 3.0.0: BALSAMIC uses singularity to run vairous parts of the workflow.
- Python 3.6
- Singularity >=version 3.0.0: BALSAMIC uses singularity to run vairous parts of the workflow.
- Python 3.11
- BALSAMIC is dependent on third-party bioinformatics software ``Sentieon-tools``. Example: for running wgs variant calling using ``TNScope``, and to execute ``UMIworkflow``.

``Note: Set Sentieon envionment variables in your ~/.bashrc file by adding following two lines``
Expand All @@ -28,18 +28,18 @@ Step 1. Installing BALSAMIC

::

conda create -c conda-forge -c defaults --name S_BALSAMIC python==3.7 pip pygraphviz
conda create -c conda-forge -c defaults --name S_balsamic python==3.11 pip pygraphviz


2. Activate environment:
2. Activate environment:

::

conda activate S_BALSAMIC



3. Install BALSAMIC using ``pip`` within the newly created environment:
3. Install BALSAMIC using ``pip`` within the newly created environment:

::

Expand Down
12 changes: 5 additions & 7 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
pytest==7.1.3
pytest-cov==2.8.1
coveralls
pylint==2.13.9
black==22.3.0
pillow>=8.4.0
fpdf2==2.4.6
black==23.7.0
bump2version==1.0.1
coveralls==3.3.1
pytest-cov==4.1.0
pytest==7.4.0
150 changes: 116 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,133 @@
"""Description of the Balsamic package."""
import os
from setuptools import setup, find_packages
from typing import List

here = os.path.abspath(os.path.dirname(__file__))
from setuptools import setup, find_packages

# Load the package's __version__.py module as a dictionary.
about = {}
with open(os.path.join(here, "BALSAMIC", "__version__.py")) as f:
exec(f.read(), about)
NAME: str = "BALSAMIC"
AUTHOR: str = "Clinical Genomics"
URL: str = "https://github.com/Clinical-Genomics/BALSAMIC"
EMAIL: str = "support@clinicalgenomics.se"
REQUIRES_PYTHON: str = ">=3.11.0"

# Requirements
requirements = [
"click==8.1.3",
"colorclass>=2.2.0",
"coloredlogs>=14.0",
"graphviz==0.16",
"gsutil==5.23",
"jinja2>=2.11.2",
"matplotlib==3.5.2",
"networkx>=2.6.3",
"numpy>=1.21.6",
"pandas>=1.1.5",
"psutil>=5.7.0",
"pydantic>=1.9.0,<2.0",
"pygments>=2.6.1",
"pyyaml>=5.3.1",
"six>=1.12.0",
"snakemake==7.25.0",
"yapf>=0.30.0",
"h5py>=3.6.0",
"PyPDF2>=1.26.0",
"markdown==3.3.3",
"cryptography==41.0.2",
"tabulate==0.8.10",
requirements: List[str] = [
"aiohttp==3.8.5",
"aiosignal==1.3.1",
"appdirs==1.4.4",
"argcomplete==3.1.1",
"async-timeout==4.0.2",
"attrs==23.1.0",
"boto==2.49.0",
"cachetools==5.3.1",
"certifi==2023.7.22",
"cffi==1.15.1",
"charset-normalizer==3.2.0",
"click==8.1.6",
"colorclass==2.2.2",
"coloredlogs==15.0.1",
"ConfigArgParse==1.7",
"connection-pool==0.0.3",
"contourpy==1.1.0",
"crcmod==1.7",
"cryptography==41.0.3",
"cycler==0.11.0",
"cyvcf2==0.30.22",
"datrie==0.8.2",
"defusedxml==0.7.1",
"docutils==0.20.1",
"dpath==2.1.6",
"fasteners==0.18",
"fastjsonschema==2.18.0",
"fonttools==4.42.0",
"fpdf2==2.7.4",
"frozenlist==1.4.0",
"gcs-oauth2-boto-plugin==3.0",
"gitdb==4.0.10",
"GitPython==3.1.32",
"google-apitools==0.5.32",
"google-auth==2.22.0",
"google-reauth==0.1.1",
"graphviz==0.20.1",
"gsutil==5.25",
"h5py==3.9.0",
"httplib2==0.20.4",
"humanfriendly==10.0",
"idna==3.4",
"importlib-metadata==6.8.0",
"iniconfig==2.0.0",
"Jinja2==3.1.2",
"jsonschema==4.18.6",
"jsonschema-specifications==2023.7.1",
"jupyter_core==5.3.1",
"kiwisolver==1.4.4",
"MarkupSafe==2.1.3",
"matplotlib==3.7.2",
"monotonic==1.6",
"multidict==6.0.4",
"nbformat==5.9.2",
"numpy==1.25.2",
"oauth2client==4.1.3",
"packaging==23.1",
"pandas==2.0.3",
"Pillow==10.0.0",
"plac==1.3.5",
"platformdirs==3.10.0",
"pluggy==1.2.0",
"psutil==5.9.5",
"PuLP==2.7.0",
"pyasn1==0.5.0",
"pyasn1-modules==0.3.0",
"pycparser==2.21",
"pydantic==1.10.12",
"Pygments==2.15.1",
"pyOpenSSL==23.2.0",
"pyparsing==3.0.9",
"PyPDF2==3.0.1",
"pytest==7.4.0",
"python-dateutil==2.8.2",
"pytz==2023.3",
"pyu2f==0.1.5",
"PyYAML==6.0.1",
"referencing==0.30.0",
"requests==2.31.0",
"reretry==0.11.8",
"retry-decorator==1.1.1",
"rpds-py==0.9.2",
"rsa==4.7.2",
"six==1.16.0",
"smart-open==6.3.0",
"smmap==5.0.0",
"snakemake==7.32.0",
"stopit==1.1.2",
"tabulate==0.9.0",
"throttler==1.2.2",
"toml==0.10.2",
"tomli==2.0.1",
"toposort==1.10",
"traitlets==5.9.0",
"typing_extensions==4.7.1",
"tzdata==2023.3",
"urllib3==1.26.16",
"wrapt==1.15.0",
"yapf==0.40.1",
"yarl==1.9.2",
"yte==1.5.1",
"zipp==3.16.2",
]

# The C libraries required to build numpy are not available on RTD
if not os.getenv("READTHEDOCS"):
requirements.extend(["cyvcf2==0.30.22"])

setup(
name="BALSAMIC",
version=about["__version__"],
url="https://github.com/Clinical-Genomics/BALSAMIC",
author="Hassan Foroughi Asl",
author_email="hassan.foroughi@scilifelab.se",
name=NAME,
version="12.0.2",
url=URL,
author=AUTHOR,
author_email=EMAIL,
install_requires=requirements,
python_requires=REQUIRES_PYTHON,
packages=find_packages(),
package_data={
"": [
Expand Down
5 changes: 3 additions & 2 deletions tests/commands/init/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from BALSAMIC.constants.cache import GenomeVersion
from BALSAMIC.constants.cluster import ClusterAccount
from BALSAMIC.constants.constants import EXIT_SUCCESS, EXIT_FAIL
from BALSAMIC.utils.exc import BalsamicError


def test_init_hg(
Expand Down Expand Up @@ -176,7 +177,7 @@ def test_init_hg_graph_exception(
# GIVEN a temporary output directory and a COSMIC key

# WHEN invoking the init command
with mock.patch.object(Source, "render"):
with mock.patch.object(Source, "render", side_effect=BalsamicError("Test error")):
result: Result = invoke_cli(
[
"init",
Expand All @@ -189,7 +190,7 @@ def test_init_hg_graph_exception(
]
)

# THEN the human reference generation workflow should have successfully started
# THEN the human reference generation workflow should fail
assert "Workflow graph generation failed" in result.output
assert Path(tmp_path, balsamic_version, GenomeVersion.HG19, config_json).exists()
assert not Path(
Expand Down

0 comments on commit 99fe9f2

Please sign in to comment.