subXString {Biostrings} | R Documentation

## Fast substring extraction

### Description

Functions for fast substring extraction.

### Usage

      subXString(x, start=NA, end=NA, length=NA)
      substr(x, start=NA, stop=NA)
      substring(text, first=NA, last=NA)

### Arguments

`x` | An XString object for `subXString`. A character vector, an XStringViews or an XString object for `substr` or `substring`.
`start` | A numeric vector.
`end` | A numeric vector.
`length` | A numeric vector.
`stop` | A numeric vector.
`text` | A character vector, an XStringViews or an XString object.
`first` | A numeric vector.
`last` | A numeric vector.

### Details

`subXString` provides a very efficient way to extract a substring from an XString object. For example, extracting a 100Mb substring from Human chromosome 1 (250Mb) with `subXString` is almost instantaneous and has almost no memory footprint. In fact, the cost in time and memory of a call to `subXString` 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: `subXString` does NOT copy the sequence data.

### Value

[TODO]

### Author(s)

H. Pages

### See Also

`letter`, `views`, XString-class, XStringViews-class

### Examples

      subXString("AxyxyxBC", 7)
      s <- BString("AxyxyxBC")
      subXString(s, 7)  # same as subXString("AxyxyxBC", 7)
      subXString(s, , 7)
      subXString(s, , 7, 3)
      identical(subXString(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))

      ## 2 equivalent ways of making the views wider
      views(subject(v), start(v)-3, end(v)+3)

[Package Biostrings version 2.8.18 Index]