bamRange-class: Class '"bamRange"'

Description Objects from the Class Slots Methods Author(s) Examples

Description

bamRange represents a double linked list of bamAlign objects which overlap with a defined region in a BAM-file. The bamRange-function retrieves all alignments in the depicted Range from BAM-File into a bamRange object. A bamRange object maintains a double-linked list of aligns and a pointer to a current align.

rewind shifts the current align before the first align (=past the last align). When there is no align, nothing happens. The functions writeCurrentAlign, insertPreCurrent, insertPastCurrent can be used to write bamAlign data to bamRange object. The function writeCurrentAlign overwrites the data of the current bamRange align. When no current align is set (i.e. ==NULL), nothing is written. The functions insertPreCurrent and insertPastCurrent insert an bamAlign object into the bamRange list. When no current align is set, insertPreCurrent inserts the object as the last object and insertPastCurrent inserts the object as the first align object in the bamRange list.

push_back (push_front) appends a bamAlign before the first (or behind the last) element of bamRange. pop_front (pop_back) removes the first (last) bamAlign from bamRange.

Objects from the Class

Objects can be created by calls of the form range<-bamRange(reader, coords).

Slots

range:

External pointer to double linked list of bamAligns.

Methods

as.data.frame

signature(x = "bamRange"): Returns data.frame representation of aligns.

coerce

signature(from = "bamRange", to = "data.frame"): Coercion of bamRange to data.frame.

bamSave

signature(object = "bamRange"): Saves aligns stored in this list to BAM-file via a bamWriter object.

getNextAlign

signature(object = "bamRange"): Returns next align from current position and shifts current position to next one.

getPrevAlign

signature(object = "bamRange"): Returns previous align from current position and shifts current position to previous one.

initialize

signature(.Object = "bamRange"): Initializes bamRange object.

insertPastCurrent

signature(object = "bamRange"): Inserts align past current position into list.

insertPreCurrent

signature(object = "bamRange"): Insert align before current position into list.

pop_back

signature(object = "bamRange"): Removes last align from list.

pop_front

signature(object = "bamRange"): Removes first align from list.

push_back

signature(object = "bamRange"): Adds align at the end of the list.

push_front

signature(object = "bamRange"): Adds align at the front of the list.

rewind

signature(object = "bamRange"): Shifts current align to position before first align.

size

signature(object = "bamRange"): Returns number of aligns in list.

writeCurrentAlign

signature(object = "bamRange"): Overwrites current align with given align.

alignQual

signature(object = "bamRange"): Returns quality scores of all aligned reads (one for each query-base). Will be reverse of raw if aligned to reverse strand.

alignSeq

signature(object = "bamRange"): Returns base sequence of all aligned reads. Will be reverse complement of raw if aligned to reverse strand.

getTag

signature(object = "bamRange", tag="character"): Retrieves the value of the given tag as a character vector, with "" if 'tag' not found.

getAllTags

signature(object = "bamRange", sep="character"): Retrieves the complete descriptors of all tags as a character vector, with with 'sep' inserted between tags.

readQual

signature(object = "bamRange"): Returns quality scores of all raw reads prior to alignment (one for each query-base).

readSeq

signature(object = "bamRange"): Returns base sequence of all raw reads prior to alignment.

readID

signature(object = "bamRange"): Returns all read Identifiers.

refID

signature(object = "bamRange"): Returns all reference sequence Identifiers.

position

signature(object = "bamRange"): Returns all align positions (on Ref-Sequence).

reverseStrand

signature(object = "bamRange"): Gets flag item denoting alignment to the reverse strand.

Author(s)

Wolfgang Kaisers

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
library(rbamtools)
bam <- system.file("extdata", "accepted_hits.bam", package="rbamtools")
idx<-paste(bam,"bai",sep=".")
# Open BAM file
reader<-bamReader(bam)
# create.index(reader,idx)
# Load BAM index file
load.index(reader,idx)
index.initialized(reader)   # Should return 'TRUE'

# +++++++++++++++++++++++++++++++++++++++++++++++
#  Find appropriate refid (=ID)
#  Returns a data.frame with three columns:
#  ID=refid, SN=Sequence Name, LN=Sequence length

rdf<-getRefData(reader)
head(rdf)

# +++++++++++++++++++++++++++++++++++++++++++++++
# The sequence length (LN) also determines valid
# range for start and stop coordinates
# Invalid refid-, start- or stop-coordinates will
# release an error.
# coords: refid=0, start=0, stop=249250621
# +++++++++++++++++++++++++++++++++++++++++++++++

coords<-as.integer(c(0,0,249250621))
range<-bamRange(reader,coords)
size(range)
range<-bamRange(reader,coords,complex=TRUE)
dfr<-as.data.frame(range)
size(range)
align<-getNextAlign(range)
cigarData(align)
rewind(range)
# while(!is.null(align))
# {
#   print(position(align))
#   align<-getNextAlign(range)
# }
bamClose(reader)

robertdouglasmorrison/DuffyNGS documentation built on Dec. 7, 2018, 8:01 a.m.