From 65984b6a6a9b235f6909cd1d618cc15818cfecb2 Mon Sep 17 00:00:00 2001 From: ssjunnebo Date: Fri, 6 Feb 2026 11:40:06 +0100 Subject: [PATCH 1/4] Add MIT licence --- LICENCE | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 LICENCE diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..2221c43 --- /dev/null +++ b/LICENCE @@ -0,0 +1,7 @@ +Copyright 2026 Sara Sjunnebo + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file From 61a7d57cb5bbfcf844533782e4800510187aaf00 Mon Sep 17 00:00:00 2001 From: ssjunnebo Date: Fri, 6 Feb 2026 11:40:56 +0100 Subject: [PATCH 2/4] Improve documentation --- README.md | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 213 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 35bb521..f539b8f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,213 @@ -# dataflow_transfer -A tool for transferring sequencing data from NAS to HPC - -## Status Files -The logic of the script relies on the following status files - - run.final_file - - The final file written by each sequencing machine. Used to indicate when the sequencing has completed. - - final_rsync_exitcode - - Used to indicate when the final rsync is done, so that the final rsync can be run in the background. This is especially useful for restarts after long pauses of the cronjob. -""" \ No newline at end of file +# Dataflow Transfer + +A Python application for automating the transfer of sequencing data. + +## Overview + +Dataflow Transfer monitors sequencing run directories and orchestrates the transfer of sequencing data via rsync. It supports multiple sequencer types (Illumina, Oxford Nanopore and Element), tracks transfer progress in a CouchDB-based status database, and handles both continuous and final transfer phases during and after sequencing completion. + +## Supported Sequencers + +- **Illumina**: NextSeq, MiSeqi100, NovaSeqXPlus (WIP), MiSeq (WIP) +- **Oxford Nanopore (ONT)**: PromethION (WIP), MinION (WIP) +- **Element**: AVITI (WIP) + +## Installation + +### Requirements + +- Python 3.11+ +- Dependencies listed in [requirements.txt](requirements.txt): + - PyYAML + - click + - xmltodict + - ibmcloudant +- [run-one](https://launchpad.net/ubuntu/+source/run-one) + +### Setup suggestions + +1. Clone the repository: + +```bash +git clone +cd dataflow_transfer +``` + +2. Install the package: + +```bash +pip install -e . +``` + +Or with development dependencies: + +```bash +pip install -e ".[dev]" +``` + +## Usage + +### Command Line Interface + +```bash +dataflow_transfer [OPTIONS] +``` + +#### Options + +- `-c, --config-file PATH`: Path to configuration YAML file. Defaults to `~/.df_transfer/df_transfer.yaml`. Can also be set via `TRANSFER_CONFIG` environment variable. +- `-r, --run RUN_ID`: Transfer a specific run (e.g., `20250528_LH00217_0219_A22TT52LT4`). Requires `--sequencer`. +- `-s, --sequencer TYPE`: Sequencer type of the run (e.g., `NovaSeqXPlus`, `MiSeq`, `AVITI`). Required with `--run`. +- `--version`: Show version and exit. + +#### Examples + +```bash +# Transfer all runs (uses configuration for sequencing directories) +dataflow_transfer + +# Transfer a specific run +dataflow_transfer --run 20250528_LH00217_0219_A22TT52LT4 --sequencer NovaSeqXPlus + +# Use a custom config file +dataflow_transfer --config-file /path/to/config.yaml +``` + +## Configuration + +Create a YAML configuration file with the following structure: + +```yaml +log: + file: /path/to/dataflow_transfer.log + +run_one_path: /usr/bin/run-one + +transfer_details: + user: username + host: remote.host.com + +statusdb: + username: couchdb_user + password: couchdb_password + url: couchdb.host.com + database: sequencing_runs + +sequencers: + NovaSeqXPlus: + sequencing_path: /sequencing/NovaSeqXPlus + miarka_destination: /Illumina/NovaSeqXPlus + metadata_for_statusdb: + - RunInfo.xml + - RunParameters.xml + ignore_folders: + - nosync + rsync_options: + - --chmod=Dg+s,g+rw + # ... additional sequencer configurations +``` + +## How It Works + +### Run Processing Pipeline + +1. **Discovery**: Scans configured sequencing directories for run folders +2. **Validation**: Confirms run ID matches expected format for the sequencer type +3. **Transfer Phases**: + - **Sequencing Phase**: Starts continuous background rsync transfer while sequencing is ongoing (when the final sequencing file doesn't exist). Uploads status and metadata files (`metadata_for_statusdb`) to database. + - **Final Transfer**: After sequencing completes (final sequencing file appears), initiates final rsync transfer and captures exit code. + - **Completion**: Updates database when transfer succeeds. + +### Status Tracking + +Run status is tracked in CouchDB with events including: + +**Status:** `sequencing_started` +**Meaning:** Sequencing is ongoing +**Occurs when:** A run folder exists but the final sequencing file has not been created yet + +**Status:** `transfer_started` +**Meaning:** Intermediate transfer was initiated +**Occurs when:** A run folder exists but the final sequencing file has not been created yet. + +**Status:** `sequencing_finished` +**Meaning:** Sequencing has completed +**Occurs when:** A run folder exists and the final sequencing file has been created + +**Status:** `final_transfer_started` +**Meaning:** Final sync has started +**Occurs when:** A run folder exists and the final sequencing file has been created, but the final rsync exit code file has not yet been created or contains a non-zero exit code + +**Status:** `transferred_to_hpc` +**Meaning:** Transfer completed successfully +**Occurs when:** A run folder exists, the final sequencing file has been created, and the final rsync exit code file contains a 0 exit code + +### Key Components + +- **[`dataflow_transfer/run_classes/`](dataflow_transfer/run_classes/)**: Sequencer-specific run classes +- **[`dataflow_transfer/utils/filesystem.py`](dataflow_transfer/utils/filesystem.py)**: File operations and rsync handling +- **[`dataflow_transfer/utils/statusdb.py`](dataflow_transfer/utils/statusdb.py)**: CouchDB session management with retry logic +- **[`dataflow_transfer/cli.py`](dataflow_transfer/cli.py)**: Command-line interface + +## Assumptions + +- Run directories are named according to sequencer-specific ID formats (defined in run classes) +- Final completion is indicated by the presence of a sequencer-specific final file (e.g., `RTAComplete.txt` for Illumina) +- Remote storage is accessible via rsync over SSH +- CouchDB is accessible and the database exists +- Metadata files (e.g., RunInfo.xml) are present in run directories for status database updates + +### Status Files + +The logic of the script relies on the following status files: + +- run.final_file + - The final file written by each sequencing machine. Used to indicate when the sequencing has completed. +- final_rsync_exitcode - Used to indicate when the final rsync is done, so that the final rsync can be run in the background. This is especially useful for restarts after long pauses of the cronjob. + +## Development + +### Running Tests + +```bash +pytest +``` + +With coverage: + +```bash +pytest --cov --cov-branch +``` + +### Code Quality + +Run linting and formatting checks: + +```bash +ruff check . +ruff format --check . +``` + +### Project Structure + +``` +dataflow_transfer/ +├── cli.py # Command-line interface +├── dataflow_transfer.py # Main transfer orchestration +├── log/ # Logging utilities +├── run_classes/ # Sequencer-specific run classes +├── utils/ # Utility modules (filesystem, statusdb) +└── tests/ # Unit tests +``` + +### Adding a new sequencer + +To add support for a new sequencer, add the following to dataflow_transfer: + +1. Add a new class for the sequencer in one of the run classes files below. Make sure it inherits from the manufacturer class (IlluminaRun, ElementRun, ONTRun) + a. `dataflow_transfer/run_classes/illumina_runs.py` + b. `dataflow_transfer/run_classes/element_runs.py` + c. `dataflow_transfer/run_classes/ont_runs.py` +2. Import the new class in `dataflow_transfer/run_classes/__init__.py` +3. Add a test fixture for the new run in `dataflow_transfer/tests/test_run_classes.py` and include it in the relevant tests +4. Add a section for the sequencer in the config file From b09d3b58f41d0ef937af2ee1c32c120110129ead Mon Sep 17 00:00:00 2001 From: ssjunnebo Date: Fri, 6 Feb 2026 13:22:44 +0100 Subject: [PATCH 3/4] Add a flow chart --- README.md | 4 ++++ docs/Dataflow_Transfer_flowchart.svg | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 docs/Dataflow_Transfer_flowchart.svg diff --git a/README.md b/README.md index f539b8f..36a3d64 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,10 @@ The logic of the script relies on the following status files: - The final file written by each sequencing machine. Used to indicate when the sequencing has completed. - final_rsync_exitcode - Used to indicate when the final rsync is done, so that the final rsync can be run in the background. This is especially useful for restarts after long pauses of the cronjob. +### Flow chart + +![Flow chart for Dataflow transfer](/docs/Dataflow_Transfer_flowchart.svg) + ## Development ### Running Tests diff --git a/docs/Dataflow_Transfer_flowchart.svg b/docs/Dataflow_Transfer_flowchart.svg new file mode 100644 index 0000000..0b690b7 --- /dev/null +++ b/docs/Dataflow_Transfer_flowchart.svg @@ -0,0 +1,4 @@ + + + +
Is the final rsync exit status 0 and is transferred_to_hpc True in StatusDB? 
Is the final rsync exit status...
Does the final sequencing file exist?
Does the final seque...
Transfer is done. Do nothing.
Transfer is done. Do...
Yes
Yes
No
No
Update Status DB (sequencing_started)
Start transfer (transfer_started)
Update Status DB (sequencing_started)...
Is the final rsync exit status 0?
Is the final rsync...
Yes
Yes
No
No
Transfer is done. 
Update StatusDB (transferred_to_hpc)
Transfer is done....
Update Status DB (sequencing_finished)
Start final transfer (final_transfer_started)
Update Status DB (sequencing_finished)...
Yes
Yes
No
No
\ No newline at end of file From afe4d61241e87d676313d63efbf9f08897b2a062 Mon Sep 17 00:00:00 2001 From: ssjunnebo Date: Fri, 6 Feb 2026 13:38:13 +0100 Subject: [PATCH 4/4] Formatting --- README.md | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 36a3d64..dee265c 100644 --- a/README.md +++ b/README.md @@ -109,38 +109,28 @@ sequencers: ## How It Works -### Run Processing Pipeline - 1. **Discovery**: Scans configured sequencing directories for run folders 2. **Validation**: Confirms run ID matches expected format for the sequencer type 3. **Transfer Phases**: - - **Sequencing Phase**: Starts continuous background rsync transfer while sequencing is ongoing (when the final sequencing file doesn't exist). Uploads status and metadata files (`metadata_for_statusdb`) to database. + - **Sequencing Phase**: Starts continuous background rsync transfer while sequencing is ongoing (when the final sequencing file doesn't exist). Uploads status and metadata files (specified for each sequencer type in the config with `metadata_for_statusdb`) to database. - **Final Transfer**: After sequencing completes (final sequencing file appears), initiates final rsync transfer and captures exit code. - - **Completion**: Updates database when transfer succeeds. + - **Completion**: Updates database when transfer was successful. ### Status Tracking Run status is tracked in CouchDB with events including: -**Status:** `sequencing_started` -**Meaning:** Sequencing is ongoing -**Occurs when:** A run folder exists but the final sequencing file has not been created yet - -**Status:** `transfer_started` -**Meaning:** Intermediate transfer was initiated -**Occurs when:** A run folder exists but the final sequencing file has not been created yet. - -**Status:** `sequencing_finished` -**Meaning:** Sequencing has completed -**Occurs when:** A run folder exists and the final sequencing file has been created +| Status | Meaning | Occurs when | +| ------------------------ | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `sequencing_started` | Sequencing is ongoing | A run folder exists but the final sequencing file has not been created yet | +| `transfer_started` | Intermediate transfer was initiated | Sequencing is ongoing and an rsync has been started | +| `sequencing_finished` | Sequencing has completed | A run folder exists and the final sequencing file has been created | +| `final_transfer_started` | Final sync has started | A run folder exists and the final sequencing file has been created, but the final rsync exit code file has not yet been created or contains a non-zero exit code | +| `transferred_to_hpc` | Transfer completed successfully | A run folder exists, the final sequencing file has been created, and the final rsync exit code file contains a 0 exit code | -**Status:** `final_transfer_started` -**Meaning:** Final sync has started -**Occurs when:** A run folder exists and the final sequencing file has been created, but the final rsync exit code file has not yet been created or contains a non-zero exit code +### Flow chart -**Status:** `transferred_to_hpc` -**Meaning:** Transfer completed successfully -**Occurs when:** A run folder exists, the final sequencing file has been created, and the final rsync exit code file contains a 0 exit code +![Flow chart for Dataflow transfer](/docs/Dataflow_Transfer_flowchart.svg) ### Key Components @@ -161,13 +151,8 @@ Run status is tracked in CouchDB with events including: The logic of the script relies on the following status files: -- run.final_file - - The final file written by each sequencing machine. Used to indicate when the sequencing has completed. -- final_rsync_exitcode - Used to indicate when the final rsync is done, so that the final rsync can be run in the background. This is especially useful for restarts after long pauses of the cronjob. - -### Flow chart - -![Flow chart for Dataflow transfer](/docs/Dataflow_Transfer_flowchart.svg) +- `run.final_file` - The final file written by each sequencing machine. Used to indicate when the sequencing has completed. +- `final_rsync_exitcode` - Used to indicate when the final rsync is done, so that the final rsync can be run in the background. This is especially useful for restarts after long pauses of the cronjob. ## Development @@ -209,9 +194,9 @@ dataflow_transfer/ To add support for a new sequencer, add the following to dataflow_transfer: 1. Add a new class for the sequencer in one of the run classes files below. Make sure it inherits from the manufacturer class (IlluminaRun, ElementRun, ONTRun) - a. `dataflow_transfer/run_classes/illumina_runs.py` - b. `dataflow_transfer/run_classes/element_runs.py` - c. `dataflow_transfer/run_classes/ont_runs.py` + - `dataflow_transfer/run_classes/illumina_runs.py` + - `dataflow_transfer/run_classes/element_runs.py` + - `dataflow_transfer/run_classes/ont_runs.py` 2. Import the new class in `dataflow_transfer/run_classes/__init__.py` 3. Add a test fixture for the new run in `dataflow_transfer/tests/test_run_classes.py` and include it in the relevant tests 4. Add a section for the sequencer in the config file