Skip to content

Commit 3945017

Browse files
authored
Merge pull request #13 from ssjunnebo/documentation
Documentation
2 parents 41780b0 + afe4d61 commit 3945017

3 files changed

Lines changed: 213 additions & 10 deletions

File tree

LICENCE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2026 Sara Sjunnebo
2+
3+
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:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
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.

README.md

Lines changed: 202 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,202 @@
1-
# dataflow_transfer
2-
A tool for transferring sequencing data from NAS to HPC
3-
4-
## Status Files
5-
The logic of the script relies on the following status files
6-
- run.final_file
7-
- The final file written by each sequencing machine. Used to indicate when the sequencing has completed.
8-
- final_rsync_exitcode
9-
- 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.
10-
"""
1+
# Dataflow Transfer
2+
3+
A Python application for automating the transfer of sequencing data.
4+
5+
## Overview
6+
7+
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.
8+
9+
## Supported Sequencers
10+
11+
- **Illumina**: NextSeq, MiSeqi100, NovaSeqXPlus (WIP), MiSeq (WIP)
12+
- **Oxford Nanopore (ONT)**: PromethION (WIP), MinION (WIP)
13+
- **Element**: AVITI (WIP)
14+
15+
## Installation
16+
17+
### Requirements
18+
19+
- Python 3.11+
20+
- Dependencies listed in [requirements.txt](requirements.txt):
21+
- PyYAML
22+
- click
23+
- xmltodict
24+
- ibmcloudant
25+
- [run-one](https://launchpad.net/ubuntu/+source/run-one)
26+
27+
### Setup suggestions
28+
29+
1. Clone the repository:
30+
31+
```bash
32+
git clone <repository-url>
33+
cd dataflow_transfer
34+
```
35+
36+
2. Install the package:
37+
38+
```bash
39+
pip install -e .
40+
```
41+
42+
Or with development dependencies:
43+
44+
```bash
45+
pip install -e ".[dev]"
46+
```
47+
48+
## Usage
49+
50+
### Command Line Interface
51+
52+
```bash
53+
dataflow_transfer [OPTIONS]
54+
```
55+
56+
#### Options
57+
58+
- `-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.
59+
- `-r, --run RUN_ID`: Transfer a specific run (e.g., `20250528_LH00217_0219_A22TT52LT4`). Requires `--sequencer`.
60+
- `-s, --sequencer TYPE`: Sequencer type of the run (e.g., `NovaSeqXPlus`, `MiSeq`, `AVITI`). Required with `--run`.
61+
- `--version`: Show version and exit.
62+
63+
#### Examples
64+
65+
```bash
66+
# Transfer all runs (uses configuration for sequencing directories)
67+
dataflow_transfer
68+
69+
# Transfer a specific run
70+
dataflow_transfer --run 20250528_LH00217_0219_A22TT52LT4 --sequencer NovaSeqXPlus
71+
72+
# Use a custom config file
73+
dataflow_transfer --config-file /path/to/config.yaml
74+
```
75+
76+
## Configuration
77+
78+
Create a YAML configuration file with the following structure:
79+
80+
```yaml
81+
log:
82+
file: /path/to/dataflow_transfer.log
83+
84+
run_one_path: /usr/bin/run-one
85+
86+
transfer_details:
87+
user: username
88+
host: remote.host.com
89+
90+
statusdb:
91+
username: couchdb_user
92+
password: couchdb_password
93+
url: couchdb.host.com
94+
database: sequencing_runs
95+
96+
sequencers:
97+
NovaSeqXPlus:
98+
sequencing_path: /sequencing/NovaSeqXPlus
99+
miarka_destination: /Illumina/NovaSeqXPlus
100+
metadata_for_statusdb:
101+
- RunInfo.xml
102+
- RunParameters.xml
103+
ignore_folders:
104+
- nosync
105+
rsync_options:
106+
- --chmod=Dg+s,g+rw
107+
# ... additional sequencer configurations
108+
```
109+
110+
## How It Works
111+
112+
1. **Discovery**: Scans configured sequencing directories for run folders
113+
2. **Validation**: Confirms run ID matches expected format for the sequencer type
114+
3. **Transfer Phases**:
115+
- **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.
116+
- **Final Transfer**: After sequencing completes (final sequencing file appears), initiates final rsync transfer and captures exit code.
117+
- **Completion**: Updates database when transfer was successful.
118+
119+
### Status Tracking
120+
121+
Run status is tracked in CouchDB with events including:
122+
123+
| Status | Meaning | Occurs when |
124+
| ------------------------ | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
125+
| `sequencing_started` | Sequencing is ongoing | A run folder exists but the final sequencing file has not been created yet |
126+
| `transfer_started` | Intermediate transfer was initiated | Sequencing is ongoing and an rsync has been started |
127+
| `sequencing_finished` | Sequencing has completed | A run folder exists and the final sequencing file has been created |
128+
| `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 |
129+
| `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 |
130+
131+
### Flow chart
132+
133+
![Flow chart for Dataflow transfer](/docs/Dataflow_Transfer_flowchart.svg)
134+
135+
### Key Components
136+
137+
- **[`dataflow_transfer/run_classes/`](dataflow_transfer/run_classes/)**: Sequencer-specific run classes
138+
- **[`dataflow_transfer/utils/filesystem.py`](dataflow_transfer/utils/filesystem.py)**: File operations and rsync handling
139+
- **[`dataflow_transfer/utils/statusdb.py`](dataflow_transfer/utils/statusdb.py)**: CouchDB session management with retry logic
140+
- **[`dataflow_transfer/cli.py`](dataflow_transfer/cli.py)**: Command-line interface
141+
142+
## Assumptions
143+
144+
- Run directories are named according to sequencer-specific ID formats (defined in run classes)
145+
- Final completion is indicated by the presence of a sequencer-specific final file (e.g., `RTAComplete.txt` for Illumina)
146+
- Remote storage is accessible via rsync over SSH
147+
- CouchDB is accessible and the database exists
148+
- Metadata files (e.g., RunInfo.xml) are present in run directories for status database updates
149+
150+
### Status Files
151+
152+
The logic of the script relies on the following status files:
153+
154+
- `run.final_file` - The final file written by each sequencing machine. Used to indicate when the sequencing has completed.
155+
- `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.
156+
157+
## Development
158+
159+
### Running Tests
160+
161+
```bash
162+
pytest
163+
```
164+
165+
With coverage:
166+
167+
```bash
168+
pytest --cov --cov-branch
169+
```
170+
171+
### Code Quality
172+
173+
Run linting and formatting checks:
174+
175+
```bash
176+
ruff check .
177+
ruff format --check .
178+
```
179+
180+
### Project Structure
181+
182+
```
183+
dataflow_transfer/
184+
├── cli.py # Command-line interface
185+
├── dataflow_transfer.py # Main transfer orchestration
186+
├── log/ # Logging utilities
187+
├── run_classes/ # Sequencer-specific run classes
188+
├── utils/ # Utility modules (filesystem, statusdb)
189+
└── tests/ # Unit tests
190+
```
191+
192+
### Adding a new sequencer
193+
194+
To add support for a new sequencer, add the following to dataflow_transfer:
195+
196+
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)
197+
- `dataflow_transfer/run_classes/illumina_runs.py`
198+
- `dataflow_transfer/run_classes/element_runs.py`
199+
- `dataflow_transfer/run_classes/ont_runs.py`
200+
2. Import the new class in `dataflow_transfer/run_classes/__init__.py`
201+
3. Add a test fixture for the new run in `dataflow_transfer/tests/test_run_classes.py` and include it in the relevant tests
202+
4. Add a section for the sequencer in the config file

0 commit comments

Comments
 (0)