def read_fp(filename, dtype=int):
  """ read fingerprint from file
  Args:
    filename: <type 'str'>
  Return:
    chembl_id_list: <type 'list'>, a list of str
    fps_list: <type 'list'>, a list of dict.
  """
  chembl_id_list = []
  fps_list = []
  infile = open(filename, "r")
  line_num = 0
  for line in infile:
    line_num += 1
    chembl_id = line.split("\t")[0].strip()
    fps_str = line.split("\t")[1].strip()
    fps = {}
    fps_str = fps_str[1:-1].split(",")
    for fp in fps_str:
      if ":" in fp:
        k, v = fp.split(":")
        k = dtype(k.strip())
        v = dtype(v.strip())
        assert k not in fps.keys(), ("error in fp_file %s at line %d: dict's keys duplicated" % (filename, line_num))
        fps[k] = v 
    chembl_id_list.append(chembl_id)
    fps_list.append(fps)
  infile.close()
  return chembl_id_list, fps_list