code: def _open_file(in_file):
      
      _, ext = os.path.splitext(in_file)
      if ext == ".gz":
          return gzip.open(in_file, 'rb')
      if ext in [".fastq", ".fq"]:
          return open(in_file, 'r')
      # default to just opening it
      return open(in_file, "r")
docs: From bcbio code