def mis_mat_cell(conn, chrom1, pos11, pos12, chrom2, pos21, pos22):
  """Get us the number of reads that should have aligned to chrom1 between pos11 and pos12 but ended up aligned to
  chrom2 pos21, pos22

  :param conn:    connection to mis-aligned reads database as produced by perfectbam
  :param chrom1:  correct chrom
  :param pos11:   correct pos lower bound
  :param pos12:   correct pos upper bound
  :param chrom2:  aligned chrom
  :param pos21:   aligned pos lower bound
  :param pos22:   aligned pos upper bound
  :return: integer corresponding to read count
  """
  query = 'SELECT COUNT(*) FROM reads WHERE correct_chrom=? AND ? <= correct_pos AND ? < correct_pos AND aligned_chrom=? AND ? <= aligned_pos AND aligned_pos < ?'
  return conn.execute(query, (chrom1, pos11, pos12, chrom2, pos21, pos22)).next()[0]