Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Roach committed Dec 28, 2021
0 parents commit 9c9b915
Show file tree
Hide file tree
Showing 23 changed files with 3,007 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Python package

on: [push]
env:
POETRY_VERSION: 1.1

jobs:
testing:
runs-on: ubuntu-latest
strategy:
matrix:
PYTHON_VERSION: ["3.6", "3.7"]
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{matrix.PYTHON_VERSION}}
uses: actions/setup-python@v1
with:
python-version: ${{matrix.PYTHON_VERSION}}

- name: Get full Python version
id: full-python-version
shell: bash
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

- name: Install poetry
shell: bash
run: |
python -m pip install --upgrade pip
pip install poetry==${{env.POETRY_VERSION}}
- name: Configure poetry
shell: bash
run: poetry config virtualenvs.in-project true

- name: Set up cache
uses: actions/cache@v2
id: cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}

- name: Ensure cache is healthy
if: steps.cache.outputs.cache-hit == 'true'
shell: bash
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv

- name: Install deps
shell: bash
run: |
poetry install --extras docs
- name: Run pytest
shell: bash
run: |
poetry run python -m pytest --cov=pybedlite --cov-report=xml --cov-branch
- name: Style checking
shell: bash
run: |
poetry run black --line-length 99 --check pybedlite
- name: Run lint
shell: bash
run: |
poetry run flake8 --config=ci/flake8.cfg pybedlite
- name: Run mypy
shell: bash
run: |
poetry run mypy -p pybedlite --config=ci/mypy.ini
- name: Run docs
shell: bash
run: |
set -euo pipefail
pushd docs
poetry run make html
popd
- name: Upload code coverage
uses: codecov/[email protected]
132 changes: 132 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# VSCode configurations
.vscode/
12 changes: 12 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
build:
image: latest
version: 2
sphinx:
configuration: docs/conf.py
python:
version: 3.6
install:
- method: pip
path: .
extra_requirements:
- docs
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
The MIT License

Copyright (c) 2021 Fulcrum Genomics LLC, with the exception of
- pybedlite/overlap_detector.py
- pybedlite/tests/test_overlap_detector.py
which are Copyright 2020 Myriad Genetics Inc. and are copied from https://github.com/myriad-opensource/samwell under MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

[![Language][language-badge]][language-link]
[![Code Style][code-style-badge]][code-style-link]
[![Type Checked][type-checking-badge]][type-checking-link]
[![PEP8][pep-8-badge]][pep-8-link]
[![Code Coverage][code-coverage-badge]][code-coverage-link]
[![License][license-badge]][license-link]

---

[![Python package][python-package-badge]][python-package-link]
[![PyPI version][pypi-badge]][pypi-link]
[![PyPI download total][pypi-downloads-badge]][pypi-downloads-link]

---

[language-badge]: http://img.shields.io/badge/language-python-brightgreen.svg
[language-link]: http://www.python.org/
[code-style-badge]: https://img.shields.io/badge/code%20style-black-000000.svg
[code-style-link]: https://black.readthedocs.io/en/stable/
[type-checking-badge]: http://www.mypy-lang.org/static/mypy_badge.svg
[type-checking-link]: http://mypy-lang.org/
[pep-8-badge]: https://img.shields.io/badge/code%20style-pep8-brightgreen.svg
[pep-8-link]: https://www.python.org/dev/peps/pep-0008/
[code-coverage-badge]: https://codecov.io/gh/fulcrumgenomics/pybedlite/branch/master/graph/badge.svg
[code-coverage-link]: https://codecov.io/gh/fulcrumgenomics/pybedlite
[license-badge]: http://img.shields.io/badge/license-MIT-blue.svg
[license-link]: https://github.com/fulcrumgenomics/pybedlite/blob/master/LICENSE
[python-package-badge]: https://github.com/fulcrumgenomics/pybedlite/workflows/Python%20package/badge.svg
[python-package-link]: https://github.com/fulcrumgenomics/pybedlite/actions?query=workflow%3A%22Python+package%22
[pypi-badge]: https://badge.fury.io/py/pybedlite.svg
[pypi-link]: https://pypi.python.org/pypi/pybedlite
[pypi-downloads-badge]: https://img.shields.io/pypi/dm/pybedlite
[pypi-downloads-link]: https://pypi.python.org/pypi/pybedlite

# pybedlite

`pip install pybedlite`

**Requires python 3.6+**

# Getting Setup

[Poetry][poetry-link] is used to manage the python development environment.

A simple way to create an environment with the desired version of python and poetry is to use [conda][conda-link]. E.g.:

```bash
conda create -n pybedlite python=3.6 poetry
conda activate pybedlite
poetry install
```

If, during `poetry install` on Mac OS X errors are encountered running gcc/clang to build `pybedtools` or other packages with native code, try setting the following and re-running `poetry install`:
```bash
export CFLAGS="-stdlib=libc++"
```

[poetry-link]: https://github.com/python-poetry/poetry
[conda-link]: https://docs.conda.io/en/latest/miniconda.html
57 changes: 57 additions & 0 deletions ci/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

function banner() {
echo
echo "================================================================================"
echo $*
echo "================================================================================"
echo
}

#####################################################################
# Takes two parameters, a "name" and a "command".
# Runs the command and prints out whether it succeeded or failed, and
# also tracks a list of failed steps in $failures.
#####################################################################
function run() {
local name=$1
local cmd=$2

banner "Running $name [$cmd]"
set +e
$cmd
exit_code=$?
set -e

if [[ $exit_code == 0 ]]; then
echo Passed $name: "[$cmd]"
else
echo Failed $name: "[$cmd]"
if [ -z "$failures" ]; then
failures="$failures $name"
else
failures="$failures, $name"
fi
fi
}

parent=$(cd $(dirname $0) && pwd -P)

# If the script is invoked with --check only have black check, otherwise have it fix!
black_extra_args=""
if [[ "$1" == "--check" ]]; then
black_extra_args="--check"
fi

banner "Executing in conda environment ${CONDA_DEFAULT_ENV} in directory ${root}"
run "Unit Tests" "python -m pytest -vv -r sx pybedlite"
run "Style Checking" "black --line-length 99 $black_extra_args pybedlite"
run "Linting" "flake8 --config=$parent/flake8.cfg pybedlite"
run "Type Checking" "mypy -p pybedlite --config $parent/mypy.ini"

if [ -z "$failures" ]; then
banner "Checks Passed"
else
banner "Checks Failed with failures in: $failures"
exit 1
fi
7 changes: 7 additions & 0 deletions ci/flake8.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# flake8 config file

[flake8]
max_line_length = 100
show-source = true
ignore = E701 W504 W503
extend-ignore = E203
6 changes: 6 additions & 0 deletions ci/mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[mypy]
strict_optional = False
ignore_missing_imports = True
disallow_untyped_decorators = False
follow_imports = silent
disallow_untyped_defs = True
Loading

0 comments on commit 9c9b915

Please sign in to comment.