code: def merge_ndx(*args):
      
      ndxs = []
      struct = None
      for fname in args:
          if fname.endswith('.ndx'):
              ndxs.append(fname)
          else:
              if struct is not None:
                  raise ValueError("only one structure file supported")
              struct = fname
  
      fd, multi_ndx = tempfile.mkstemp(suffix='.ndx', prefix='multi_')
      os.close(fd)
      atexit.register(os.unlink, multi_ndx)
  
      if struct:
          make_ndx = registry['Make_ndx'](f=struct, n=ndxs, o=multi_ndx)
      else:
          make_ndx = registry['Make_ndx'](n=ndxs, o=multi_ndx)
  
      _, _, _ = make_ndx(input=['q'], stdout=False, stderr=False)
      return multi_ndx
docs: Takes one or more index files and optionally one structure file and
      returns a path for a new merged index file.
  
      :param args: index files and zero or one structure file
      :return: path for the new merged index file