def write(self, format="smi", filename=None, overwrite=False, **kwargs):
        format = format.lower()
        # Use lazy molecule if possible
        if self._source and 'fmt' in self._source and self._source['fmt'] == format and self._source['string']:
            return self._source['string']
        if filename:
            if not overwrite and os.path.isfile(filename):
                raise IOError, "%s already exists. Use 'overwrite=True' to overwrite it." % filename
        if format=="smi" or format=="can":
            result = '%s\t%s\n' % (Chem.MolToSmiles(self.Mol, **kwargs), self.title)
        elif format in ["mol", "sdf"]:
            result = Chem.MolToMolBlock(self.Mol, **kwargs)
        elif format=="mol2":
            result = Chem.MolToMol2Block(self.Mol, **kwargs)
        elif format=="pdb":
            result = Chem.MolToPDBBlock(self.Mol, **kwargs)
        elif format in ('inchi', 'inchikey') and Chem.INCHI_AVAILABLE:
            result = Chem.inchi.MolToInchi(self.Mol, **kwargs)
            if format == 'inchikey':
                result = Chem.inchi.InchiToInchiKey(result, **kwargs)
        else:
            raise ValueError,"%s is not a recognised RDKit format" % format
        if filename:
            print >> open(filename, "w"), result
        else:
            return result
template : template_impl
dataset/ETHPy150Open oddt/oddt/oddt/toolkits/rdk.py/Molecule.write--crossover with--dataset/ETHPy150Open nucleic/enaml/enaml/core/parser.py/p_template1