# NOT RUN {
bam<-system.file("extdata","accepted_hits.bam",package="rbamtools")
# Open bam file
reader<-bamReader(bam)
# Extract binary header structure
header<-getHeader(reader)
header
# Extract textual representation
htxt<-getHeaderText(header)
# Extract header line segment
hl<-headerLine(htxt)
# Get header program
hp<-headerProgram(htxt)
hp
# Re-create binary header structure
header2<-bamHeader(htxt)
# Use created structure for new BAM-file
# }
# NOT RUN {
writer<-bamWriter(header2,"test.bam")
bamClose(reader)
bamClose(writer)
# }
Run the code above in your browser using DataLab