Skip to content

Commit

Permalink
Replace "-" with "_" in gene IDs before SBML export
Browse files Browse the repository at this point in the history
Otherwise, libSBML reports an error:
`Error: basic_string::substr: __pos (which is 2) > this->size() (which is 0)`
  • Loading branch information
Waschina committed Oct 7, 2024
1 parent 95ba6cc commit 05ec80e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/io.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ writeSBMLmod <- function(model, file_path = NULL) {
model@subSys_id <- paste0("subsys_",model@subSys_id)
model@met_id <- sub("\\[(.*)\\]$", "_\\1", model@met_id)

# libSBML seems not to allow "." nor ":" in gene IDs... replacing them here
# libSBML seems not to allow ".", ":", "-" in gene IDs... replacing them here
# with underscores
regrepl <- "\\.|\\:"
regrepl <- "\\.|\\:|-"
if(any(grepl(regrepl,model@allGenes))) {
model@allGenes <- gsub(regrepl,"_",model@allGenes)
model@genes <- lapply(model@genes, FUN = function(x) gsub(regrepl,"_",x))
Expand Down

0 comments on commit 05ec80e

Please sign in to comment.