Skip to content

Commit 61a7d57

Browse files
committed
Improve documentation
1 parent 65984b6 commit 61a7d57

1 file changed

Lines changed: 213 additions & 10 deletions

File tree

README.md

Lines changed: 213 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,213 @@
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+
### Run Processing Pipeline
113+
114+
1. **Discovery**: Scans configured sequencing directories for run folders
115+
2. **Validation**: Confirms run ID matches expected format for the sequencer type
116+
3. **Transfer Phases**:
117+
- **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.
118+
- **Final Transfer**: After sequencing completes (final sequencing file appears), initiates final rsync transfer and captures exit code.
119+
- **Completion**: Updates database when transfer succeeds.
120+
121+
### Status Tracking
122+
123+
Run status is tracked in CouchDB with events including:
124+
125+
**Status:** `sequencing_started`
126+
**Meaning:** Sequencing is ongoing
127+
**Occurs when:** A run folder exists but the final sequencing file has not been created yet
128+
129+
**Status:** `transfer_started`
130+
**Meaning:** Intermediate transfer was initiated
131+
**Occurs when:** A run folder exists but the final sequencing file has not been created yet.
132+
133+
**Status:** `sequencing_finished`
134+
**Meaning:** Sequencing has completed
135+
**Occurs when:** A run folder exists and the final sequencing file has been created
136+
137+
**Status:** `final_transfer_started`
138+
**Meaning:** Final sync has started
139+
**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
140+
141+
**Status:** `transferred_to_hpc`
142+
**Meaning:** Transfer completed successfully
143+
**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
144+
145+
### Key Components
146+
147+
- **[`dataflow_transfer/run_classes/`](dataflow_transfer/run_classes/)**: Sequencer-specific run classes
148+
- **[`dataflow_transfer/utils/filesystem.py`](dataflow_transfer/utils/filesystem.py)**: File operations and rsync handling
149+
- **[`dataflow_transfer/utils/statusdb.py`](dataflow_transfer/utils/statusdb.py)**: CouchDB session management with retry logic
150+
- **[`dataflow_transfer/cli.py`](dataflow_transfer/cli.py)**: Command-line interface
151+
152+
## Assumptions
153+
154+
- Run directories are named according to sequencer-specific ID formats (defined in run classes)
155+
- Final completion is indicated by the presence of a sequencer-specific final file (e.g., `RTAComplete.txt` for Illumina)
156+
- Remote storage is accessible via rsync over SSH
157+
- CouchDB is accessible and the database exists
158+
- Metadata files (e.g., RunInfo.xml) are present in run directories for status database updates
159+
160+
### Status Files
161+
162+
The logic of the script relies on the following status files:
163+
164+
- run.final_file
165+
- The final file written by each sequencing machine. Used to indicate when the sequencing has completed.
166+
- 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.
167+
168+
## Development
169+
170+
### Running Tests
171+
172+
```bash
173+
pytest
174+
```
175+
176+
With coverage:
177+
178+
```bash
179+
pytest --cov --cov-branch
180+
```
181+
182+
### Code Quality
183+
184+
Run linting and formatting checks:
185+
186+
```bash
187+
ruff check .
188+
ruff format --check .
189+
```
190+
191+
### Project Structure
192+
193+
```
194+
dataflow_transfer/
195+
├── cli.py # Command-line interface
196+
├── dataflow_transfer.py # Main transfer orchestration
197+
├── log/ # Logging utilities
198+
├── run_classes/ # Sequencer-specific run classes
199+
├── utils/ # Utility modules (filesystem, statusdb)
200+
└── tests/ # Unit tests
201+
```
202+
203+
### Adding a new sequencer
204+
205+
To add support for a new sequencer, add the following to dataflow_transfer:
206+
207+
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)
208+
a. `dataflow_transfer/run_classes/illumina_runs.py`
209+
b. `dataflow_transfer/run_classes/element_runs.py`
210+
c. `dataflow_transfer/run_classes/ont_runs.py`
211+
2. Import the new class in `dataflow_transfer/run_classes/__init__.py`
212+
3. Add a test fixture for the new run in `dataflow_transfer/tests/test_run_classes.py` and include it in the relevant tests
213+
4. Add a section for the sequencer in the config file

0 commit comments

Comments
 (0)