@@ -142,13 +142,19 @@ setMethod("extract_character_from_XString_by_ranges", "XString",
142142# ## BString methods to support 0:255 input
143143
144144# # BSTRING_RAW_LOOKUP is initialized in `zzz.R`
145- # # this value is just a backup on the offchance `zzz.R:.onLoad` fails
146- BSTRING_RAW_LOOKUP <- rawToChar(as.raw(0 : 255 ), multiple = TRUE )
147145setMethod ("extract_character_from_XString_by_ranges ", "BString",
148146 function (x , start , width , collapse = FALSE )
149147 {
150148 SHOW_RAW <- getOption(" Biostrings.showRaw" )
149+ if (! is.logical(SHOW_RAW )){
150+ warning(" Invalid value for option 'Biostrings.showRaw', " ,
151+ " resetting to FALSE" )
152+ SHOW_RAW <- FALSE
153+ options(Biostrings.showRaw = FALSE )
154+ }
151155 if (! SHOW_RAW ) callNextMethod()
156+
157+ bstring_lookup <- get(" BSTRING_RAW_LOOKUP" , envir = .pkgenv )
152158 lkup <- xs_dec_lkup(x )
153159
154160 # # need to remap null bytes, they have to be in 0:255
@@ -159,7 +165,7 @@ setMethod("extract_character_from_XString_by_ranges", "BString",
159165 lkup = lkup )
160166 # # replace all undisplayable characters
161167 for (i in seq_along(xs ))
162- xs [i ] <- paste(BSTRING_RAW_LOOKUP [as.integer(charToRaw(xs [i ]))+ 1L ],
168+ xs [i ] <- paste(bstring_lookup [as.integer(charToRaw(xs [i ]))+ 1L ],
163169 collapse = ' ' )
164170 xs
165171 }
@@ -169,8 +175,15 @@ setMethod("extract_character_from_XString_by_positions", "BString",
169175 function (x , pos , collapse = FALSE )
170176 {
171177 SHOW_RAW <- getOption(" Biostrings.showRaw" )
178+ if (! is.logical(SHOW_RAW )){
179+ warning(" Invalid value for option 'Biostrings.showRaw', " ,
180+ " resetting to FALSE" )
181+ SHOW_RAW <- FALSE
182+ options(Biostrings.showRaw = FALSE )
183+ }
172184 if (! SHOW_RAW ) callNextMethod()
173185 lkup <- xs_dec_lkup(x )
186+ bstring_lookup <- get(" BSTRING_RAW_LOOKUP" , envir = .pkgenv )
174187
175188 # # need to remap null bytes, they have to be in 0:255
176189 # # so we have to overload some value
@@ -180,7 +193,7 @@ setMethod("extract_character_from_XString_by_positions", "BString",
180193 lkup = lkup )
181194 # # replace all undisplayable characters
182195 for (i in seq_along(xs ))
183- xs [i ] <- paste(BSTRING_RAW_LOOKUP [as.integer(charToRaw(xs [i ]))+ 1L ],
196+ xs [i ] <- paste(bstring_lookup [as.integer(charToRaw(xs [i ]))+ 1L ],
184197 collapse = ' ' )
185198 xs
186199 }
0 commit comments