docs: def download_structure(pdb_id, file_type, outdir='', only_header=False, force_rerun=False):
      """Download a structure from the RCSB PDB by ID. Specify the file type desired.
  
      Args:
          pdb_id: PDB ID
          file_type: pdb, pdb.gz, mmcif, cif, cif.gz, xml.gz, mmtf, mmtf.gz
          outdir: Optional output directory
          only_header: If only the header file should be downloaded
          force_rerun: If the file should be downloaded again even if it exists
  
      Returns:
          str: Path to outfile
  
      """
      # method in biopython. extra file types have not been added to biopython download yet
  
      pdb_id = pdb_id.lower()
      file_type = file_type.lower()
      file_types = ['pdb', 'pdb.gz', 'mmcif', 'cif', 'cif.gz', 'xml.gz', 'mmtf', 'mmtf.gz']
      if file_type not in file_types:
          raise ValueError('Invalid file type, must be either: pdb, pdb.gz, cif, cif.gz, xml.gz, mmtf, mmtf.gz')
  
      if file_type == 'mmtf':
          file_type = 'mmtf.gz'
  
      if file_type.endswith('.gz'):
          gzipped = True
      else:
          gzipped = False
  
      if file_type == 'mmcif':
          file_type = 'cif'
  
      if only_header:
          folder = 'header'
          outfile = op.join(outdir, '{}.header.{}'.format(pdb_id, file_type))
      else:
          folder = 'download'
          outfile = op.join(outdir, '{}.{}'.format(pdb_id, file_type))
  
      if ssbio.utils.force_rerun(flag=force_rerun, outfile=outfile):
          if file_type == 'mmtf.gz' or file_type == 'mmtf':
              mmtf_api = '1.0'
              download_link = 'http://mmtf.rcsb.org/v{}/full/{}.mmtf.gz'.format(mmtf_api, pdb_id)
          else:
              download_link = 'http://files.rcsb.org/{}/{}.{}'.format(folder, pdb_id, file_type)
  
          urlretrieve(download_link, outfile)
  
          if gzipped:
              outfile = ssbio.utils.gunzip_file(infile=outfile,
                                                outfile=outfile.strip('.gz'),
                                                outdir=outdir,
                                                delete_original=False,
                                                force_rerun_flag=force_rerun)
  
          log.debug('{}: saved structure file'.format(outfile))
      else:
          if file_type == 'mmtf.gz':
              outfile = op.join(outdir, '{}.{}'.format(pdb_id, 'mmtf'))
          log.debug('{}: structure file already saved'.format(outfile))
  
      return outfile