code: def detect_complexity(bam_in, genome, out):
      
      if not genome:
          logger.info("No genome given. skipping.")
          return None
      out_file = op.join(out, op.basename(bam_in) + "_cov.tsv")
      if file_exists(out_file):
          return None
      fai = genome + ".fai"
      cov = pybedtools.BedTool(bam_in).genome_coverage(g=fai, max=1)
      cov.saveas(out_file)
      total = 0
      for region in cov:
          if region[0] == "genome" and int(region[1]) != 0:
              total += float(region[4])
      logger.info("Total genome with sequences: %s " % total)
docs: genome coverage of small RNA