There is a lot of copy-paste that we can move into a function, e.g.

def pileupFromRecord(record: ADAMRecord, ...): ADAMPileup = {
   // insert copy-paste here.
}