I want to generate a list of 100 genomic intervals that are 100kb long and in which 50 genomic intervals should overlap some genes such as (GAPDH etc) from the bam file (mapping data). I want to check where some genes are being mapped and check the alignment summary of the mapping.
Do you basically want to generate 100 intervals with half of them containing genes of your interests, and the other half not? I don't see your description of purpose having anything to do with BAMs, unless you haven't described something important (e.g. coverage). You are talking about something easier to be done with excel instead of using tools/packages.