Skip to content
Draft
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
55 changes: 55 additions & 0 deletions .github/workflows/piranha-installer-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Piranha Installer for Ubuntu
on:
push:
branches: [ main ]
paths:
- 'piranha-installer/**'
- './github/workflows/**'
pull_request:
branches: [ main ]

defaults:
run:
working-directory: ./piranha-installer

jobs:
build-piranha-exe:
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Install micromamba
uses: mamba-org/setup-micromamba@v2
with:
environment-file: ./piranha-installer/environment.yml
- name: Build Piranha exe
shell: bash -el {0}
run: ./scripts/build-installer
- name: Upload exe as artifact
uses: actions/upload-artifact@v4
with:
name: piranha-exe-ubuntu
path: ./piranha-installer/dist/piranha
retention-days: 1

test-piranha-exe:
needs: build-piranha-exe
runs-on: ubuntu-latest
steps:
- name: Check out source # Get source just to have access to test data and run script
uses: actions/checkout@v4
- name: Make empty dist folder # So we can run the same script as in local dev, manually create dist folder...
run: mkdir dist
- name: Download Piranha exe # ...and download the exe to it
uses: actions/download-artifact@v4
with:
name: piranha-exe-ubuntu
path:
./piranha-installer/dist
- name: Add executable permission
run: chmod u+x dist/piranha
#- name: TMATE
# uses: mxschmitt/action-tmate@v3
- name: Test Piranha exe
run: ./scripts/test-run-exe

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# piranhaNET
Typescript user interface for piranha on desktop and web

Typescript user interface for [piranha](https://github.com/polio-nanopore/piranha) on desktop and web.

### :wrench: This is a work in progress. :wrench:

We will provide a Typescript front end for piranha, which can be built and distributed as an Electron application,
or deployed as a web application.

This repo contains the following components in its directories. See the READMEs in each directory for more details:

* `piranha-installer` - a [pyinstaller](https://pyinstaller.org) project for piranha allowing it to be bundled with the
Electron app installer.
3 changes: 3 additions & 0 deletions piranha-installer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build
dist
test_results
22 changes: 22 additions & 0 deletions piranha-installer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# piranhaNET: piranha-installer

[Pyinstaller](https://pyinstaller.org) project for piranha.

`piranha.spec` defines the installer configuration.

### Pre-requisites
* [micromamba](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html)

### Development

Run all commands from this folder.

Create a local conda environment (you only need to do this once): `micromamba env create --file environment.yml`

Activate the conda environment: `micromamba activate piranha-installer`

Build piranha to an executable with pyinstaller: `./scripts/build-installer`

Run the executable on test data: `./scripts/test-run-exe`

To add a new dependency, update environment.yml then run: `micromamba env update --file environment.yml`
22 changes: 22 additions & 0 deletions piranha-installer/entrypoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import subprocess
import sys
from piranha import command

name, *args = sys.argv

# Decide from args whether this is the top level entrypoint to a
# piranha run, or an invocation of snakemake.
# (This is needed because snakemake uses sys.executable to launch
# new workflows, expecting the exe to be python or python3, but that
# is not the case when running from this executable!)
if (args[0] == "-m" and args[1] == "snakemake"):
# Run snakemake
subprocess.run(
["python3", *args],
stdout=sys.stdout,
stderr=sys.stdout,
check=True,
)
else:
# Run piranha
command.main(args)
13 changes: 13 additions & 0 deletions piranha-installer/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: piranha-installer
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- conda
- medaka=1.11.3
- piranha-polio
- python
- snakemake
- pyinstaller
- tzdata=2025a # 2025c and latest 2025b breaks pyinstaller!
49 changes: 49 additions & 0 deletions piranha-installer/piranha.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# -*- mode: python ; coding: utf-8 -*-

from conda.core.envs_manager import list_all_known_prefixes

# Get the root of the installed piranha package in order to copy data files etc into the installer
env_root = list(filter(lambda prefix: prefix.endswith("piranha-installer"), list_all_known_prefixes()))[-1]
python_version = "3.9"
piranha_package_root = "{env_root}/lib/python{python_version}/site-packages/piranha/".format(env_root = env_root, python_version = python_version)

a = Analysis(
['entrypoint.py'],
pathex=[],
binaries=[],
datas=[
(piranha_package_root + 'scripts', './piranha/scripts'),
(piranha_package_root + 'analysis', './piranha/analysis'),
(piranha_package_root + 'data', './piranha/data')

],
hiddenimports=[
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)

pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='piranha',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
4 changes: 4 additions & 0 deletions piranha-installer/scripts/build-installer
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -ex

pyinstaller piranha.spec --noconfirm
6 changes: 6 additions & 0 deletions piranha-installer/scripts/test-run-exe
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -ex

out_dir=test_results
rm -rf $out_dir
./dist/piranha -i test_data/demultiplexed -b test_data/barcodes.csv -pc Pos1,P2 -nc "my negative control" -o $out_dir --verbose
8 changes: 8 additions & 0 deletions piranha-installer/test_data/barcodes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
barcode,sample,date,well
barcode01,MixedTest,2022-01-01,A01
barcode02,PureTest,2022-01-02,B01
barcode03,WTTest,2022-01-07,C01
barcode04,VDPVTest,2022-01-05,D05
barcode05,negative,,D06
barcode06,positively,,D07
barcode07,somemixed,2022-03-01,H12
Loading
Loading