I like using the first method as I can seamlessly utilize the *ranges packages. Is there a way to retrieve sequence data from a readGappedAlignments object? If not, what is the preferred method to construct a data.frame with:
"rname", "strand", "start", "stop", "width", "sequence" from a bam file inside of R?
You can configure your readGappedAlignments call with a custom param object that returns the things you like. So if you are asking if you want to get the sequences of the reads aligned you can do so like this:
Converting this to the data.frame you are after should be pretty straight forward.
If, however, you are rather interested in getting the genomic sequences that are fenceposted by the ranges returned in your GappedAlignments, you can use the getSeq function from BSgenome package to get the genomic sequences you are after -- I suspect you aren't asking for this, so I'll leave this as an exercise to the reader.
Thanks a lot Steve!