Skip to content

About

Lightweight LIMS (alpha) for NGS workflows in molecular pathology. Not a medical device; login not fully developed yet – run locally with fictitious data only.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

molpath-lims

A data model for NGS workflows in molecular pathology, and a lightweight LIMS built on it with Django.

Status: alpha (0.1.0). The core workflow works, but the software is unfinished: there are still known errors, and some tables and relations in the data model are not fully consistent yet. It is a personal project. It is not a medical device and has not been validated for diagnostic use. No maintenance or support is promised. See Known limitations.

Security warning: The login is not fully developed yet. Signing in and a user area with roles are prepared, but the lab pages do not require a login yet. Anyone who can reach the server can therefore read and change all data. Run it only locally, with fictitious data, and never expose it to a network.

Data model

The database is the core of the project. It follows a sample from intake through sectioning, DNA/RNA isolation, library preparation and sequencing loading, and records which reagent lots were used on the way. The reference is labor/models.py (Django ORM, MySQL); the tables are named in upper case, for example PROCESSSTEP for the model ProcessStep.

Samples

erDiagram
    PATIENT ||--o{ SAMPLE : "has"
    DIAGNOSIS ||--o{ SAMPLE : "classifies"
    SAMPLE ||--o{ SAMPLE_PANEL : ""
    PANEL ||--o{ SAMPLE_PANEL : ""
    SAMPLE ||--o{ SAMPLE_METHOD : ""
    METHOD ||--o{ SAMPLE_METHOD : ""
    SAMPLE ||--o{ PROCESSSTEP : "goes through"

    PATIENT {
        string patient_id PK
        string last_name
        string first_name
        date birth_date
        string gender "male, female, diverse"
    }
    DIAGNOSIS {
        int diagnosis_id PK
        string diagnosis_name UK
        string icd_10_code
        string icd_o_code
    }
    SAMPLE {
        int sample_id PK
        string internal_id UK
        string hist_sample_id
        date entry_date
        string material_type "FFPE, LB, FRESH"
        decimal tumor_content "required unless LB"
        string patient_id FK
        int diagnosis_id FK
    }
    PANEL {
        int panel_id PK
        string panel_name UK
    }
    METHOD {
        int method_id PK
        string method_name UK
        string method_type
    }
    SAMPLE_PANEL {
        int sample_id FK "unique together"
        int panel_id FK "unique together"
    }
    SAMPLE_METHOD {
        int sample_id FK "unique together"
        int method_id FK "unique together"
    }
Loading

Workflow steps (one table per station)

erDiagram
    SAMPLE ||--o{ PROCESSSTEP : "goes through"
    EMPLOYEE ||--o{ PROCESSSTEP : "performs"
    PROCESSSTEP ||--o| SECTIONING : "is a"
    PROCESSSTEP ||--o| ISOLATION : "is a"
    PROCESSSTEP ||--o| LIBRARY_PREP : "is a"
    PROCESSSTEP ||--o| SEQUENCING_LOADING : "is a"
    SEQUENCINGRUN ||--o{ LIBRARY_PREP : "contains"
    PANEL |o--o{ LIBRARY_PREP : "used in"
    DEVICE ||--o{ SEQUENCINGRUN : "runs"

    PROCESSSTEP {
        bigint id PK
        int sample_id FK "unique together"
        string step_type "unique together"
        string nucleic_acid_type "DNA, RNA, NONE; unique together"
        date step_date
        string initials FK
    }
    SECTIONING {
        bigint processstep_ptr_id PK, FK
        int section_count
    }
    ISOLATION {
        bigint processstep_ptr_id PK, FK
        decimal concentration
        bool negative_control_ltb
    }
    LIBRARY_PREP {
        bigint processstep_ptr_id PK, FK
        string run_id FK
        int panel_id FK "nullable"
        string library_mode
        string index_i7
        string index_i5
        decimal input_ng
    }
    SEQUENCING_LOADING {
        bigint processstep_ptr_id PK, FK
        decimal molarity_nm
        bigint reads
    }
    SEQUENCINGRUN {
        string run_id PK
        date run_date
        string inventory_number FK
    }
    DEVICE {
        string inventory_number PK
        string device_name
    }
    EMPLOYEE {
        string initials PK
        string last_name
        string first_name
        bool active
    }
Loading

Reagents and lot traceability (PROCESSSTEP and EMPLOYEE as above)

erDiagram
    PROCESSSTEP ||--o{ USES_REAGENT : "uses"
    REAGENT_LOT ||--o{ USES_REAGENT : "used in"
    REAGENT ||--o{ REAGENT_LOT : "has"
    EMPLOYEE ||--o{ STATION_RUN : "performs"
    STATION_RUN ||--o{ STATION_REAGENT_USAGE : "uses"
    REAGENT_LOT ||--o{ STATION_REAGENT_USAGE : "used in"
    REAGENT ||--o{ STOCK_MOVEMENT : "has"
    EMPLOYEE |o--o{ STOCK_MOVEMENT : "books"

    USES_REAGENT {
        bigint process_step_id FK "unique together"
        string lot_id FK "unique together"
        decimal quantity_used
        string unit
    }
    REAGENT_LOT {
        string lot_id PK
        string article_number FK
        date expiry_date
    }
    REAGENT {
        string article_number PK
        string reagent_name
        int current_stock
        int minimum_stock
    }
    STATION_RUN {
        int station_run_id PK
        string step_type
        date run_date
        string initials FK
    }
    STATION_REAGENT_USAGE {
        int run_id FK "unique together"
        string lot_id FK "unique together"
        decimal quantity_used
        string unit
    }
    STOCK_MOVEMENT {
        int movement_id PK
        string article_number FK
        string movement_type "IN, OUT"
        int quantity "greater than 0"
        string performed_by FK "nullable"
    }
Loading

The diagrams show the core tables with their keys and main columns. Left out are DOCUMENT and CALENDAR_EVENT (staff area), the employee who did the sex check in LIBRARY_PREP, and the surrogate id of the join and usage tables.

Design ideas:

  • One table per station. ProcessStep is a concrete base table. Sectioning, Isolation, LibraryPrep and SequencingLoading inherit from it (Django multi-table inheritance) and share its primary key; each subtype sets the step_type discriminator in save(). Sample, date and employee are stored once in PROCESSSTEP, and reagent usage can refer to any step.
  • DNA and RNA per step. nucleic_acid_type is DNA, RNA or NONE; sectioning is sample-wide (NONE). Sample, step type and nucleic acid together are unique, so each station is recorded at most once per sample and nucleic acid.
  • Lot traceability. USES_REAGENT links a step to the reagent lots used for it. Batch entries record the lots once per station run (STATION_RUN, STATION_REAGENT_USAGE) for all samples processed together; a station run is not linked to the individual samples. Recording usage does not change the stock. A stock booking updates REAGENT.current_stock and writes a STOCK_MOVEMENT row in one transaction; editing a reagent can also set the stock directly, without a movement row.
  • Panels and methods per sample through the join tables SAMPLE_PANEL and SAMPLE_METHOD. A library prep can also name its panel (nullable, for older entries without one).
  • Employees by initials. The primary key of EMPLOYEE is the employee's initials, and steps, station runs, stock movements, documents and calendar events refer to it.
  • Patient → sample → diagnosis. Each sample belongs to one patient and has one diagnosis (ICD-10 and ICD-O codes optional). The tumour content is required except for liquid biopsies (check constraint). The status of a sample is not stored; it is derived from the recorded steps.

More on the data model:

  • Interactive schema graph of all models, including Django's own tables: http://127.0.0.1:8000/schema/ (django-schema-graph), see the screenshot.
  • MolPat-Physical-Schema-MySQL.erdplus: the physical MySQL schema as of 21 June 2026 (open with erdplus.com). It matches labor/models.py except for the later tables STATION_RUN and STATION_REAGENT_USAGE and the columns panel_id and library_mode in LIBRARY_PREP.
  • MolPat-Relational Schema.erdplus: the initial relational design. It also contains modules that were not implemented, such as roles and permissions, announcements, notifications, device maintenance and proficiency tests.
  • Workflow.txt: a fictitious example of the lab workflow the data model is based on (in German).

What it does

  • Sample intake: patient, diagnosis, panel, tumour content, histology and internal sample IDs.
  • Workflow tracking: sectioning, DNA/RNA isolation, library preparation and sequencing loading. Each step can be entered for a single sample or as a batch, and the status of every sample is shown.
  • Library prep calculator: dilution, DNA and water volumes and input amount.
  • Inventory: reagents with lots, stock bookings, movement history and usage per sample or per station run; devices.
  • Staff and organisation: employees, a user area (sign-in status and roles), document upload and a calendar.
  • Dashboard and an admin interface for master data.
  • German user interface with English translation, light and dark mode. The seeded diagnosis list is German.
  • Server-rendered HTML without JavaScript in the lab interface (the admin uses JavaScript). No client-side code and no external resources are loaded in the browser, which keeps the attack surface small. The templates contain no inline scripts or styles, so a strict Content Security Policy (built into Django 6) could block all scripts; it is not configured yet.

Screenshots

Fictitious demo data, English interface, light and dark mode.

Dashboard
Dashboard
Sample overview
Sample overview (dark mode)
Sample detail
Sample detail with workflow status
Library prep entry
Library prep entry with volume calculator (dark mode)
Reagents
Reagents and stock
Calendar
Calendar (dark mode)

Known limitations

  • The login is not fully developed yet: you can sign in through the admin login page and the user area shows your roles, but the lab pages do not require a login or check permissions, and employees are not yet linked to user accounts. Only the admin at /admin/ requires a login.
  • No audit trail of changes.
  • No management of results or reports.
  • No exports (for example sample sheets) and no barcodes or labels.
  • Development settings only (DEBUG = True, empty ALLOWED_HOSTS); there is no production configuration.
  • Some design decisions are still open, for example whether the panel is a required field.
  • Developed on Windows; other platforms have not been tested.

Requirements

  • Python 3.12 or newer
  • MySQL or MariaDB in a version supported by Django 6.0
  • The Python packages in requirements.txt

Setup

python -m venv venv
# Windows: venv\Scripts\activate    Linux/macOS: source venv/bin/activate
pip install -r requirements.txt
cp mein_config/local_settings.example.py mein_config/local_settings.py

Edit mein_config/local_settings.py: set your own SECRET_KEY and your database settings. Create the database first, for example:

CREATE DATABASE lims_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Then:

python manage.py migrate
python manage.py createsuperuser
python manage.py runserver

Open http://127.0.0.1:8000/ for the lab interface and http://127.0.0.1:8000/admin/ for the admin.

Optional demo data (fictitious; demo sample IDs start with DEMO-; only runs with DEBUG = True):

python tools/seed_demo.py

Development

  • Tests: python manage.py test frontend (the database user needs permission to create the test database).
  • Translations: edit locale/en/LC_MESSAGES/django.po, then run python tools/compile_messages.py (pure Python, no gettext needed).
  • CSS: frontend/static/frontend/css/app.css is built with the Tailwind CSS standalone CLI v3, which is not included: tailwindcss -c tailwind.config.js -i frontend/static_src/input.css -o frontend/static/frontend/css/app.css --minify

Project layout: labor/ contains the data model and admin, frontend/ the lab interface, mein_config/ the project settings.

Disclaimer

This software is provided "as is", without any warranty (see LICENSE). It is not a medical device under the EU In Vitro Diagnostic Medical Devices Regulation (IVDR), it has not been validated, and it must not be used for diagnostics or patient care. Any laboratory that uses it is responsible for validation and for compliance with data protection law. Do not store real patient data in this software.

License

MIT, see LICENSE.

About

Lightweight LIMS (alpha) for NGS workflows in molecular pathology. Not a medical device; login not fully developed yet – run locally with fictitious data only.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages