# NOT RUN {
#
bam<-system.file("extdata","accepted_hits.bam",package="rbamtools")
idx<-system.file("extdata","accepted_hits.bam.bai",package="rbamtools")
#
reader<-bamReader(bam)
isOpen(reader)
#
align<-getNextAlign(reader)
if(is.null(align))
print("End of File!\n")
#
loadIndex(reader,idx)
indexInitialized(reader)
#
coords<-as.integer(c(0,0,249250621))
range<-bamRange(reader,coords)
align<-getNextAlign(range)
position(align)
#
bamClose(reader)
# }
Run the code above in your browser using DataLab