Step00: Hypothesizing that you have get a duplication-removed bam file named by sample1_q30.sort.RGadd.rmdu.bam.
samtools view -f 64 -F 128 -h sample1_q30.sort.RGadd.rmdu.bam > sample1_q30.sort.RGadd.rmdu.bam.R1.sam
perl ./sam_filter_split.pl -i sample1_q30.sort.RGadd.rmdu.bam.R1.sam -m sample1_q30.sort.RGadd.rmdu.bam.R1.minusStrand.sam -p sample1_q30.sort.RGadd.rmdu.bam.R1.plusStrand.sam
samtools view -bS sample1_q30.sort.RGadd.rmdu.bam.R1.minusStrand.sam > sample1_q30.sort.RGadd.rmdu.bam.R1.minusStrand.bam
samtools index -c sample1_q30.sort.RGadd.rmdu.bam.R1.minusStrand.bam
samtools depth sample1_q30.sort.RGadd.rmdu.bam.R1.minusStrand.bam > sample1_q30.sort.RGadd.rmdu.bam.R1.minusStrand.bam.depth
samtools view -bS sample1_q30.sort.RGadd.rmdu.bam.R1.plusStrand.sam > sample1_q30.sort.RGadd.rmdu.bam.R1.plusStrand.bam
samtools index -c sample1_q30.sort.RGadd.rmdu.bam.R1.plusStrand.bam
samtools depth sample1_q30.sort.RGadd.rmdu.bam.R1.plusStrand.bam > sample1_q30.sort.RGadd.rmdu.bam.R1.plusStrand.bam.depth
perl ./find_tags_R1_plusStrand.pl -i sample1_q30.sort.RGadd.rmdu.bam.R1.plusStrand.bam.depth -c 1.35 -d 3 -o sample1_q30.sort.RGadd.rmdu.bam.R1.plusStrand.bam.depth.tags
perl ./find_tags_R1_minusStrand.pl -i sample1_q30.sort.RGadd.rmdu.bam.R1.minusStrand.bam.depth -c 1.35 -d 3 -o sample1_q30.sort.RGadd.rmdu.bam.R1.minusStrand.bam.depth.tags
perl ./merge_plus-minus-Strand-tags-sort.pl sample1_q30.sort.RGadd.rmdu.bam.R1.plusStrand.bam.depth.tags sample1_q30.sort.RGadd.rmdu.bam.R1.minusStrand.bam.depth.tags sample1_q30_PlusMinusStrands-merged-sort.bam.depth.tags
perl ./extr_RefSeqPrimerBindingRegion.pl -t sample1_q30_PlusMinusStrands-merged-sort.bam.depth.tags -s sample1_q30.sort.RGadd.rmdu.bam.R1.sam -l 24 -o sample1_q30_PlusMinusStrands-merged-sort.bam.depth.tags.region
Tips: In the output file sample1_q30_PlusMinusStrands-merged-sort.bam.depth.tags.region, (1) some spurious tags caused by indel may be included, so you can fiter out these bad tags marked with charecters "noCIGAR" in the column of "all_CIGAR_values"; (2) the last two columns showed 0-based genomic coordinates, which will help to extract corresponding genomic sequences by command of "bedtools getfasta" if necessary.
The detailed explanation of paramerers of custom perl scripts in aboving steps, could be obtained by looking into corresponding scripts contents.