subBString {Biostrings}R Documentation

Fast substring extraction

Description

Functions for fast substring extraction.

Usage

  subBString(x, start=NA, end=NA, length=NA)
  subviews(x, start=NA, end=NA, width=NA, check.limits=TRUE)
  substr(x, start=NA, stop=NA)
  substring(text, first=NA, last=NA)

Arguments

x A BString (or derived) object for subBString. A BStringViews object for subviews. A character vector, a BStringViews or a BString object for substr or substring.
start A numeric vector.
end A numeric vector.
length A numeric vector.
width A numeric vector.
check.limits A single logical indicating whether or not an error should be raised if the BStringViews object to be returned contains "out of limit" views (default is TRUE). With check.limits=FALSE then "out of limit" views are padded with spaces.
stop A numeric vector.
text A character vector, a BStringViews or a BString object.
first A numeric vector.
last A numeric vector.

Details

subBString provides a very efficient way to extract a substring from a BString (or derived) object. For example, extracting a 100Mb substring from Human chromosome 1 (250Mb) with subBString is almost instantaneous and has almost no memory footprint. In fact, the cost in time and memory of a call to subBString doesn't depend on the length of the original object or on the length of the extracted object. The "trick" behind this "feature" is very simple: subBString does NOT copy the sequence data.

For subviews, the start/end values must be given relatively to x views.

Value

[TODO]

See Also

letter, views, BString-class, DNAString-class, RNAString-class, AAString-class, BStringViews-class

Examples

  subBString("AxyxyxBC", 7)
  s <- BString("AxyxyxBC")
  subBString(s, 7)  # same as subBString("AxyxyxBC", 7)
  subBString(s, , 7)
  subBString(s, , 7, 3)
  identical(subBString(s), s) # TRUE

  v <- views(s, c(6, 4,-1, NA), c(7, 6, 1, 1))
  ## 2 equivalent ways of keeping the last letter of each view
  views(subject(v), end(v), end(v))
  subviews(v, end=width(v), width=1)

  ## 2 equivalent ways of making the views wider
  views(subject(v), start(v)-3, end(v)+3)
  subviews(v, -2, end=width(v)+3, check.limits=FALSE)

[Package Biostrings version 2.6.6 Index]