Skip to content

Commit fc72067

Browse files
Fix find_aa_candidates() regex to match tRNA names with numeric suffixes (#33)
1 parent af7db20 commit fc72067

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090

9191
* `modomics_mods()` maps MODOMICS tRNA modifications onto reference sequences using bundled data, eliminating the need for internet access. Use `modomics_organisms()` to list organisms with cached data. Falls back to `fetch_modomics_mods()` for unsupported organisms (#11).
9292

93+
* `modomics_mods()` now correctly matches reference tRNA names with numeric suffixes such as tRNA-Ile2 (#29).
94+
9395
* `plot_volcano()` creates a labeled volcano plot from `tidy_deseq_results()` output, with significant points highlighted and labeled using ggrepel.
9496

9597
* `tabulate_deseq()` creates a formatted gt table of the top significant tRNAs from `tidy_deseq_results()` output, sorted by p-value. The table now includes zebra striping, search, column sorting, and pagination.

R/modomics.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ find_aa_candidates <- function(subtype, fasta_names) {
495495

496496
candidate_idx <- integer(0)
497497
for (pat in patterns) {
498-
aa_regex <- paste0("[-_]", pat, "[-_(]")
498+
aa_regex <- paste0("[-_]", pat, "\\d*[-_(]")
499499
idx <- grep(aa_regex, fasta_names, ignore.case = TRUE)
500500
candidate_idx <- union(candidate_idx, idx)
501501
}

tests/testthat/test-modomics.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@ test_that("find_aa_candidates matches amino acid in FASTA names", {
127127
expect_equal(gly_idx, 3L)
128128
})
129129

130+
test_that("find_aa_candidates matches numeric suffix variants (#29)", {
131+
fasta_names <- c(
132+
"tRNA-Ile-GAT-1",
133+
"tRNA-Ile2-CAT-1",
134+
"tRNA-Lys3-CTT-1",
135+
"tRNA-Alab-AGC-1"
136+
)
137+
138+
ile_idx <- find_aa_candidates("Ile", fasta_names)
139+
expect_equal(sort(ile_idx), c(1L, 2L))
140+
141+
lys_idx <- find_aa_candidates("Lys", fasta_names)
142+
expect_equal(lys_idx, 3L)
143+
144+
ala_idx <- find_aa_candidates("Ala", fasta_names)
145+
expect_equal(length(ala_idx), 0L)
146+
})
147+
130148
test_that("find_aa_candidates maps Ini to Met variants", {
131149
fasta_names <- c(
132150
"tRNA-Met-CAT-1",

0 commit comments

Comments
 (0)