# SeqCore LIMS

**Laboratory information management for sequencing labs.**
`seqcore-lims.infinity-sdg.com`. An Infinity Software Development Group product built on Kalos/ADL.

```
requisition → specimen (chain of custody) → library (QC) → loading → run → analysis → report
```

## What it enforces

The rules below are enforced on the server, so no screen or API call can skip them.

- **A rejected specimen goes no further.** Rejecting one requires a reason, and only accepted specimens can become libraries.
- **A library that failed QC never reaches a run.**
- **A run's contents are fixed once it starts.**
- **No run starts on an instrument that is out of calibration.** A daily schedule also takes lapsed instruments offline.
- **A completed run under 75% Q30 is flagged for the director.**
- **Analysis starts only on a completed run.** The pipeline version is written once, and every output carries a SHA-256 checksum.
- **A report is signed only against a completed analysis.** The analyst reviews it, the director signs it, then it's released. A signed report is frozen.
- **Chain-of-custody entries are append-only.**
- **Turnaround is tracked per requisition.** The turnaround board highlights overdue work.
- **Every change is audited** with the old and new values, who made it and when.

## Resources

`client` · `requisition` · `specimen` · `custody` · `instrument` · `library` · `run` · `loading` · `analysis` · `report`

Views: **turnaroundBoard**, **runQuality**, **reportsAwaitingSignature**.
Roles: `accessioner`, `technologist`, `analyst`, `director`, `admin`.

## Demo data

Two weeks of a clinical sequencing lab:
- **Specimens:** 12 requisitions from 10 clients. One specimen was rejected (unlabeled tube) and one is still at receipt.
- **Libraries and runs:** one library failed QC. Seven runs completed (one under 75% Q30, so it's flagged), one failed, one is running and one is planned.
- **Results:** analyses are complete, and reports sit at every stage: four released, two signed, three awaiting signature, one draft.
- **Calibration:** one backup sequencer's calibration has lapsed.

Regenerate the seed with `python3 seeds/gen_seed.py`.

## Run it

This repo runs on a [Kalos](https://github.com/datajango/kalos) checkout, as one of its `*.infinity-sdg.com` sub-domain sites.

```bash
export KALOS_REPO=~/kalos        # defaults to ../kalos beside this repo
scripts/kalos.sh validate        # static checks (adlref + config + seed)
scripts/kalos.sh start           # certs + fresh DB + kalosd on :9206
scripts/kalos.sh verify          # boot, seed, exercise over TLS, stop
```

Sign in as `admin` / `Admin123!`, or as `accessioner1`, `tech1`, `analyst1` or `director1` / `Demo123!`.

## Reselling

The product is generic, with no customer names in the code or data. To brand it for a customer, change `site.json` (`host`, `slug`), the port in `config.json`, and the data in `seeds/gen_seed.py`.
