Skip to content

Commit

Permalink
V2.0.1 dev (#43)
Browse files Browse the repository at this point in the history
* Switch to using pyproject.toml (#42)

* Switch to using pyproject.toml

* Include numpy headers

* Start using github actions

* Fix linter errors

* Use pylint for github actions

* Run pylint first

* use defined environments on github

* Fix call windows issue

* Try to run coveralls

* Run on pull requests

* Upload coverage results in parallel jobs

* Bump version number
  • Loading branch information
rbeagrie committed Jun 13, 2023
1 parent 01f6624 commit 690cdb5
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 129 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/tox-test.yml
@@ -0,0 +1,40 @@
name: Python package

on: ["push", "pull_request"]

jobs:
test:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9",]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Test with tox
run: tox --skip-missing-interpreters
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ join(matrix.*, '-') }}
parallel: true

finish:
needs: test
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: "run-3.8,run-3.9"
2 changes: 1 addition & 1 deletion .pylintrc
Expand Up @@ -353,4 +353,4 @@ analyse-fallback-blocks=no

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.Exception
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.1] - 2023-06-13

### Changed
- Move to pyproject.toml packaging for compatibility with newer PIP versions
- Fixed incorrect parameter name in gamtools call_windows

## [2.0.0] - 2022
### Added
- Allow the doit dependencies database to be reset
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Expand Up @@ -2,4 +2,4 @@ include README.md
include lib/gamtools/tests/*.py
include lib/gamtools/data/examples/*
include lib/gamtools/data/scripts/*
exclude lib/gamtools/*.pyx
include lib/gamtools/*.pyx
2 changes: 1 addition & 1 deletion lib/gamtools/call_windows.py
Expand Up @@ -420,4 +420,4 @@ def threshold_from_args(args):

threshold_file(args.coverage_file, args.output_file,
args.fitting_folder, args.details_file,
args.fitting_function, args.min_reads)
args.fitting_function, args.min_read_threshold)
7 changes: 5 additions & 2 deletions lib/gamtools/resolution.py
Expand Up @@ -39,6 +39,9 @@
from . import segregation


class SliceException(Exception):
"""Exception class for errors related to SLICE"""

def segregation_info(segregation_table, skip_chroms):
"""
Given a segregation table, retrieve the number of tubes,
Expand All @@ -57,10 +60,10 @@ def segregation_info(segregation_table, skip_chroms):

bin_sizes = segregation_windows['size'].value_counts()
frequent_sizes = [size for (size, freq)
in (bin_sizes / bin_sizes.sum()).iteritems()
in (bin_sizes / bin_sizes.sum()).items()
if freq > 0.95]
if not frequent_sizes:
raise Exception('SLICE requires windows of even sizes')
raise SliceException('SLICE requires windows of even sizes')
window_size = frequent_sizes[0]

return genome_size, window_size
Expand Down
40 changes: 40 additions & 0 deletions pyproject.toml
@@ -0,0 +1,40 @@
[build-system]
requires = ["setuptools>=61.0", "wheel", "Cython", "numpy"]
build-backend = "setuptools.build_meta"

[project]
name = "gamtools"
version = "2.0.1"
authors = [
{ name="Rob Beagrie", email="rob@beagrie.co.uk"}
]
description = "A package containing some utilities for analyzing GAM data."
license = { file = "LICENSE" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"License :: OSI Approved :: Apache Software License"
]
dependencies = [
"numpy",
"scipy",
"pandas",
"wrapit>=0.3.0",
"pytest",
"doit==0.29.0; python_version<'3.0'",
"mock; python_version<'3.0'",
"doit>=0.30.0; python_version>='3.0'"
]

[project.urls]
"Homepage" = "https://gam.tools"

[project.scripts]
gamtools = 'gamtools.main:main'
create_empty_bedgraph = 'gamtools.utils:empty_bedgraph_from_cmdline'

[tool.setuptools]
packages = ['gamtools', 'gamtools.qc']
include-package-data = true
package-dir = {"" = "lib"}
98 changes: 14 additions & 84 deletions setup.py
@@ -1,86 +1,16 @@
import os
import sys
from setuptools import setup, Extension
from setuptools.command.sdist import sdist
from setuptools.command.build_ext import build_ext

class CustomBuildExtCommand(build_ext):
"""Customized setuptools build_ext command - checks numpy is installed."""
def run(self):

# Check numpy is installed before trying to find the location
# of numpy headers

try:
import numpy
except ImportError:
raise ImportError('numpy need to be installed before GAMtools can be '
'compiled. Try installing with "pip install numpy" '
'before installing GAMtools.')

self.include_dirs.append(numpy.get_include())

build_ext.run(self)

class custom_cythonize_sdist(sdist):
def run(self):
# Make sure the compiled Cython files in the distribution are up-to-date
from Cython.Build import cythonize
cythonize([
"lib/gamtools/cosegregation_internal.pyx",
"lib/gamtools/mirnylib_numutils_internal.pyx",
], language_level = "3")
sdist.run(self)

# Utility function to read the README file.
# Used for the long_description. It's nice, because now 1) we have a top level
# README file and 2) it's easier to type in the README file than to put a raw
# string in below ...
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()

from setuptools import Extension, setup
from Cython.Build import cythonize
import numpy

extensions = [
Extension('gamtools.cosegregation_internal',
["lib/gamtools/cosegregation_internal.pyx"],
include_dirs=[numpy.get_include()]),
Extension('gamtools.mirnylib_numutils_internal',
["lib/gamtools/mirnylib_numutils_internal.pyx"],
include_dirs=[numpy.get_include()]),
]

setup(
name = "gamtools",
version = "2.0.0",
author = "Rob Beagrie",
author_email = "rob@beagrie.co.uk",
url = "https://gam.tools",
description = ("A package containing some utilities for analyzing GAM data."),
license = "Apache2.0",
package_dir = {'': 'lib'},
packages=['gamtools', 'gamtools.qc'],
ext_modules = [Extension('gamtools.cosegregation_internal',
["lib/gamtools/cosegregation_internal.c"]),
Extension('gamtools.mirnylib_numutils_internal',
["lib/gamtools/mirnylib_numutils_internal.c"],),
],
cmdclass = {
'sdist': custom_cythonize_sdist,
'build_ext': CustomBuildExtCommand,
},
install_requires=[
'numpy',
'scipy',
'pandas',
'wrapit>=0.3.0',
'pytest'],
extras_require={
':python_version<"3.0"': ['doit==0.29.0'],
':python_version>="3.0"': ['doit==0.30.0'],
':python_version<"3.0"': ['mock'],
},
entry_points = {
'console_scripts': [
'gamtools = gamtools.main:main',
'create_empty_bedgraph = gamtools.utils:empty_bedgraph_from_cmdline',
]
},
long_description=read('README.md'),
include_package_data=True,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"License :: OSI Approved :: Apache Software License",
],
ext_modules = cythonize(extensions, language_level = "3"),
)
22 changes: 0 additions & 22 deletions simple_sample_name.py

This file was deleted.

20 changes: 2 additions & 18 deletions tox.ini
Expand Up @@ -4,22 +4,19 @@
# and then run "tox" from this directory.

[tox]
envlist = py{38,39}-pandas{12,13}, pylint, docs
envlist = pylint, py{38,39}-pandas{12,13}, docs

[testenv]
deps =
pytest-cov
pandas12: pandas>=1.2,<1.3
pandas13: pandas>=1.3,<1.4
pytest-cov
commands =
pytest --cov=gamtools --cov-report xml -m "not dependencies"
pytest -m "not dependencies"

[testenv:pylint]
deps =
pylint
basepython =
python3.9
commands =
pylint gamtools --rcfile={toxinidir}/.pylintrc

Expand All @@ -32,16 +29,3 @@ deps=
sphinx_rtd_theme
commands=
sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html

[testenv:coverage]
deps =
pytest-cov
basepython =
python3.9
commands=
pytest --cov=gamtools -m "not dependencies"

[travis]
python =
3.8: py38
3.9: py39, docs, pylint

0 comments on commit 690cdb5

Please sign in to comment.