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

Translate source-backed CDS with exact codon provenance
Source:R/data-translate.R
translate_ggchord_cds.RdUses the complete observed codons in build_ggchord_cds(), including codons
split across segments. Extraction follows biological segment order; negative
DNA/RNA strands are complemented. Biostrings supplies genetic codes and
translation, and is required only when this function is called.
Arguments
- cds
A map from
build_ggchord_cds().- sequences
Named character vector of complete forward source strings, or a data frame with unique accver and sequence (e.g.
read_fasta_lengths()with keep_sequence = TRUE). DNAStringSet/RNAStringSet are also accepted. Every CDS source must exist and contain its declared intervals.- alphabet
Explicit
"DNA"(default) or"RNA"; ungapped IUPAC only.- initiation
"literal"(default) translates every codon literally."start"uses the genetic code's alternative initiation codons for the first codon only; it requires a complete biological 5-prime end.- ambiguous
"error"(default) rejects ambiguous codons;"solve"uses Biostrings to resolve them, emitting X when not uniquely resolvable.
Value
A list with models (coding_sequence, protein_sequence and policies),
nucleotides (one row per observed coding base) and residues (one row per
codon, with source_positions, source_cds_rows and source_cds_segments list
columns in transcription order). Residues use the CDS feature_id as their
observed-protein accver, not an inferred external accession. Nucleotides
retain genomic source_accver/source_position and codon_index/codon_base;
both tables can be displayed with geom_residue(). Source input and the
original CDS map remain in provenance. No alignment is computed.
Details
A known genetic_code is required for every model. No sequence, phase,
missing end or translation exception is inferred. Stops remain *, including
internal stops; they are not replaced or removed. The result is an observed
translation, not a validation of gene function or a predicted full protein.
Partial-end trimming follows the supplied CDS map and is reported in models.
Examples
R · Example code
# Explicit synthetic codon contract, not a biological annotation claim.
if (requireNamespace("Biostrings", quietly = TRUE)) {
coding <- data.frame(feature_id = "cds", accver = "source",
start = 1, end = 6, strand = "+", phase = 0)
cds <- build_ggchord_cds(coding, genetic_code = 11)
translate_ggchord_cds(cds, c(source = "ATGTAA"))$residues
}
#> accver alignment_column source_accver source_position symbol is_gap strand
#> 1 cds 1 cds 1 M FALSE +
#> 2 cds 2 cds 2 * FALSE +
#> alphabet sequence_unit source_verified genetic_code codon is_stop
#> 1 AA aa TRUE 11 ATG FALSE
#> 2 AA aa TRUE 11 TAA TRUE
#> source_positions source_cds_rows source_cds_segments genomic_accver
#> 1 1, 2, 3 1, 1, 1 1, 1, 1 source
#> 2 4, 5, 6 1, 1, 1 1, 1, 1 source
#> genomic_strand
#> 1 +
#> 2 +