Add elbow-form layout for plot_tRNA_structure()#28
Open
jayhesselberth wants to merge 3 commits into
Open
Conversation
Adds a `layout = c("cloverleaf", "elbow")` argument to
`plot_tRNA_structure()` and `structure_trnas()`. The elbow form stacks
the acceptor stem and T-arm coaxially at the top, with the D-arm
extending horizontally and the anticodon arm hanging vertically —
matching the L-shape depiction common in structural biology figures.
Geometry is derived from canonical Sprinzl labels via
`inst/extdata/sprinzl/ecoliK12_global_coords.tsv.gz`, so a single
coordinate table works across all standard tRNAs. The new generator
`data-raw/structures/generate_elbow.py` reads each cloverleaf JSON's
sequence, looks up Sprinzl labels, and writes elbow SVG + JSON in the
same schema as cloverleaf — overlay code (modifications, outlines,
linkages, position markers, end labels) works unchanged.
v1 ships 29 E. coli standard 3-arm tRNAs. Variable-arm tRNAs
(Leu, Ser, SeC, Tyr) are deferred to v2.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Initial elbow layout drew the D-arm horizontally with D-loop at the far left. The reference figure (Matsumoto 2026 JBC fig 2A) shows the L-shape with D-arm and AC-arm both VERTICAL — sitting side-by-side as parallel helices below the horizontal acceptor+T stack: * D-arm on the LEFT, 4 bp going DOWN, D-loop curling at bottom-left * AC-arm on the RIGHT, 5 bp going DOWN, AC-loop at the bottom * pos 26 hinge bridges D-arm top-right to AC-arm top-left * variable region curves from AC-arm top-right up to T-stem 5' Updates the geometry constants and the D-arm + D-loop placement code in generate_elbow.py and regenerates all 29 bundled E. coli elbow SVG/JSON pairs. Visual check on Phe, Asp, and Val now matches the reference. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The first elbow layout had loop residues only 4-5 SVG units apart and the variable region as tight as 2.5 units — too tight for the radius-4.3 modification circles and stroke outlines drawn by plot_tRNA_structure(). Fixes: * Loop radii now solved analytically so chord between adjacent residues equals the backbone spacing S: R = S / (2 sin(π/(2N))) for N residues on a 180° arc. Previous formula (N-1)*S/π underestimated R by ~17%. * Variable region (44..48) now sampled by ARC LENGTH along the bezier rather than by uniform t, so neighbors are evenly spaced instead of bunching at the apex. * Wider canvas (240×170 vs 215×132) and deeper D-arm/AC-arm (D_TOP_Y pushed down by 14 units) give the variable-region path enough room. * Acceptor stem widened (ACC_X1 220 vs 195) for more horizontal room. Result: minimum neighbor distance is now 7.55 (matching the cloverleaf median of 7.56), so modification circles fit without overlapping neighboring letters. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
layout = c("cloverleaf", "elbow")toplot_tRNA_structure()andstructure_trnas(). Default is"cloverleaf"— fully backwards compatible.inst/extdata/structures/Escherichia_coli/elbow/.data-raw/structures/generate_elbow.pyderives geometry from canonical Sprinzl labels (so a single coordinate table covers all standard tRNAs across organisms), reads each cloverleaf JSON's sequence, and writes elbow SVG + JSON in the same schema as cloverleaf — so all overlay machinery (modifications, outlines, linkages, position markers, end labels) works unchanged.The elbow form stacks the acceptor stem and T-arm coaxially at the top, with the D-arm extending horizontally and the anticodon arm hanging vertically — matching the L-shape depiction common in structural biology figures.
Variable-arm tRNAs (Leu, Ser, SeC, Tyr) are deferred to v2; the generator skips them with a clear log message and the R-side path errors cleanly when callers request elbow layout for an unbundled tRNA.
Test plan
devtools::test()— all 47 new + existing tests pass (8 pre-existing skips for rsvg/tidygraph/ggraph)pkgdown::check_pkgdown()clean<circle>annotations are placed correctlylayoutrenders identical cloverleaf output🤖 Generated with Claude Code