Chapters and reference
Complete canonical API text; task articles explain the workflows. Usage guide

Read chain alignment blocks without inventing sequence characters
Source:R/data-genome-alignment.R
read_chain.RdOptional Biopython Bio.Align parses chain coordinates. Each block aligned on both sides becomes one directional interval pair; intervening gaps stay in the source coordinate matrix rather than becoming a false uninterrupted match. Source chain scores and IDs remain in report metadata; neither is an Identity or read-support count. Chain contains no aligned characters.
Usage
R · Example code
read_chain(
file = NULL,
files = NULL,
query_ids = NULL,
subject_ids = NULL,
sequence_unit = c("bp", "aa"),
python = "python3",
source_file = FALSE
)Arguments
- file
Optional local path vector or glob patterns, before files.
- files
Optional additional chain paths or patterns.
- query_ids, subject_ids
Optional named character vectors mapping original query/target IDs to explicit source IDs. Unspecified IDs stay unchanged. Unknown map keys and conflicting full lengths fail.
- sequence_unit
Declared coordinate unit, "bp" (default) or "aa". The format itself cannot establish the biological unit.
- python
Existing interpreter with optional Biopython, default "python3".
- source_file
Add .source_file to ribbon rows, default FALSE.
Value
A list with seq_data, ribbon_data and report containing original text, chain scores/IDs, full lengths and exact zero-based boundary matrices. Each link retains source_block and source_segment provenance; no source HSP ID, pident, base mismatch script or character alignment is fabricated.
Details
The chain query becomes qaccver and its target becomes saccver. Original IDs stay in q_source_accver/s_source_accver. If both assemblies use the same IDs, supply explicit query_ids/subject_ids rather than implicitly merging distinct molecules or auto-prefixing them. Shared final IDs require explicit declaration on both sides and consistent full lengths. This is data identity mapping, not automatic homology discovery or display-instance creation.
Examples
R · Example code
python <- Sys.getenv("ALIGNMENT_PYTHON", "python3")
available <- identical(suppressWarnings(system2(python,
c("-c", shQuote("import Bio")), stdout = FALSE, stderr = FALSE)), 0L)
if (available) {
result <- read_chain("examples/genome-alignments/dna_rna.chain", python = python)
head(result$seq_data)
} else {
"Optional Biopython parser is unavailable; no parsed result was computed."
}
#> [1] "Optional Biopython parser is unavailable; no parsed result was computed."