import gzip


def read_aids(filename):
  """
  Read AIDs from file.

  Parameters
  ----------
  filename : str
    Filename containing AIDs.
  """
  if filename.endswith('.gz'):
    f = gzip.open(filename)
  else:
    f = open(filename)
  try:
    aids = []
    for line in f:
      if line.strip():
        aids.append(int(line))
  finally:
    f.close()
  return aids