Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitattributes

This file was deleted.

3 changes: 1 addition & 2 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ jobs:
run: |
sudo apt-get install tabix
python -m pip install --upgrade pip
pip install .
make devdeps
pip install .[dev,test]
- name: Test with pytest
run: make test
- name: Style check
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ __pycache__/
rsidx.egg-info/
.coverage
scratch/
.vscode/
23 changes: 8 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@ help: Makefile
test:
pytest --cov=rsidx --doctest-modules rsidx/*/test_*.py

## devdeps: install development dependencies
devdeps:
pip install --upgrade pip setuptools
pip install wheel twine
pip install pycodestyle pytest-cov pytest-sugar
## style: check code style
style:
black --line-length=99 --check rsidx/*.py rsidx/*/*.py

## format: autoformat Python code
format:
black --line-length=99 rsidx/*.py rsidx/*/*.py

## devhooks: install development hooks
devhooks:
## hooks: install development hooks
hooks:
echo 'set -eo pipefail' > .git/hooks/pre-commit
echo 'make style' >> .git/hooks/pre-commit
chmod 755 .git/hooks/pre-commit

## clean: remove development artifacts
clean:
rm -rf __pycache__/ rsidx/__pycache__/ rsidx/*/__pycache__ build/ dist/ *.egg-info/

## style: check code style against PEP8
style:
pycodestyle --max-line-length=99 rsidx/*.py rsidx/*/*.py
33 changes: 33 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[project]
name = "rsidx"
version = "0.3.2.dev"
description = "Library for indexing VCF files for random access searches by rsID"
readme = "README.md"
requires-python = ">=3.8"
authors = [
{name = "Daniel Standage", email = "daniel.standage@st.dhs.gov"},
]


[project.optional-dependencies]
dev = ["black==24.10", "build", "twine"]
test = ["pytest", "pytest-cov"]


[project.scripts]
rsidx = "rsidx.__main__:main"


[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"


[tool.setuptools]
include-package-data = true
package-data = { rsidx = ["tests/data/**/*"] }


[tool.setuptools.packages.find]
where = ["."]
include = ["rsidx*"]
13 changes: 5 additions & 8 deletions rsidx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@
from rsidx import __main__
from rsidx import cli

from . import _version
__version__ = _version.get_versions()['version']


@contextmanager
def open(filename, mode):
if mode not in ('r', 'w'):
if mode not in ("r", "w"):
raise ValueError('invalid mode "{}"'.format(mode))
if filename in ['-', None]:
filehandle = sys.stdin if mode == 'r' else sys.stdout
if filename in ["-", None]:
filehandle = sys.stdin if mode == "r" else sys.stdout
yield filehandle
else:
openfunc = builtins.open
if filename.endswith('.gz'):
if filename.endswith(".gz"):
openfunc = gzopen
mode += 't'
mode += "t"
with openfunc(filename, mode) as filehandle:
yield filehandle
14 changes: 7 additions & 7 deletions rsidx/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
# and is licensed under the BSD license: see LICENSE.txt.
# -----------------------------------------------------------------------------

import argparse
import rsidx
from . import cli
from importlib.metadata import version
import sys


def main(args=None):
"""Entry point for the happer CLI.
"""Entry point for the rsidx CLI.

Isolated as a method so that the CLI can be called by other Python code
(e.g. for testing), in which case the arguments are passed to the function.
Expand All @@ -22,10 +22,10 @@ def main(args=None):
"""
if args is None: # pragma: no cover
if len(sys.argv) == 1:
rsidx.cli.get_parser().parse_args(['-h'])
args = rsidx.cli.get_parser().parse_args()
cli.get_parser().parse_args(["-h"])
args = cli.get_parser().parse_args()

versionmessage = '[rsidx] running version {}'.format(rsidx.__version__)
versionmessage = "[rsidx] running version {}".format(version("rsidx"))
print(versionmessage, file=sys.stderr)
mainmethod = rsidx.cli.mains[args.subcmd]
mainmethod = cli.mains[args.subcmd]
mainmethod(args)
Loading