I am trying to use bedtools to pull out the reads falling directly within a set of BED coordinates. While this command does it successfully:
intersectBed -abam mybam.bam -b intervals.gff -wa -wb -f 1 | coverageBed -abam stdin -b intervals.gff
I find that it loses key information that I need. I'd like to get a listing of the BAM reads -- getting at least their ID -- split by exon. In other words, all the read IDs that fall into the first interval in intervals.gff, all the read IDs that fall into the second interval in intervals.gff... ideally, it would also report the CIGAR string for these reads, but I'd settle for just the ID.
Is there a way to report these reads, such that it's easy to tell from the output which set of reads landed in a given interval in the input BED file?