Пример #1
0
creators = templates.creators
main_units = {
    'time': 'h',
    'extent': 'mg',
    'substance': 'mg',
    'length': 'm',
    'area': 'm2',
    'volume': UNIT_KIND_LITRE,
}

#########################################################################
# Units
##########################################################################
# units (kind, exponent, scale=0, multiplier=1.0)
units = [
    mc.Unit('h', [(UNIT_KIND_SECOND, 1.0, 0, 3600)]),
    mc.Unit('kg', [(UNIT_KIND_GRAM, 1.0, 3, 1.0)]),
    mc.Unit('m', [(UNIT_KIND_METRE, 1.0)]),
    mc.Unit('m2', [(UNIT_KIND_METRE, 2.0)]),
    mc.Unit('per_h', [(UNIT_KIND_SECOND, -1.0, 0, 3600)]),
    mc.Unit('mg', [(UNIT_KIND_GRAM, 1.0, -3, 1.0)]),
    mc.Unit('mg_per_litre', [(UNIT_KIND_GRAM, 1.0, -3, 1.0),
                             (UNIT_KIND_LITRE, -1.0, 0, 1.0)]),
    mc.Unit('mg_per_g', [(UNIT_KIND_GRAM, 1.0, -3, 1.0),
                         (UNIT_KIND_GRAM, -1.0, 0, 1.0)]),
    mc.Unit('mg_per_h', [(UNIT_KIND_GRAM, 1.0, -3, 1.0),
                         (UNIT_KIND_SECOND, -1.0, 0, 3600)]),
    mc.Unit('litre_per_h', [(UNIT_KIND_LITRE, 1.0, 0, 1.0),
                            (UNIT_KIND_SECOND, -1.0, 0, 3600)]),
    mc.Unit('litre_per_kg', [(UNIT_KIND_LITRE, 1.0, 0, 1.0),
                             (UNIT_KIND_GRAM, -1.0, 3, 1.0)]),
Пример #2
0
def test_modelcreator_notebook():
    """
    If this test fails the respective notebook must be updated:
    :return:
    """

    import libsbml
    from libsbml import (UNIT_KIND_SECOND, UNIT_KIND_ITEM, UNIT_KIND_MOLE,
                         UNIT_KIND_KILOGRAM, UNIT_KIND_METRE, UNIT_KIND_LITRE)

    from sbmlutils import comp
    from sbmlutils import fbc
    from sbmlutils import sbmlio
    from sbmlutils import factory as fac
    from sbmlutils.dfba import builder, utils

    main_units = {
        'time': 's',
        'extent': UNIT_KIND_ITEM,
        'substance': UNIT_KIND_ITEM,
        'length': 'm',
        'area': 'm2',
        'volume': 'm3',
    }
    units = [
        fac.Unit('s', [(UNIT_KIND_SECOND, 1.0)]),
        fac.Unit('item', [(UNIT_KIND_ITEM, 1.0)]),
        fac.Unit('kg', [(UNIT_KIND_KILOGRAM, 1.0)]),
        fac.Unit('m', [(UNIT_KIND_METRE, 1.0)]),
        fac.Unit('m2', [(UNIT_KIND_METRE, 2.0)]),
        fac.Unit('m3', [(UNIT_KIND_METRE, 3.0)]),
        fac.Unit('mM', [(UNIT_KIND_MOLE, 1.0, 0),
                        (UNIT_KIND_METRE, -3.0)]),
        fac.Unit('per_s', [(UNIT_KIND_SECOND, -1.0)]),
        fac.Unit('item_per_s', [(UNIT_KIND_ITEM, 1.0),
                                (UNIT_KIND_SECOND, -1.0)]),
        fac.Unit('item_per_m3', [(UNIT_KIND_ITEM, 1.0),
                                 (UNIT_KIND_METRE, -3.0)]),
    ]

    UNIT_TIME = 's'
    UNIT_AMOUNT = 'item'
    UNIT_AREA = 'm2'
    UNIT_VOLUME = 'm3'
    UNIT_CONCENTRATION = 'item_per_m3'
    UNIT_FLUX = 'item_per_s'

    # Create SBMLDocument with fba
    doc = builder.template_doc_fba(model_id="toy")
    model = doc.getModel()

    utils.set_units(model, units)
    utils.set_main_units(model, main_units)

    objects = [
        # compartments
        fac.Compartment(sid='extern', value=1.0, unit=UNIT_VOLUME, constant=True, name='external compartment',
                        spatialDimensions=3),
        fac.Compartment(sid='cell', value=1.0, unit=UNIT_VOLUME, constant=True, name='cell', spatialDimensions=3),
        fac.Compartment(sid='membrane', value=1.0, unit=UNIT_AREA, constant=True, name='membrane', spatialDimensions=2),

        # exchange species
        fac.Species(sid='A', name="A", value=0, substanceUnit=UNIT_AMOUNT, hasOnlySubstanceUnits=True,
                    compartment="extern"),
        fac.Species(sid='C', name="C", value=0, substanceUnit=UNIT_AMOUNT, hasOnlySubstanceUnits=True,
                    compartment="extern"),

        # internal species
        fac.Species(sid='B1', name="B1", value=0, substanceUnit=UNIT_AMOUNT, hasOnlySubstanceUnits=True,
                    compartment="cell"),
        fac.Species(sid='B2', name="B2", value=0, substanceUnit=UNIT_AMOUNT, hasOnlySubstanceUnits=True,
                    compartment="cell"),

        # bounds
        fac.Parameter(sid="ub_R1", value=1.0, unit=UNIT_FLUX, constant=True, sboTerm=builder.FLUX_BOUND_SBO),
        fac.Parameter(sid="zero", value=0.0, unit=UNIT_FLUX, constant=True, sboTerm=builder.FLUX_BOUND_SBO),
        fac.Parameter(sid="ub_default", value=builder.UPPER_BOUND_DEFAULT, unit=UNIT_FLUX, constant=True,
                      sboTerm=builder.FLUX_BOUND_SBO),
    ]
    fac.create_objects(model, objects)

    # reactions
    r1 = fac.create_reaction(model, rid="R1", name="A import (R1)", fast=False, reversible=True,
                             reactants={"A": 1}, products={"B1": 1}, compartment='membrane')
    r2 = fac.create_reaction(model, rid="R2", name="B1 <-> B2 (R2)", fast=False, reversible=True,
                             reactants={"B1": 1}, products={"B2": 1}, compartment='cell')
    r3 = fac.create_reaction(model, rid="R3", name="B2 export (R3)", fast=False, reversible=True,
                             reactants={"B2": 1}, products={"C": 1}, compartment='membrane')

    # flux bounds
    fbc.set_flux_bounds(r1, lb="zero", ub="ub_R1")
    fbc.set_flux_bounds(r2, lb="zero", ub="ub_default")
    fbc.set_flux_bounds(r3, lb="zero", ub="ub_default")

    # exchange reactions
    builder.create_exchange_reaction(model, species_id="A", flux_unit=UNIT_FLUX)
    builder.create_exchange_reaction(model, species_id="C", flux_unit=UNIT_FLUX)

    # objective function
    model_fbc = model.getPlugin("fbc")
    fac.create_objective(model_fbc, oid="R3_maximize", otype="maximize",
                         fluxObjectives={"R3": 1.0}, active=True)

    # write SBML file
    import tempfile
    sbml_file = tempfile.NamedTemporaryFile(suffix=".xml")
    sbmlio.write_sbml(doc=doc, filepath=sbml_file.name)
Пример #3
0
creators = [
    mc.Creator(familyName='Koenig', givenName='Matthias', email='*****@*****.**',
               organization='Humboldt University Berlin', site='http://livermetabolism.com')
]

main_units = {
    'time': 'h',
    'extent': 'mmol',
    'substance': 'mmol',
    'length': 'm',
    'area': 'm2',
    'volume': 'l',
}
units = [
    mc.Unit('h', [(UNIT_KIND_SECOND, 1.0, 0, 3600)]),
    mc.Unit('g', [(UNIT_KIND_GRAM, 1.0)]),
    mc.Unit('m', [(UNIT_KIND_METRE, 1.0)]),
    mc.Unit('m2', [(UNIT_KIND_METRE, 2.0)]),
    mc.Unit('l', [(UNIT_KIND_LITRE, 1.0)]),
    mc.Unit('mmol', [(UNIT_KIND_MOLE, 1.0, -3, 1.0)]),
    mc.Unit('per_h', [(UNIT_KIND_SECOND, -1.0, 0, 3600)]),
    mc.Unit('mmol_per_h', [(UNIT_KIND_MOLE, 1.0, -3, 1.0),
                           (UNIT_KIND_SECOND, -1.0, 0, 3600)]),
    mc.Unit('mmol_per_l', [(UNIT_KIND_MOLE, 1.0, -3, 1.0),
                           (UNIT_KIND_LITRE, -1.0)]),
    mc.Unit('l_per_mmol', [(UNIT_KIND_LITRE, 1.0),
                           (UNIT_KIND_MOLE, -1.0, -3, 1.0)]),
    mc.Unit('g_per_l', [(UNIT_KIND_GRAM, 1.0),
                        (UNIT_KIND_LITRE, -1.0)]),
    mc.Unit('g_per_mmol', [(UNIT_KIND_GRAM, 1.0),
Пример #4
0
    """)

main_units = {
    'time': 'min',
    'extent': UNIT_KIND_MOLE,  # change to mg
    'substance': UNIT_KIND_MOLE,  # change to mg
    'length': 'm',
    'area': 'm2',
    'volume': 'm3',
}

#########################################################################
# Units
##########################################################################
units = [
    mc.Unit('kg', [(UNIT_KIND_KILOGRAM, 1.0)]),
    mc.Unit('m', [(UNIT_KIND_METRE, 1.0)]),
    mc.Unit('m2', [(UNIT_KIND_METRE, 2.0)]),
    mc.Unit('m3', [(UNIT_KIND_METRE, 3.0)]),
    mc.Unit('min', [(UNIT_KIND_SECOND, 1.0, 0, 60)]),
    mc.Unit('per_min', [(UNIT_KIND_SECOND, -1.0, 0, 60)]),
    mc.Unit('l_per_kg', [(UNIT_KIND_LITRE, 1.0), (UNIT_KIND_KILOGRAM, -1.0)]),
    mc.Unit('dl_per_kg', [(UNIT_KIND_LITRE, 1.0, -1, 1.0),
                          (UNIT_KIND_KILOGRAM, -1.0)]),
    mc.Unit('mg_per_kg', [(UNIT_KIND_GRAM, 1.0, -3, 1.0),
                          (UNIT_KIND_KILOGRAM, -1.0)]),
    mc.Unit('mg_per_dl', [(UNIT_KIND_GRAM, 1.0, -3, 1.0),
                          (UNIT_KIND_LITRE, -1.0, -1, 1.0)]),
    mc.Unit('pmol_per_kg', [(UNIT_KIND_MOLE, 1.0, -9, 1.0),
                            (UNIT_KIND_KILOGRAM, -1.0)]),
    mc.Unit('pmol_per_l', [(UNIT_KIND_MOLE, 1.0, -9, 1.0),
Пример #5
0
    'volume': 'm3',
}
units = list()
species = list()
parameters = list()
names = list()
assignments = list()
rules = list()
reactions = list()

#########################################################################
# Units
##########################################################################
# units (kind, exponent, scale=0, multiplier=1.0)
units.extend([
    mc.Unit('s', [(UNIT_KIND_SECOND, 1.0)]),
    mc.Unit('kg', [(UNIT_KIND_KILOGRAM, 1.0)]),
    mc.Unit('m', [(UNIT_KIND_METRE, 1.0)]),
    mc.Unit('m2', [(UNIT_KIND_METRE, 2.0)]),
    mc.Unit('m3', [(UNIT_KIND_METRE, 3.0)]),
    mc.Unit('per_s', [(UNIT_KIND_SECOND, -1.0)]),
    mc.Unit('mole_per_s', [(UNIT_KIND_MOLE, 1.0), (UNIT_KIND_SECOND, -1.0)]),
    mc.Unit('mole_per_s_per_mM', [(UNIT_KIND_METRE, 3.0),
                                  (UNIT_KIND_SECOND, -1.0)]),
    mc.Unit('mole_per_s_per_mM2', [(UNIT_KIND_MOLE, -1.0),
                                   (UNIT_KIND_METRE, 6.0),
                                   (UNIT_KIND_SECOND, -1.0)]),
    mc.Unit('m_per_s', [(UNIT_KIND_METRE, 1.0), (UNIT_KIND_SECOND, -1.0)]),
    mc.Unit('m2_per_s', [(UNIT_KIND_METRE, 2.0), (UNIT_KIND_SECOND, -1.0)]),
    mc.Unit('m3_per_s', [(UNIT_KIND_METRE, 3.0), (UNIT_KIND_SECOND, -1.0)]),
    mc.Unit('mM', [(UNIT_KIND_MOLE, 1.0, 0), (UNIT_KIND_METRE, -3.0)]),
#########################################################################
# Units
##########################################################################
main_units = {
    'time': 'h',
    'extent': 'mmole',
    'substance': 'mmole',
    'length': 'm',
    'area': 'm2',
    'volume': UNIT_KIND_LITRE,
}

# units (kind, exponent, scale=0, multiplier=1.0)
units = [
    mc.Unit('h', [(UNIT_KIND_SECOND, 1.0, 0, 3600)]),
    mc.Unit('s', [(UNIT_KIND_SECOND, 1.0, 0, 1)]),
    mc.Unit('kg', [(UNIT_KIND_GRAM, 1.0, 3, 1.0)]),
    mc.Unit('m', [(UNIT_KIND_METRE, 1.0)]),
    mc.Unit('m2', [(UNIT_KIND_METRE, 2.0)]),
    mc.Unit('per_h', [(UNIT_KIND_SECOND, -1.0, 0, 3600)]),
    mc.Unit('per_min', [(UNIT_KIND_SECOND, -1.0, 0, 60)]),
    mc.Unit('cm', [(UNIT_KIND_METRE, 1.0, -2, 1.0)]),
    mc.Unit('mg', [(UNIT_KIND_GRAM, 1.0, -3, 1.0)]),
    mc.Unit('mmole', [(UNIT_KIND_MOLE, 1.0, -3, 1)]),
    mc.Unit('ml', [(UNIT_KIND_LITRE, 1.0, -3, 1.0)]),
    mc.Unit('mg_per_litre', [(UNIT_KIND_GRAM, 1.0, -3, 1.0),
                             (UNIT_KIND_LITRE, -1.0, 0, 1.0)]),
    mc.Unit('mg_per_g', [(UNIT_KIND_GRAM, 1.0, -3, 1.0),
                         (UNIT_KIND_GRAM, -1.0, 0, 1.0)]),
    mc.Unit('mg_per_h', [(UNIT_KIND_GRAM, 1.0, -3, 1.0),
Пример #7
0
main_units = {
    'time': 'h',
    'extent': 'mmole',
    'substance': 'mmole',
    'length': 'm',
    'area': 'm2',
    'volume': UNIT_KIND_LITRE,
}
ports = []

#########################################################################
# Units
##########################################################################
# units (kind, exponent, scale=0, multiplier=1.0)
units = [
    mc.Unit('h', [(UNIT_KIND_SECOND, 1.0, 0, 3600)]),
    mc.Unit('s', [(UNIT_KIND_SECOND, 1.0, 0, 1)]),
    mc.Unit('kg', [(UNIT_KIND_GRAM, 1.0, 3, 1.0)]),
    mc.Unit('m', [(UNIT_KIND_METRE, 1.0)]),
    mc.Unit('m2', [(UNIT_KIND_METRE, 2.0)]),
    mc.Unit('per_h', [(UNIT_KIND_SECOND, -1.0, 0, 3600)]),
    mc.Unit('per_min', [(UNIT_KIND_SECOND, -1.0, 0, 60)]),
    mc.Unit('mg', [(UNIT_KIND_GRAM, 1.0, -3, 1.0)]),
    mc.Unit('ml', [(UNIT_KIND_LITRE, 1.0, -3, 1.0)]),
    mc.Unit('mmole', [(UNIT_KIND_MOLE, 1.0, -3, 1)]),
    mc.Unit('mM', [(UNIT_KIND_MOLE, 1.0, -3, 1),
                   (UNIT_KIND_LITRE, -1.0, 0, 1)]),
    mc.Unit('mmole_per_h', [(UNIT_KIND_MOLE, 1.0, -3, 1),
                            (UNIT_KIND_SECOND, -1.0, 0, 3600)]),
    mc.Unit('g_per_mole', [(UNIT_KIND_GRAM, 1.0, 0, 1.0),
                           (UNIT_KIND_MOLE, -1.0, 0, 1)]),
Пример #8
0
    mc.Creator(familyName='Koenig',
               givenName='Matthias',
               email='*****@*****.**',
               organization='Humboldt University Berlin',
               site='http://livermetabolism.com')
]
main_units = {
    'time': 'h',
    'extent': 'mmole',
    'substance': 'mmole',
    'length': 'm',
    'area': 'm2',
    'volume': UNIT_KIND_LITRE,
}
units = [
    mc.Unit('h', [(UNIT_KIND_SECOND, 1.0, 0, 3600)], name="hour"),
    mc.Unit('kg', [(UNIT_KIND_KILOGRAM, 1.0)], name="kilogram"),
    mc.Unit('m', [(UNIT_KIND_METRE, 1.0)], name="meter"),
    mc.Unit('m2', [(UNIT_KIND_METRE, 2.0)], name="square meter"),
    mc.Unit('m3', [(UNIT_KIND_METRE, 3.0)], name="cubic meter"),
    mc.Unit('mmole', [(UNIT_KIND_MOLE, 1.0, -3, 1)]),
    mc.Unit('mM', [(UNIT_KIND_MOLE, 1.0, -3, 1), (UNIT_KIND_LITRE, -1.0)],
            name="millimolar"),
    mc.Unit('mmole_per_h', [(UNIT_KIND_MOLE, 1.0, -3, 1),
                            (UNIT_KIND_SECOND, -1.0, 0, 3600)]),
]

UNIT_TIME = 'h'
UNIT_AREA = 'm2'
UNIT_VOLUME = UNIT_KIND_LITRE
UNIT_AMOUNT = 'mmole'
Пример #9
0
    </body>
""".format(settings.VERSION, '{}')
creators = [
    mc.Creator(familyName='Koenig', givenName='Matthias', email='*****@*****.**',
               organization='Humboldt University Berlin', site='http://livermetabolism.com')
]
main_units = {
    'time': 's',
    'extent': UNIT_KIND_ITEM,
    'substance': UNIT_KIND_ITEM,
    'length': 'm',
    'area': 'm2',
    'volume': 'm3',
}
units = [
    mc.Unit('s', [(UNIT_KIND_SECOND, 1.0)], name="second"),
    mc.Unit('kg', [(UNIT_KIND_KILOGRAM, 1.0)], name="kilogram"),

    mc.Unit('m', [(UNIT_KIND_METRE, 1.0)], name="meter"),
    mc.Unit('m2', [(UNIT_KIND_METRE, 2.0)], name="square meter"),
    mc.Unit('m3', [(UNIT_KIND_METRE, 3.0)], name="cubic meter"),
    mc.Unit('mM', [(UNIT_KIND_MOLE, 1.0, 0),
                   (UNIT_KIND_METRE, -3.0)], name="millimolar"),
    mc.Unit('per_s', [(UNIT_KIND_SECOND, -1.0)]),
    mc.Unit('item_per_s', [(UNIT_KIND_ITEM, 1.0),
                           (UNIT_KIND_SECOND, -1.0)]),
    mc.Unit('item_per_m3', [(UNIT_KIND_ITEM, 1.0),
                            (UNIT_KIND_METRE, -3.0)]),
]

UNIT_TIME = 's'