How kojix2/read_until works
This repository is a Crystal shard that wraps Oxford Nanopore’s Read Until API. It is not a standalone application; it is a library centered on streaming signal inspection and control of sequencing reads.
1. Public entry point
• src/read_until.cr is the top-level require file.
• shard.yml defines the package as a Crystal dependency.
• The README shows the main usage pattern: ReadUntil::Client.new(connection) followed by client.open(...).
2. Core runtime boundary
• The library sits between Crystal application code and an underlying connection to a Nanopore Read Until-capable system.
• The external dependency is the sequencing/control endpoint, not a database or web server.
• The user supplies the connection object; this library manages session lifecycle and read decisions.
3. Client and session orchestration
• src/read_until/client.cr is the main facade for opening a controlled streaming session.
• src/read_until/session.cr likely owns the active run state: channel scope, streaming mode, read iteration, and actions such as unblock.
• Architecturally, this is the control plane: open a session, process reads, issue decisions back to the device.
4. Read ingestion pipeline
• src/read_until/read.cr and src/read_until/read_buffer.cr represent the data plane for incoming read chunks and buffered signal data.
• The example in the README shows batch-oriented iteration over reads, suggesting the library supports streaming and incremental processing rather than loading full reads into memory.
• This is the key flow: raw signal arrives → buffer/read wrapper → user inspection → decision.
5. Prefiltering and classification
• src/read_until/prefilter.cr provides early filtering rules before full read processing.
• src/read_until/classification_registry.cr suggests a registry of classification outcomes or labels used to route reads.
• The README’s Prefilter.strand_like(:strand, :adapter) example indicates the library supports lightweight heuristics to decide which reads proceed to deeper analysis.
6. Signal representation
• src/read_until/signal_format.cr defines how raw signal data is interpreted or converted.
• The README example read.signal(Int16) implies the library abstracts signal extraction into typed views, so downstream code can work with signal arrays in a chosen numeric format.
• This is important for performance-sensitive analysis because signal conversion is explicit and typed.
7. Configuration and types
• src/read_until/config.cr centralizes session/runtime configuration.
• src/read_until/types.cr likely defines shared domain types used across client, session, and read handling.
• src/read_until/version.cr exposes package version metadata.
• These files indicate a clean separation between domain model, runtime settings, and public API surface.
8. Statistics and operational insight
• src/read_until/stats.cr suggests the library tracks session-level or read-level metrics.
• This is a supporting subsystem rather than the main control path, but it matters for monitoring throughput, filter outcomes, and unblock/reject behavior.
9. Example-driven architecture
• examples/basic.cr is the only example entry point, and it reflects the intended control loop:
open session on a channel range, stream reads in batches, inspect signal, and send unblock actions conditionally.
• The example demonstrates the library’s primary architectural pattern: event-driven stream processing with feedback to the sequencer.
10. Test and release structure
• spec/ contains behavior tests, with spec/read_until_spec.cr and shared setup in spec/spec_helper.cr.
• GitHub Actions workflows in .github/workflows/test.yml and docs.yml indicate automated validation and documentation generation.
• This suggests the public API is meant to stay stable and the library is verified through spec-based behavior tests.
11. Main data flow
• Incoming connection data enters through Client.
• Session coordinates channel selection, streaming mode, and batching.
• Read/ReadBuffer hold the streamed signal.
• Prefilter and ClassificationRegistry classify or triage reads.
• User code inspects typed signal, then sends a sequencing decision such as unblock.
12. Architectural summary
• The repository is best understood as a thin, stateful streaming control library for nanopore sequencing.
• Its boundaries are: Crystal application code on one side, Nanopore Read Until infrastructure on the other.
• Internally it is organized around session control, buffered signal handling, filtering/classification, and typed signal conversion.
Main entry points: session.cr Session · read_until.cr Entry file · client.cr Client · read.cr Read
Components 15
Public API
Top-level require and package surface
- Entry file · Top-level require file for the shard
src/read_until.cr
Control Plane
Session orchestration and sequencing decisions
Data Plane
Read ingestion, buffering, and signal views
- Read · Wrapper for incoming reads and signal access
src/read_until/read.cr - Read buffer · Incremental storage for streamed signal chunks
src/read_until/read_buffer.cr - Signal format · Typed interpretation of raw signal data
src/read_until/signal_format.cr - Prefilter · Early heuristics for triaging reads
src/read_until/prefilter.cr - Registry · Classification outcomes and labels used to route reads
src/read_until/classification_registry.cr
Support
Shared domain types, config, stats, and versioning
Examples & Specs
Intended usage and behavioral coverage
- Basic example · Demonstrates open, stream, inspect, and unblock flow
examples/basic.cr - Specs · Public API and session behavior coverage
spec/read_until_spec.cr
Connections 37
- Entry file → Client: exports · Top-level entry requires the main client API
- Entry file → Session: exports · Top-level entry exposes session orchestration
- Entry file → Read: exports · Top-level entry exposes read handling
- Entry file → Read buffer: exports · Top-level entry exposes buffered signal support
- Entry file → Prefilter: exports · Top-level entry exposes prefiltering helpers
- Entry file → Registry: exports · Top-level entry exposes classification routing
- Entry file → Signal format: exports · Top-level entry exposes signal conversion
- Entry file → Config: exports · Top-level entry exposes configuration
- Entry file → Types: exports · Top-level entry exposes shared types
- Entry file → Stats: exports · Top-level entry exposes metrics support
- Client → Read Until API: connects · Client operates over a supplied connection to the sequencing system
- Client → Session: opens · Client creates and manages active sessions
- Session → Read Until API: controls · Session issues read-until decisions back to the device
- Session → Read buffer: streams · Session coordinates incremental read buffering
- Session → Read: emits · Session yields reads for inspection and decisioning
- Session → Prefilter: applies · Session can triage reads before deeper processing
- Session → Stats: records · Session updates operational counters and throughput data
- Read buffer → Read: wraps · Buffered chunks are exposed through read objects
- Read → Signal format: views · Reads expose typed signal access
- Prefilter → Registry: routes · Early heuristics map reads into classification outcomes
- Config → Client: configures · Configuration shapes client behavior
- Config → Session: configures · Configuration shapes session scope and runtime mode
- Types → Client: shared by · Shared domain types support the public API
- Types → Session: shared by · Shared domain types support session orchestration
- Types → Read: shared by · Shared domain types support read handling
- Types → Prefilter: shared by · Shared domain types support filtering decisions
- Stats → Session: observes · Metrics summarize session activity
- Version → Entry file: metadata · Package version metadata belongs to the public module
- Basic example → Client: uses · Example constructs the client and opens a session
- Basic example → Session: uses · Example demonstrates the streaming control loop
- Basic example → Read: inspects · Example inspects read signal batches
- Basic example → Signal format: converts · Example shows typed signal extraction
- Basic example → Prefilter: triages · Example demonstrates read filtering decisions
- Specs → Client: verifies · Specs cover the public client API
- Specs → Session: verifies · Specs cover session behavior
- Specs → Read: verifies · Specs cover read handling and signal access
- Specs → Prefilter: verifies · Specs cover filtering behavior