From 3e13d179e167e964e12075980f7c33ee713f0378 Mon Sep 17 00:00:00 2001 From: Piotr Balwierz Date: Fri, 19 Jul 2019 12:27:11 +0100 Subject: [PATCH 1/2] Allow digit grouping (by comma or space) in coercion from character --- R/IRanges-class.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/IRanges-class.R b/R/IRanges-class.R index a9a406e5..421bbd1a 100644 --- a/R/IRanges-class.R +++ b/R/IRanges-class.R @@ -201,11 +201,13 @@ setAs("numeric", "NormalIRanges", error_msg <- wmsg( "The character vector to convert to an IRanges object must ", "contain strings of the form \"start-end\" or \"start..end\", ", - "with end >= start - 1, or just \"pos\". For example: \"2501-2900\", ", - "\"2501..2900\", or \"740\"." + "with end >= start - 1, or just \"pos\". pos and end can have ", + "digit group separators in form of a space or a comma. ", + "For example: \"2501-2900\", \"2,501..2,900\", or \"740\"." ) ## We want to split on the first occurence of "-" that is preceeded by ## a digit (ignoring and removing the spaces in between if any). + from <- gsub("[,[:space:]]", "", from) from <- sub("([[:digit:]])[[:space:]]*-", "\\1..", from) split2 <- CharacterList(strsplit(from, "..", fixed=TRUE)) split2_eltNROWS <- elementNROWS(split2) From 23a0be8e44f3721f246bbdaa9aae3368c506663f Mon Sep 17 00:00:00 2001 From: Piotr Balwierz Date: Fri, 19 Jul 2019 12:34:05 +0100 Subject: [PATCH 2/2] Allow digit grouping (by comma or space) in coercion from character --- R/IRanges-class.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/IRanges-class.R b/R/IRanges-class.R index 421bbd1a..75140ef5 100644 --- a/R/IRanges-class.R +++ b/R/IRanges-class.R @@ -205,10 +205,10 @@ setAs("numeric", "NormalIRanges", "digit group separators in form of a space or a comma. ", "For example: \"2501-2900\", \"2,501..2,900\", or \"740\"." ) - ## We want to split on the first occurence of "-" that is preceeded by - ## a digit (ignoring and removing the spaces in between if any). from <- gsub("[,[:space:]]", "", from) - from <- sub("([[:digit:]])[[:space:]]*-", "\\1..", from) + ## We want to split on the first occurence of "-" that is preceeded by + ## a digit. + from <- sub("([[:digit:]])-", "\\1..", from) split2 <- CharacterList(strsplit(from, "..", fixed=TRUE)) split2_eltNROWS <- elementNROWS(split2) if (!all(split2_eltNROWS <= 2L))