def write_sbml_model(cobra_model, filename, f_replace=F_REPLACE, **kwargs):
doc = _model_to_sbml(cobra_model, f_replace=f_replace, **kwargs)<EOL>if isinstance(filename, string_types):<EOL><INDENT>libsbml.writeSBMLToFile(doc, filename)<EOL><DEDENT>elif hasattr(filename, "<STR_LIT>"):<EOL><INDENT>sbml_str = libsbml.writeSBMLToString(doc)<EOL>filename.write(sbml_str)<EOL><DEDENT>
Writes cobra model to filename.

    The created model is SBML level 3 version 1 (L1V3) with
    fbc package v2 (fbc-v2).

    If the given filename ends with the suffix ".gz" (for example,
    "myfile.xml.gz"), libSBML assumes the caller wants the file to be
    written compressed in gzip format. Similarly, if the given filename
    ends with ".zip" or ".bz2", libSBML assumes the caller wants the
    file to be compressed in zip or bzip2 format (respectively). Files
    whose names lack these suffixes will be written uncompressed. Special
    considerations for the zip format: If the given filename ends with
    ".zip", the file placed in the zip archive will have the suffix
    ".xml" or ".sbml".  For example, the file in the zip archive will
    be named "test.xml" if the given filename is "test.xml.zip" or
    "test.zip". Similarly, the filename in the archive will be
    "test.sbml" if the given filename is "test.sbml.zip".

    Parameters
    ----------
    cobra_model : cobra.core.Model
        Model instance which is written to SBML
    filename : string
        path to which the model is written
    use_fbc_package : boolean {True, False}
        should the fbc package be used
    f_replace: dict of replacement functions for id replacement