BStringViews-constructors {Biostrings}R Documentation

Basic functions for creating BStringViews objects

Description

A set of basic functions for creating BStringViews objects.

Usage

  views(subject, start=NA, end=NA)
  adjacentViews(subject, width, gapwidth=0)
  BStringViews(src, subjectClass, collapse="")

Arguments

subject A BString (or derived) object or a single string.
start An integer vector containing the start positions of the views.
end An integer vector containing the end positions of the views.
width An integer vector containing the widths of the views.
gapwidth An integer vector containing the widths of the gaps between the views.
src A BString (or derived) object or a character vector.
subjectClass The class to be given to the subject of the BStringViews object created and returned by the function. Must be "BString" or one of its subclasses: "DNAString", "RNAString" or "AAString".
collapse An optional character string to be inserted between the views of the BStringViews object created and returned by the function.

Details

The views function returns a BStringViews object containing views on subject with start and end positions given in the start and end vectors.

The adjacentViews function returns a BStringViews object containing views on subject with widths given in the width vector and separated by gaps of width gapwidth. The first view starts at position 1.

The BStringViews constructor will try to create a BStringViews object from the value passed to its src argument. If src itself is a BStringViews object, the returned object is obtained by coercing its subject to the class specified by subjectClass. If src is a BString object, the returned object is made of a single view that starts at the first letter and ends at the last letter of src (in addition src itself is coerced to the class specified by subjectClass when specified). If src is a character vector, the returned object has one view per character string in src (and its subject is an instance of the class specified by subjectClass).

Value

All these functions return a BStringViews object y with the following number of views (length(y)): max(length(start), length(end) for the views function and length(width) for the adjacentViews function. For the BStringViews constructor, length(y) is 1 when src is a BString object and length(src) otherwise.

See Also

BStringViews-class, BString, DNAString, RNAString

Examples

  ## 'start' and 'end' are recycled
  views("abcdefghij", 2:1, 4)
  views("abcdefghij", 5:7, )
  views("abcdefghij", , 5:7)

  ## Views can be "out of limits"
  views("abcdefghij", 2:0, 4)

  ## Views on a DNAString object
  v12 <- views(DNAString("TAATAATG"), -2:9, 0:11)

  ## Creating adjacent views
  v3 <- adjacentViews("abcdefghij", 4:2, gapwidth=1)

  BStringViews(v12, subjectClass="RNAString")
  BStringViews(AAString("MARKSLEMSIR*"))
  BStringViews("abcdefghij", subjectClass="BString")

[Package Biostrings version 2.6.6 Index]