merge first bit of duplicate code in main

the whole block was copied for the two cases:

A) read whole bam
B) read single sequence

we now have bam readers that hide these details so the code can be
merged. There will be a lot more of these commits coming
more deduplication