Learn R Programming

rbamtools (version 2.0.1)

getNextAlign: Reads next Align from bamReader or bamRange.

Description

An open bamReader and a bamRange maintain a pointer to a current align. getNextAlign shifts the current align to the next following align and returns the value of the current align.

When there is no align past the current align (e.g. EOF), the getNextAling returns NULL. When a corrupted BAM-file is detected, an error is thrown.

Usage

getNextAlign(object)

Arguments

object
An object of class bamReader or bamRange.

Value

  • An object of class bamAlign or NULL.

Examples

Run this code
library(rbamtools)
bam_file <- system.file("extdata", "accepted_hits.bam", package="rbamtools")
idx_file <- system.file("extdata", "accepted_hits.bam.bai", package="rbamtools")
reader<-bamReader(bam_file)
isOpen(reader)
align<-getNextAlign(reader)
if(is.null(align))
	print("End of File!
")
loadIndex(reader,idx_file)
index.initialized(reader)
coords<-as.integer(c(0,0,1874))
range<-bamRange(reader,coords)
align<-getNextAlign(range)

align<-getNextAlign(range)
bamClose(reader)

Run the code above in your browser using DataLab