Skip to content

dev: Streaming FASTQ dataset support#91

Merged
cauliyang merged 7 commits into
001-biodata-dl-libfrom
006-modern-python-api
Dec 13, 2025
Merged

dev: Streaming FASTQ dataset support#91
cauliyang merged 7 commits into
001-biodata-dl-libfrom
006-modern-python-api

Conversation

@cauliyang

Copy link
Copy Markdown
Owner

This pull request introduces streaming FASTQ dataset support for efficient processing of large files in Rust and Python, and improves Python module structure for genomic annotation (GTF) and variant (VCF) processing. It also expands Python utilities for multi-label tasks and updates workflow configuration for Python testing.

Major new features and improvements:

Streaming FASTQ dataset support

  • Added new streaming module (crates/deepbiop-fq/src/streaming.rs) implementing a memory-efficient streaming FASTQ iterator with optional shuffle buffer, and Python bindings for StreamingFastqDataset. This enables handling of very large FASTQ files without loading them entirely into memory.
  • Registered the new streaming dataset class with the Python module, making it available for Python users.
  • Updated Rust module imports to include the new streaming module. [1] [2]

Python module improvements for genomic data

  • Refactored GTF and VCF Python module registration to use submodules with docstrings, improving discoverability and organization of genomic annotation and variant classes. [1] [2]
  • Updated Python package __init__.py to import GTF and VCF classes, and added them to the public API (__all__). [1] [2] [3]

Multi-label utilities for supervised learning

  • Added new multi-label collate functions and extractor utilities to the Python package and exported them in the public API. [1] [2] [3]

Workflow configuration cleanup

  • Cleaned up the Python test workflow by removing commented-out build/dependency steps, leaving only the necessary test and linting steps. [1] [2]

cauliyang and others added 7 commits November 21, 2025 00:47
Introduces deepbiop.modern module with type-safe, shape-annotated API:

Features:
- Shape-annotated types using jaxtyping for self-documenting APIs
- Modern OneHotEncoder/IntegerEncoder wrappers with batch encoding
- Architecture-specific methods (for_conv1d, for_transformer, for_rnn)
- einops-based rearrangement utilities (to_channels_first, pool_sequences)
- Comprehensive test suite (30 tests, all passing)

Technical details:
- Runtime shape validation with typeguard (optional)
- Graceful fallback when jaxtyping not available
- Wraps existing Rust encoders from deepbiop.fq
- Modern dependencies: einops>=0.8.0, jaxtyping>=0.2.34

Files:
- deepbiop/modern/__init__.py: Module exports
- deepbiop/modern/types.py: Shape-annotated type aliases
- deepbiop/modern/encoders.py: Modern encoder wrappers (480 lines)
- deepbiop/modern/transforms.py: Rearrangement utilities (390 lines)
- tests/test_modern.py: Comprehensive test suite (30 tests)

All pre-commit hooks passing. Resolves merge conflicts in stub files.
## VCF/GTF Module Exposure
- Modified register_vcf_module() to create proper Python submodule
- Modified register_gtf_module() to create proper Python submodule
- Added VcfReader, Variant, GtfReader, GenomicFeature to __init__.py exports
- Created comprehensive type stub files (vcf.pyi, gtf.pyi) for IDE support

## Bug Fix
- Fixed invalid escape sequence in targets.py docstring (line 9)
- Changed r"label=(\w+)" to r"label=(\\w+)" for Python 3.10+ compatibility
- Resolves 18 supervised learning test failures

## Testing
- All 52 VCF/GTF tests passing (2 skipped pandas tests)
- All 18 supervised learning tests now passing

This completes Python API parity with Rust for genomic variant and
annotation processing capabilities.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
**Multi-Label Target Extraction (Python)**
- Add MultiLabelExtractor class for multi-task learning
- Support dict, tuple, and array output formats
- Enable extraction of multiple targets per record (quality, GC, length, etc.)
- 100% backward compatible with existing TargetExtractor

**Enhanced Collate Functions (Python)**
- Add multi_label_collate for list-based batching
- Add multi_label_tensor_collate for tensor conversion
- Intelligently handle dict/tuple/array targets
- Enable multi-task learning workflows with PyTorch

**Streaming FASTQ Dataset (Rust + Python Bindings)**
- Implement StreamingFastqIterator with Iterator trait
- Add ShuffleBuffer using reservoir sampling for approximate randomization
- Memory-efficient: O(buffer_size) vs O(dataset_size)
- Support plain, gzip, and bgzip FASTQ files
- Python bindings via PyStreamingFastqDataset
- Enable processing of >100GB datasets without caching

**Performance Architecture**
- Rust: High-performance file I/O and streaming (20-30K reads/sec)
- Python: Flexible coordination layer for ML workflows
- Follows project philosophy: Rust for efficiency, Python for usability

Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add unsendable marker for PyStreamingFastqIterator (ThreadRng is not Sync)
- Add gen_stub attributes for proper stub generation
- Replace deprecated PyObject with Py<PyAny>
- Build and install successful

✅ All Rust code compiles cleanly
✅ Python bindings build successfully
✅ Ready for integration testing
Fix TypeError in test_multilabel_streaming.py by correcting parameter
name from 'target_extractor' to 'target_fn' in TransformDataset calls.
This resolves 2 failing tests:
- test_streaming_with_multilabel_extraction
- test_streaming_with_multilabel_collate

All 265 tests now pass successfully.
@cauliyang cauliyang merged commit 1331cf7 into 001-biodata-dl-lib Dec 13, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant