Metadata-Version: 2.4
Name: bonsai-prp
Version: 1.3.3
Summary: Pipline result processing program for the JASEN pipeline and Bonsai tool.
Author-email: Markus Johansson <markus.h.johansson@skane.se>, Ryan Kennedy <Ryan.Kennedy@skane.se>
Project-URL: Repository, https://github.com/Clinical-Genomics-Lund/
Project-URL: Issues, https://github.com/Clinical-Genomics-Lund/bonsai-prp/issues
Project-URL: Changelog, https://github.com/Clinical-Genomics-Lund/CHANGELOG.md
Classifier: Development Status :: 3 - Alpha
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: setuptools
Requires-Dist: wheel
Requires-Dist: click==8.1.7
Requires-Dist: pydantic
Requires-Dist: pandas==2.1.3
Requires-Dist: numpy==1.26.3
Requires-Dist: Biopython==1.83
Requires-Dist: cyvcf2==0.31.1
Requires-Dist: pysam==0.22.1
Requires-Dist: pyyaml==6.0.2
Requires-Dist: requests==2.32.3
Provides-Extra: dev
Requires-Dist: pylint~=3.0.2; extra == "dev"
Requires-Dist: black~=23.11.0; extra == "dev"
Requires-Dist: isort~=5.12.0; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest-cov~=4.1.0; extra == "test"
Requires-Dist: mypy==1.13.0; extra == "test"
Dynamic: license-file

# Pipeline result processor (PRP)

*A collection of tools for working with [JASEN](https://github.com/genomic-medicine-sweden/jasen) results or uploading it to the visualization tool [Bonsai](https://github.com/Clinical-Genomics-Lund/bonsai).*

> [!WARNING]
> Bonsai-PRP is under development in an alpha stage. Expect uneven documentation, breaking changes, and bugs until the official 1.0 release.

## Using prp

Use the help argument for information on prp's functions.

```
prp --help
```

PRP takes a file with information on the sample and paths to the individual results generated by JASEN as input. The sample file is created by default by JASEN during the analysis but can be modified or extended. An example of the input file can be found among [the test files](./tests/fixtures/saureus/sample_1.cnf.yml).

## Parse

This commands combines the JASEN output into serialized json object. This is good for backuping or computational analysis of the data.

```sh
prp parse --sample /path/to/sample.cnf.yml -o dump.json
```

### Validate output format of result json file

```
prp validate -o OUTPUT_FILE [-h]
```

### Create CDM input from pipeline data

Calculate quality metrics and present them in a format compatible with [CDM](https://github.com/SMD-Bioinformatics-Lund/cmd-data-management).

```sh
prp cdm --sample /path/to/sample.cnf.yml -o dump.json
```

## Upload a sample to Bonsai

Use the sample config to upload a sample to Bonsai.

The username and password can be set using either flags or by setting the environment variables `BONSAI_USER` and `BONSAI_PASSWD`.

```sh
prp upload                         \
  --sample /path/to/sample.cnf.yml \
  --api http://bonsai/api          \
  --username admin                 \
  --password secret                \
```

## The sample file

The sample file is generated by JASEN and catalogs the different output files. Additionally, the sample file can also contain information on how the sample should be presented in Bonsai. For example, which groups the sample should be added to or which IGV tacks should be available.

The `groups` field should be a list of the different *group_ids*. These are set when creating a group in Bonsai.

```yaml
groups:  # list of Bonsai groups to add the sample to
  - bonsai_group_id_1
  - bonsai_group_id_2
```

Use the `igv_annotations` field to add one or more IGV annoatation tracks. It should be a list of mappings, where each mapping should contian the fields `name`, `type` and `uri`. The name is the track name, the is the type of annotation track (*annotation*, *variant*, *alignment*) and URI is how to access the resource. See the [IGV documentation](https://igv.org/doc/igvjs/#tracks/Tracks/) for more information on the tracks and supported file formats.

```yaml
igv_annotations:  # list of IGV tracks
  - name: Cool variants
    type: variant
    uri: file://rs-fe1/path/to/variants.vcf
```
