Skip to content

Commit

Permalink
Merge pull request #215 from qiyunzhu/toml
Browse files Browse the repository at this point in the history
Upgrading Python packaging mechanism
  • Loading branch information
qiyunzhu authored Oct 8, 2024
2 parents 959f2f9 + 9d37183 commit 7fbd303
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 83 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
strategy:
max-parallel: 5
matrix:
os: ['ubuntu']
python-version: ['3.8', '3.12']
os: ['ubuntu', 'macos', 'windows']
python-version: ['3.8', '3.10', '3.12']

steps:
- name: Check out repo
Expand All @@ -28,13 +28,10 @@ jobs:
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge

- name: Install dependencies
run: conda install --file ci/conda_requirements.txt
environment-file: environment.yml

- name: Install CI packages
run: conda install pycodestyle coverage
run: conda install -c conda-forge pycodestyle coverage

- name: Install program
run: pip install -e .
Expand All @@ -48,6 +45,7 @@ jobs:
coverage run -m unittest && coverage lcov
- name: Coveralls
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.12' }}
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

### Added
- Formally adopted the NumPy + Numba solution in the ordinal mapper. This significantly accelerated the algorithm ([#209](https://github.com/qiyunzhu/woltka/pull/209)).
- Accelerated command-line interface loading ([#215](https://github.com/qiyunzhu/woltka/pull/215)).

### Changed
- Changed default output subject coverage (`--outcov`) coordinates into BED-like (0-based, exclusive end). The output can be directly parsed by programs like bedtools. Also added support for GFF-like and other custom formats, as controled by paramter `--outcov-fmt` ([#204](https://github.com/qiyunzhu/woltka/pull/204) and [#205](https://github.com/qiyunzhu/woltka/pull/205)).
- Default chunk size is now 1024 for plain and range mapeprs, and 2 ** 20 = 1048576 for ordinal mapper. The latter represents the number of valid query-subject pairs ([#209](https://github.com/qiyunzhu/woltka/pull/209)).
- Updated packaging method ([#215](https://github.com/qiyunzhu/woltka/pull/215)).


## Version 0.1.6 (2/22/2024)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2020, Qiyun Zhu
Copyright (c) 2020--, Qiyun Zhu
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

2 changes: 0 additions & 2 deletions ci/conda_requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Option 4: Install from a local copy:
Download this [repository](https://github.com/qiyunzhu/woltka/archive/main.zip) or any of the previous [releases](https://github.com/qiyunzhu/woltka/releases). Unzip and navigate to the package directory. Then execute:

```bash
python setup.py install
pip install .
```

Type `woltka` to check if installation is successful, in which case command-line help information will be displayed on the screen.
Expand Down
7 changes: 7 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: woltka
channels:
- conda-forge
dependencies:
- python >=3.6
- numba
- biom-format
52 changes: 52 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "woltka"
dynamic = ["version"]
dependencies = [
"numba",
"biom-format",
]
requires-python = ">=3.6"
authors = [
{name = "Qiyun Zhu", email = "qiyunzhu@gmail.com"}
]
maintainers = [
{name = "Qiyun Zhu", email = "qiyunzhu@gmail.com"}
]
description = "versatile meta-omic data classifier"
readme = "README.md"
license = {file = "LICENSE"}
keywords = ["bioinformatics", "metagenomics", "microbiome"]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: BSD License",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Operating System :: OS Independent",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
]

[project.urls]
Homepage = "https://github.com/qiyunzhu/woltka"
Documentation = "https://github.com/qiyunzhu/woltka/blob/main/README.md"
Repository = "https://github.com/qiyunzhu/woltka.git"
Issues = "https://github.com/qiyunzhu/woltka/issues"
Changelog = "https://github.com/qiyunzhu/woltka/blob/main/CHANGELOG.md"

[project.scripts]
woltka = "woltka.cli:cli"

[project.entry-points."qiime2.plugins"]
q2-woltka = "woltka.q2.plugin_setup:plugin"

[tool.hatch.version]
path = "woltka/__init__.py"
47 changes: 0 additions & 47 deletions setup.py

This file was deleted.

20 changes: 6 additions & 14 deletions woltka/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import click

from . import __version__
from .workflow import workflow
from .tools import normalize_wf, filter_wf, merge_wf, collapse_wf, coverage_wf


class NaturalOrderGroup(click.Group):
Expand Down Expand Up @@ -197,6 +195,7 @@ def cli():
def classify_cmd(**kwargs):
"""Main classification workflow: Alignments => profile(s).
"""
from .workflow import workflow
workflow(**kwargs)


Expand Down Expand Up @@ -236,6 +235,7 @@ def classify_cmd(**kwargs):
def collapse_cmd(**kwargs):
"""Collapse a profile by feature mapping and/or hierarchy.
"""
from .tools import collapse_wf
collapse_wf(**kwargs)


Expand Down Expand Up @@ -263,6 +263,7 @@ def collapse_cmd(**kwargs):
def normalize_cmd(**kwargs):
"""Normalize a profile to fractions and/or by feature sizes.
"""
from .tools import normalize_wf
normalize_wf(**kwargs)


Expand All @@ -284,6 +285,7 @@ def normalize_cmd(**kwargs):
def filter_cmd(**kwargs):
"""Filter a profile by per-sample abundance.
"""
from .tools import filter_wf
filter_wf(**kwargs)


Expand All @@ -300,6 +302,7 @@ def filter_cmd(**kwargs):
def merge_cmd(**kwargs):
"""Merge multiple profiles into one profile.
"""
from .tools import merge_wf
merge_wf(**kwargs)


Expand Down Expand Up @@ -330,20 +333,9 @@ def merge_cmd(**kwargs):
def coverage_cmd(**kwargs):
"""Calculate per-sample coverage of feature groups.
"""
from .tools import coverage_wf
coverage_wf(**kwargs)


# the "tools" menu is for backward compatibility
@cli.group('tools', cls=NaturalOrderGroup)
def tools():
"""Entries to the same commands for backward compatibility (deprecated).
"""
pass # pragma: no cover


for cmd in collapse_cmd, normalize_cmd, filter_cmd, merge_cmd, coverage_cmd:
tools.add_command(cmd)


if __name__ == '__main__':
cli() # pragma: no cover
3 changes: 2 additions & 1 deletion woltka/tests/test_biom.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def test_table_to_biom(self):
'G5\t0\t7\t5\t\t\t\n'),
sep='\t', index_col=0, na_filter=False)
assert_frame_equal(
obs.to_dataframe(dense=True).astype(int), exp.iloc[:, :3])
obs.to_dataframe(dense=True).astype(int),
exp.iloc[:, :3].astype(int))
assert_frame_equal(
obs.metadata_to_dataframe('observation')[[
'Name', 'Rank', 'Lineage']], exp.iloc[:, -3:])
Expand Down
10 changes: 5 additions & 5 deletions woltka/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ def _test_params(params, exp):
# check read maps
for i in range(1, 6):
outmap_fp = join(self.tmpdir, f'S0{i}.txt.gz')
with gzip.open(outmap_fp, 'r') as f:
obs = f.read()
with gzip.open(outmap_fp, 'rt') as f:
obs = [x.rstrip() for x in f.readlines()]
with gzip.open(join(self.outdir, 'burst.genus.map',
f'S0{i}.txt.gz'), 'r') as f:
exp = f.read()
self.assertEqual(obs, exp)
f'S0{i}.txt.gz'), 'rt') as f:
exp = [x.rstrip() for x in f.readlines()]
self.assertListEqual(obs, exp)
remove(outmap_fp)

# blastn, family-level classification, report relative abundance (%)
Expand Down
4 changes: 2 additions & 2 deletions woltka/tests/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def test_write_profiles(self):
write_profiles(data, fp, is_biom=True)
obs = load_table(fp).to_dataframe(dense=True).astype(int)
exp = pd.DataFrame([[1, 3], [2, 0], [0, 2]], index=['G1', 'G2', 'G3'],
columns=['S1', 'S2'])
columns=['S1', 'S2']).astype(int)
assert_frame_equal(obs, exp)

# multiple profiles in BIOM format (default)
Expand All @@ -695,7 +695,7 @@ def test_write_profiles(self):
fp = join(self.tmpdir, 'free.biom')
obs = load_table(fp).to_dataframe(dense=True).astype(int)
exp = pd.DataFrame([[3, 1], [0, 2]], index=['Ecoli', 'Strep'],
columns=['S1', 'S2'])
columns=['S1', 'S2']).astype(int)
assert_frame_equal(obs, exp)
remove(fp)

Expand Down

0 comments on commit 7fbd303

Please sign in to comment.