code: def _get_current_dup_metrics(self, align_bam):
          
          metrics_file = "%s.dup_metrics" % os.path.splitext(align_bam)[0]
          if not file_exists(metrics_file):
              dups = 0
              with pysam.Samfile(align_bam, "rb") as bam_handle:
                  for read in bam_handle:
                      if (read.is_paired and read.is_read1) or not read.is_paired:
                          if read.is_duplicate:
                              dups += 1
              with open(metrics_file, "w") as out_handle:
                  out_handle.write("# custom bcbio-nextgen metrics\n")
                  out_handle.write("READ_PAIR_DUPLICATES\t%s\n" % dups)
          return metrics_file
docs: Retrieve duplicate information from input BAM file.