docs: def download_genome(self, name, genome_dir, localname=None, mask="soft", regex=None, invert_match=False, version=None):
          """
          Download a (gzipped) genome file to a specific directory
  
          Parameters
          ----------
          name : str
              Genome / species name
          
          genome_dir : str
              Directory to install genome
  
          mask: str , optional
              Masking, soft, hard or none (all other strings)
          """
          genome_dir = os.path.expanduser(genome_dir)
          
          if not os.path.exists(genome_dir):
              os.makedirs(genome_dir)
          
          dbname, link = self.get_genome_download_link(name, mask=mask, version=version)
          myname = dbname 
          if localname:
              myname = localname
          
          myname = myname.replace(" ", "_")
  
          gzipped = False
          if link.endswith(".gz"):
              gzipped = True
  
          if not os.path.exists(os.path.join(genome_dir, myname)):
              os.makedirs(os.path.join(genome_dir, myname))
          urlcleanup()
          response = urlopen(link)
           
          sys.stderr.write("downloading from {}...\n".format(link))
          down_dir = genome_dir
          fname = os.path.join(genome_dir, myname, myname + ".fa")
          if regex:
              down_dir = mkdtemp()
              os.mkdir(os.path.join(down_dir, myname))
              fname = os.path.join(down_dir, myname, myname + ".fa") 
          with open(fname, "wb") as f_out:
              if gzipped:
                  # Supports both Python 2.7 as well as 3
                  with gzip.GzipFile(fileobj=io.BytesIO(response.read())) as f_in:
                      shutil.copyfileobj(f_in, f_out)
              else:
                  f_out.write(response.read())
          sys.stderr.write("done...\n")
          
          if link.endswith("tar.gz"):
              self.tar_to_bigfile(fname, fname) 
          
          if hasattr(self, '_post_process_download'):
              self._post_process_download(name, down_dir, mask)
          
          if regex:
              infa = fname
              outfa = os.path.join(genome_dir, myname, myname + ".fa") 
              filter_fasta(
                  infa,
                  outfa,
                  regex=regex,
                  v=invert_match,
                  force=True
                  )
  
              not_included = [k for k in Fasta(infa).keys() if k not in Fasta(outfa).keys()]
              shutil.rmtree(down_dir)
              fname = outfa
          
          sys.stderr.write("name: {}\n".format(dbname))
          sys.stderr.write("local name: {}\n".format(myname))
          sys.stderr.write("fasta: {}\n".format(fname))
  
          # Create readme with information
          readme = os.path.join(genome_dir, myname, "README.txt")
          with open(readme, "w") as f:
              f.write("name: {}\n".format(myname))
              f.write("original name: {}\n".format(dbname))
              f.write("original filename: {}\n".format(os.path.split(link)[-1]))
              f.write("url: {}\n".format(link))
              f.write("mask: {}\n".format(mask))
              f.write("date: {}\n".format(time.strftime("%Y-%m-%d %H:%M:%S")))
              if regex:
                  if invert_match:
                      f.write("regex: {} (inverted match)\n".format(regex))
                  else:
                      f.write("regex: {}\n".format(regex))
                  f.write("sequences that were excluded:\n")
                  for seq in not_included:
                      f.write("\t{}\n".format(seq))