parameters: (mol, filename, size=(300, 300), kekulize=True, wedgeBonds=True, imageType=None,
                fitImage=False, options=None, **kwargs)
docstring: Generates a drawing of a molecule and writes it to a file
docstring_summary: Generates a drawing of a molecule and writes it to a file
docstring_tokens: Generates a drawing of a molecule and writes it to a file
function: def MolToFile(mol, filename, size=(300, 300), kekulize=True, wedgeBonds=True, imageType=None,
                fitImage=False, options=None, **kwargs):
    """ Generates a drawing of a molecule and writes it to a file
    """
    # original contribution from Uwe Hoffmann
    if not filename:
      raise ValueError('no filename provided')
    if not mol:
      raise ValueError('Null molecule provided')
  
    if imageType is None:
      imageType = os.path.splitext(filename)[1][1:]
  
    if imageType not in ('svg', 'png'):
      _legacyMolToFile(mol, filename, size, kekulize, wedgeBonds, imageType, fitImage, options,
                       **kwargs)
  
    if type(options) == DrawingOptions:
      warnings.warn(
        "legacy DrawingOptions not translated for new drawing code, please update manually",
        DeprecationWarning)
      options = None
    if imageType == 'png':
      drawfn = _moltoimg
      mode = 'b'
    elif imageType == 'svg':
      drawfn = _moltoSVG
      mode = 't'
    else:
      raise ValueError("unsupported output format")
    data = drawfn(mol, size, kwargs.get('highlightAtoms', []), kwargs.get('legend', ''),
                  highlightBonds=kwargs.get('highlightBonds', []), drawOptions=options,
                  kekulize=kekulize, wedgeBonds=wedgeBonds, returnPNG=True)
    with open(filename, 'w+' + mode) as outf:
      outf.write(data)
      outf.close()
function_tokens: def MolToFile ( mol , filename , size = ( 300 , 300 ) , kekulize = True , wedgeBonds = True , imageType = None , fitImage = False , options = None , * * kwargs ) : # original contribution from Uwe Hoffmann if not filename : raise ValueError ( 'no filename provided' ) if not mol : raise ValueError ( 'Null molecule provided' ) if imageType is None : imageType = os . path . splitext ( filename ) [ 1 ] [ 1 : ] if imageType not in ( 'svg' , 'png' ) : _legacyMolToFile ( mol , filename , size , kekulize , wedgeBonds , imageType , fitImage , options , * * kwargs ) if type ( options ) == DrawingOptions : warnings . warn ( "legacy DrawingOptions not translated for new drawing code, please update manually" , DeprecationWarning ) options = None if imageType == 'png' : drawfn = _moltoimg mode = 'b' elif imageType == 'svg' : drawfn = _moltoSVG mode = 't' else : raise ValueError ( "unsupported output format" ) data = drawfn ( mol , size , kwargs . get ( 'highlightAtoms' , [ ] ) , kwargs . get ( 'legend' , '' ) , highlightBonds = kwargs . get ( 'highlightBonds' , [ ] ) , drawOptions = options , kekulize = kekulize , wedgeBonds = wedgeBonds , returnPNG = True ) with open ( filename , 'w+' + mode ) as outf : outf . write ( data ) outf . close ( )