Remove duplicate code for extracting primer

Pushed code into its own function so that it works for forward and reverse reads.