|
| 1 | +# qprimer_designer Development Guide |
| 2 | + |
| 3 | +## Project Structure |
| 4 | + |
| 5 | +This is a Python package for ML-guided qPCR primer design. Key directories: |
| 6 | + |
| 7 | +- `src/qprimer_designer/` - Main package source |
| 8 | + - `cli.py` - Single CLI entry point with subcommands |
| 9 | + - `commands/` - Individual subcommand implementations |
| 10 | + - `models/` - PyTorch ML model architectures |
| 11 | + - `external/` - Wrappers for external tools (ViennaRNA, bowtie2, MAFFT) |
| 12 | + - `utils/` - Shared utilities (sequence ops, encoding, params) |
| 13 | + - `data/` - Pre-trained ML models (bundled as package data) |
| 14 | +- `workflows/` - Snakemake workflow templates |
| 15 | +- `training/` - Historical model training code (not production) |
| 16 | +- `tests/` - pytest test suite |
| 17 | + |
| 18 | +## Development Setup |
| 19 | + |
| 20 | +```bash |
| 21 | +# Create conda environment with external tools |
| 22 | +conda env create -f environment.yml |
| 23 | +conda activate qprimer-designer |
| 24 | + |
| 25 | +# Install package in editable mode with dev dependencies |
| 26 | +pip install -e ".[dev]" |
| 27 | + |
| 28 | +# Run tests |
| 29 | +pytest tests/ -v |
| 30 | +``` |
| 31 | + |
| 32 | +## CLI Usage |
| 33 | + |
| 34 | +Single entry point with subcommands: |
| 35 | +```bash |
| 36 | +qprimer generate --help |
| 37 | +qprimer evaluate --help |
| 38 | +qprimer pick-representatives --help |
| 39 | +qprimer prepare-input --help |
| 40 | +qprimer filter --help |
| 41 | +qprimer build-output --help |
| 42 | +qprimer select-multiplex --help |
| 43 | +``` |
| 44 | + |
| 45 | +## Key Patterns |
| 46 | + |
| 47 | +### External Tool Wrappers |
| 48 | +External bioinformatics tools (RNAduplex, bowtie2, mafft) are assumed to be |
| 49 | +in PATH via conda installation. Use `shutil.which()` to verify availability. |
| 50 | + |
| 51 | +### ML Model Loading |
| 52 | +Models are bundled as package data. Load using `importlib.resources`: |
| 53 | +```python |
| 54 | +from importlib.resources import files |
| 55 | +model_path = files('qprimer_designer.data').joinpath('combined_classifier.pth') |
| 56 | +``` |
| 57 | + |
| 58 | +### Adding New Subcommands |
| 59 | +1. Create module in `src/qprimer_designer/commands/` |
| 60 | +2. Implement `register(subparsers)` function to add argparse subparser |
| 61 | +3. Import and register in `cli.py` |
| 62 | + |
| 63 | +## Testing |
| 64 | + |
| 65 | +- Run all tests: `pytest tests/ -v` |
| 66 | +- Run with coverage: `pytest tests/ -v --cov=qprimer_designer` |
| 67 | +- Tests should not require external tools (mock them) |
| 68 | + |
| 69 | +## Docker |
| 70 | + |
| 71 | +Build locally: |
| 72 | +```bash |
| 73 | +docker build -t qprimer-designer:local . |
| 74 | +docker run --rm qprimer-designer:local qprimer --help |
| 75 | +``` |
| 76 | + |
| 77 | +## Snakemake Workflows |
| 78 | + |
| 79 | +Workflows are in `workflows/`. They use the `qprimer` CLI internally: |
| 80 | +```bash |
| 81 | +cd workflows |
| 82 | +snakemake -s Snakefile.example --cores all |
| 83 | +``` |
| 84 | + |
| 85 | +Dry-run validation: |
| 86 | +```bash |
| 87 | +snakemake -s Snakefile.example --dry-run |
| 88 | +``` |
| 89 | + |
| 90 | +## Environment Variables |
| 91 | + |
| 92 | +- `QPRIMER_FONT_PATH`: Custom font directory for training plots (optional) |
| 93 | +- `QPRIMER_TOOLPATH`: Custom tool installation path for training scripts (optional) |
| 94 | +- `RNASTRUCTURE_DATAPATH`: Path to RNAstructure data tables (optional) |
0 commit comments