docs: def mapped_read_count(self, force=False):
          """
          Counts total reads in a BAM file.
  
          If a file self.bam + '.scale' exists, then just read the first line of
          that file that doesn't start with a "#".  If such a file doesn't exist,
          then it will be created with the number of reads as the first and only
          line in the file.
  
          The result is also stored in self._readcount so that the time-consuming
          part only runs once; use force=True to force re-count.
  
          Parameters
          ----------
          force : bool
              If True, then force a re-count; otherwise use cached data if
              available.
          """
          # Already run?
          if self._readcount and not force:
              return self._readcount
  
          if os.path.exists(self.fn + '.mmr') and not force:
              for line in open(self.fn + '.mmr'):
                  if line.startswith('#'):
                      continue
                  self._readcount = float(line.strip())
                  return self._readcount
  
          cmds = ['samtools',
                  'view',
                  '-c',
                  '-F', '0x4',
                  self.fn]
          p = subprocess.Popen(
              cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
          stdout, stderr = p.communicate()
          if stderr:
              sys.stderr.write('samtools says: %s' % stderr)
              return None
          mapped_reads = int(stdout)
  
          # write to file so the next time you need the lib size you can access
          # it quickly
          if not os.path.exists(self.fn + '.mmr'):
              fout = open(self.fn + '.mmr', 'w')
              fout.write(str(mapped_reads) + '\n')
              fout.close()
  
          self._readcount = mapped_reads
          return self._readcount