R
Using SEGUL API in R
Section titled “Using SEGUL API in R”We recommend to use the R package rextendr to interact with SEGUL API. Check out rsegul to see how to use rextendr to interact with SEGUL API. A comprehensive list of available SEGUL functions and how to use them is available in the SEGUL API documentation.
Step-by-step guide
Section titled “Step-by-step guide”Install Rust
Section titled “Install Rust”Follow the Rust installation guide to install Rust.
Install rextendr
Section titled “Install rextendr”install.packages("rextendr")Load rextendr
Section titled “Load rextendr”library(rextendr)Check Rust installation
Section titled “Check Rust installation”rust_sitrep()
# Rust infrastructure sitrep:# ✔ "rustup": 1.26.0 (5af9b9484 2023-04-05)# ✔ "cargo": 1.75.0 (1d8b05cdd 2023-11-20)# ℹ host: aarch64-apple-darwin# ℹ toolchain: stable-aarch64-apple-darwin# ℹ targets: aarch64-apple-darwin, aarch64-apple-ios, aarch64-apple-ios-sim, aarch64-linux-android, armv7-linux-androideabi,# i686-linux-android, x86_64-apple-darwin, x86_64-apple-ios, and x86_64-linux-androidWrite SEGUL code in R
Section titled “Write SEGUL code in R”For example, to call the alphabet function from the segul crate:
use segul::helper::alphabet;
fn alphabet() -> String { alphabet::DNA_STR_UPPERCASE.to_string()}In R, you can use the rust_source function from rextendr to call the SEGUL function.
segul_code <- r"(use segul::helper::alphabet;
#[extendr]fn alphabet() -> String { alphabet::DNA_STR_UPPERCASE.to_string()})"
rust_source(code = segul_code, dependencies = list(segul = "*"))Call SEGUL function in R
Section titled “Call SEGUL function in R”alphabet()
# [1] "?-ACGTNRYSWKMBDHV."Copyright © 2026 H. Handika & J. A. Esselstyn.