Skip to content

Commit

Permalink
Merge pull request #54 from kedhammar/ci
Browse files Browse the repository at this point in the history
Implement continous integration practices + formatting and fixes across entire repo
  • Loading branch information
remiolsen authored Jan 11, 2024
2 parents 1cf4aa8 + 9115460 commit 261284e
Show file tree
Hide file tree
Showing 16 changed files with 622 additions and 251 deletions.
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 240110, non-invasive, repo-wide formatting with ruff and prettier
7634a3bd7b150f552f064e7089b4ab160b6f4564

# 240110, safe ruff-fixes
1d308fb21d4c4d07f1d6a97d0e85d9495db80557
8 changes: 4 additions & 4 deletions .github/workflows/anglerfish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
- uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@v1
with:
init-shell: bash
create-args: >-
init-shell: bash
create-args: >-
python=${{ matrix.python-version }}
pip
environment-file: environment.yml
environment-file: environment.yml

# Install Anglerfish
- shell: bash -l {0}
Expand All @@ -29,7 +29,7 @@ jobs:
# Run anglerfish --help
- shell: bash -l {0}
name: Test anglerfish
run: |
run: |
anglerfish --help
# Run anglerfish using test data
Expand Down
99 changes: 99 additions & 0 deletions .github/workflows/lint-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: lint-code
on: [push, pull_request]

# Cancel if a newer run is started
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
# Use ruff to check for code style violations
ruff-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: ruff --> Check for style violations
# Configured in pyproject.toml
run: ruff check .

# Use ruff to check code formatting
ruff-format:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: ruff --> Check code formatting
run: ruff format --check .

# Use mypy for static type checking
mypy-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy
# Start by installing type stubs
- name: mypy --> Install stubs
run: echo -e "y" | mypy --install-types **/*.py || exit 0
- name: mypy --> Static type checking
# Configured in pyprojet.toml
run: mypy **/*.py

# Use Prettier to check various file formats
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install Prettier
run: npm install -g prettier

- name: Run Prettier --check
run: prettier --check .

# Use editorconfig to check all remaining file formats
editorconfig:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install editorconfig-checker
run: npm install -g editorconfig-checker

- name: editorconfig --> Lint files
run: editorconfig-checker $(git ls-files | grep -v '.py\|.md\|.json\|.yml\|.yaml\|.html')
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
*~
*.egg-info
.DS_Store
.benchmarks
.*_cache
node_modules
.vscode
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# .pre-commit-config.yaml
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.7.1"
hooks:
- id: mypy
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: "2.7.2"
hooks:
- id: editorconfig-checker
50 changes: 39 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Anglerfish

[![Anglerfish CI Status](https://github.com/remiolsen/anglerfish/workflows/Anglerfish/badge.svg)](https://github.com/remiolsen/anglerfish/actions)
[![PyPI](https://img.shields.io/pypi/v/bio-anglerfish)](https://pypi.python.org/pypi/bio-anglerfish/)
[![Conda (channel only)](https://img.shields.io/conda/vn/bioconda/anglerfish)](https://anaconda.org/bioconda/anglerfish)
[![Docker Container available](https://img.shields.io/docker/automated/remiolsen/anglerfish.svg)](https://hub.docker.com/r/remiolsen/anglerfish/)


## Introduction

Anglerfish is a tool designed to demultiplex Illumina libraries sequenced on Oxford Nanopore
Expand All @@ -27,31 +27,60 @@ pip install bio-anglerfish
conda install -c bioconda anglerfish
```

### Manually with Conda
### Install development version

First [install miniconda](https://docs.conda.io/en/latest/miniconda.html), then:
```
pip install --upgrade --force-reinstall git+https://github.com/remiolsen/anglerfish.git
```

## Source development

1. [Install miniconda](https://docs.conda.io/en/latest/miniconda.html).

2. Set up repo clone with editable install

```
git clone https://github.com/remiolsen/anglerfish.git
cd anglerfish
# Create a the anglerfish conda environment
conda env create -f environment.yml
# Install anglerfish
conda activate anglerfish
pip install -e .
```

### Development version
3. Install developer tools

```
pip install --upgrade --force-reinstall git+https://github.com/remiolsen/anglerfish.git
conda install --file requirements-dev-conda.txt
pip install -r requirements-dev-pip.txt
```

4. (Optional) Install pre-commit to prevent committing code that will fail linting

```
pre-commit install
```

5. (Optional) Enable automatic formatting in VS Code by creating `.vscode/settings.json` with:

```
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
},
"prettier.configPath": "./pyproject.toml"
}
```

## Usage

Anglerfish requires two files to run.

* A basecalled FASTQ file from for instance Guppy (`/path/to/ONTreads.fastq.gz`)
* A samplesheet containing the sample names and indices expected to be found in the sequencing run. (`/path/to/samples.csv`)
- A basecalled FASTQ file from for instance Guppy (`/path/to/ONTreads.fastq.gz`)
- A samplesheet containing the sample names and indices expected to be found in the sequencing run. (`/path/to/samples.csv`)

Example of a samplesheet file:

Expand Down Expand Up @@ -120,10 +149,9 @@ P54321_101,truseq,ATTACTCG,/path/to/barcode02/*.fastq.gz

In folder `anglerfish_????_??_??_?????/`

* `*.fastq.gz` Demultiplexed reads (if any)
* `anglerfish_stats.txt` Barcode statistics from anglerfish run
* `anglerfish_stats.json` Machine readable anglerfish statistics

- `*.fastq.gz` Demultiplexed reads (if any)
- `anglerfish_stats.txt` Barcode statistics from anglerfish run
- `anglerfish_stats.json` Machine readable anglerfish statistics

## Credits

Expand Down
6 changes: 3 additions & 3 deletions anglerfish/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import anglerfish
from .anglerfish import anglerfish

if __name__ == '__main__':
anglerfish()
if __name__ == "__main__":
anglerfish()
Loading

0 comments on commit 261284e

Please sign in to comment.