code: def filterbedgraph(args):
      
      p = OptionParser(filterbedgraph.__doc__)
      opts, args = p.parse_args(args)
  
      if len(args) != 2:
          sys.exit(not p.print_help())
  
      bedgraphfile, cutoff = args
      c = float(cutoff)
      fp = open(bedgraphfile)
      pf = bedgraphfile.rsplit(".", 1)[0]
      filteredbed = pf + ".filtered-{}.bed".format(cutoff)
      fw = open(filteredbed, "w")
      nfiltered = ntotal = 0
      for row in fp:
          b = BedLine(row)
          ntotal += 1
          if float(b.accn) >= c:
              print(b, file=fw)
              nfiltered += 1
      fw.close()
      logging.debug("A total of {} intervals (score >= {}) written to `{}`".\
                      format(percentage(nfiltered, ntotal), cutoff, filteredbed))
  
      mergeBed(filteredbed, sorted=True, delim=None)
docs: %prog filterbedgraph a.bedgraph 1
  
      Filter the bedGraph, typically from the gem-mappability pipeline. Unique
      regions are 1, two copies .5, etc.