def create_model(output_dir):
    """ Create all submodels and comp model.

    :param output_dir: results directory
    :rtype:
    :return directory in which model files exist.
    """
    f_annotations = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'annotations.xlsx')
    annotations = annotation.ModelAnnotator.annotations_from_file(f_annotations)

    directory = utils.versioned_directory(output_dir, version=settings.VERSION)

    # create sbml
    doc_fba = fba_model(settings.FBA_LOCATION, directory, annotations=annotations)

    bounds_model(settings.BOUNDS_LOCATION, directory, doc_fba=doc_fba, annotations=annotations)

    update_model(settings.UPDATE_LOCATION, directory, doc_fba=doc_fba, annotations=annotations)

    emds = {
        "{}_fba".format(settings.MODEL_ID): settings.FBA_LOCATION,
        "{}_bounds".format(settings.MODEL_ID): settings.BOUNDS_LOCATION,
        "{}_update".format(settings.MODEL_ID): settings.UPDATE_LOCATION,
    }

    # flatten top model
    top_model(settings.TOP_LOCATION, directory, emds, doc_fba, annotations=annotations)
    comp.flattenSBMLFile(sbml_path=pjoin(directory, settings.TOP_LOCATION),
                         output_path=pjoin(directory, settings.FLATTENED_LOCATION))

    # create reports
    locations = [
        settings.FBA_LOCATION,
        settings.BOUNDS_LOCATION,
        settings.UPDATE_LOCATION,
        settings.TOP_LOCATION,
        settings.FLATTENED_LOCATION
    ]

    sbml_paths = [pjoin(directory, fname) for fname in locations]
    sbmlreport.create_sbml_reports(sbml_paths, directory, validate=False)

    # create sedml
    from sbmlutils.dfba.sedml import create_sedml
    species_ids = ", ".join(['atp', 'adp', 'glc', 'pyr'])
    reaction_ids = ", ".join(['EX_atp', 'EX_adp', 'EX_glc', 'EX_pyr', 'RATP'])
    create_sedml(settings.SEDML_LOCATION, settings.TOP_LOCATION, directory=directory,
                 dt=0.1, tend=15, species_ids=species_ids, reaction_ids=reaction_ids)

    return directory
Exemple #2
0
def create_model(output_dir):
    """ Create all submodels and comp model.

    :param output_dir: results directory
    :rtype:
    :return directory in which model files exist.
    """
    directory = utils.versioned_directory(output_dir, version=settings.VERSION)

    f_annotations = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 settings.ANNOTATIONS_LOCATION)
    annotations = annotator.ModelAnnotator.read_annotations(f_annotations)


    # create sbml
    doc_fba = fba_model(settings.FBA_LOCATION, directory, annotations=annotations)
    bounds_model(settings.BOUNDS_LOCATION, directory, doc_fba=doc_fba, annotations=annotations)
    update_model(settings.UPDATE_LOCATION, directory, doc_fba=doc_fba, annotations=annotations)

    emds = {
        "{}_fba".format(settings.MODEL_ID): settings.FBA_LOCATION,
        "{}_bounds".format(settings.MODEL_ID): settings.BOUNDS_LOCATION,
        "{}_update".format(settings.MODEL_ID): settings.UPDATE_LOCATION,
    }

    # flatten top model
    top_model(settings.TOP_LOCATION, directory, emds, doc_fba, annotations=annotations)
    comp.flattenSBMLFile(sbml_path=pjoin(directory, settings.TOP_LOCATION),
                         output_path=pjoin(directory, settings.FLATTENED_LOCATION))
    # create reports
    locations = [
        settings.FBA_LOCATION,
        settings.BOUNDS_LOCATION,
        settings.UPDATE_LOCATION,
        settings.TOP_LOCATION,
        settings.FLATTENED_LOCATION
    ]

    sbml_paths = [pjoin(directory, fname) for fname in locations]
    sbmlreport.create_reports(sbml_paths, directory, validate=False)

    # create sedml
    from sbmlutils.dfba.sedml import create_sedml
    species_ids = ", ".join(['A', 'C', 'D'])
    reaction_ids = ", ".join(['R4', 'EX_A', 'EX_C'])
    create_sedml(settings.SEDML_LOCATION, settings.TOP_LOCATION, directory=directory,
                 dt=0.1, tend=50, species_ids=species_ids, reaction_ids=reaction_ids)

    return directory
def create_model(output_dir):
    """ Create all models.

    :return:
    """
    directory = utils.versioned_directory(output_dir, version=settings.VERSION)

    f_annotations = os.path.join(os.path.dirname(os.path.abspath(__file__)), settings.ANNOTATIONS_LOCATION)
    annotations = annotation.ModelAnnotator.annotations_from_file(f_annotations)

    # create sbml
    doc_fba = fba_model(settings.FBA_LOCATION, directory, annotations=annotations)
    bounds_model(settings.BOUNDS_LOCATION, directory, doc_fba=doc_fba, annotations=annotations)
    update_model(settings.UPDATE_LOCATION, directory, doc_fba=doc_fba, annotations=annotations)
    emds = {
        "diauxic_fba": settings.FBA_LOCATION,
        "diauxic_bounds": settings.BOUNDS_LOCATION,
        "diauxic_update": settings.UPDATE_LOCATION,
    }
    top_model(settings.TOP_LOCATION, directory, emds, doc_fba=doc_fba, annotations=annotations)

    # flatten top model
    comp.flattenSBMLFile(sbml_path=pjoin(directory, settings.TOP_LOCATION),
                         output_path=pjoin(directory, settings.FLATTENED_LOCATION))

    # create reports
    locations = [
        settings.FBA_LOCATION,
        settings.BOUNDS_LOCATION,
        settings.UPDATE_LOCATION,
        settings.TOP_LOCATION,
        settings.FLATTENED_LOCATION
    ]

    sbml_paths = [pjoin(directory, fname) for fname in locations]
    sbmlreport.create_sbml_reports(sbml_paths, directory, validate=False)

    # create sedml
    from sbmlutils.dfba.sedml import create_sedml
    species_ids = ", ".join(['Ac', 'Glcxt', 'O2', 'X'])
    reaction_ids = ", ".join(['vO2_transfer', 'EX_Ac', 'EX_Glcxt', 'EX_O2', 'EX_X'])
    create_sedml(settings.SEDML_LOCATION, settings.TOP_LOCATION, directory=directory,
                 dt=0.01, tend=15, species_ids=species_ids, reaction_ids=reaction_ids)

    return directory
Exemple #4
0
def create_model(output_dir):
    """ Create all models.

    :return: directory where SBML files are located
    """
    directory = utils.versioned_directory(output_dir, version=settings.VERSION)

    # create sbml
    import time
    t_start = time.time()

    doc_fba = fba_model(settings.FBA_LOCATION, directory)
    t_fba = time.time()
    print('{:<10}: {:3.2f}'.format('fba', t_fba - t_start))

    bounds_model(settings.BOUNDS_LOCATION, directory, doc_fba=doc_fba)
    t_bounds = time.time()
    print('{:<10}: {:3.2f}'.format('bounds', t_bounds - t_fba))

    update_model(settings.UPDATE_LOCATION, directory, doc_fba=doc_fba)
    t_update = time.time()
    print('{:<10}: {:3.2f}'.format('update', t_update - t_bounds))

    emds = {
        "ecoli_fba": settings.FBA_LOCATION,
        "ecoli_bounds": settings.BOUNDS_LOCATION,
        "ecoli_update": settings.UPDATE_LOCATION,
    }

    # flatten top model
    top_model(settings.TOP_LOCATION, directory, emds, doc_fba=doc_fba)
    t_top = time.time()
    print('{:<10}: {:3.2f}'.format('top', t_top - t_update))

    comp.flattenSBMLFile(sbml_path=pjoin(directory, settings.TOP_LOCATION),
                         output_path=pjoin(directory,
                                           settings.FLATTENED_LOCATION))
    t_flat = time.time()
    print('{:<10}: {:3.2f}'.format('flat', t_flat - t_top))

    # create reports
    locations = [
        settings.FBA_LOCATION, settings.BOUNDS_LOCATION,
        settings.UPDATE_LOCATION, settings.TOP_LOCATION,
        settings.FLATTENED_LOCATION
    ]

    sbml_paths = [pjoin(directory, fname) for fname in locations]
    sbmlreport.create_reports(sbml_paths, directory, validate=False)

    # create sedml
    from sbmlutils.dfba.sedml import create_sedml
    sids = [
        'ac_e', 'acald_e', 'akg_e', 'co2_e', 'etoh_e', 'for_e', 'fru_e',
        'fum_e', 'glc__D_e', 'gln__L_e', 'glu__L_e', 'h_e', 'h2o_e',
        'lac__D_e', 'mal__L_e', 'nh4_e', 'o2_e', 'pi_e', 'pyr_e', 'succ_e', 'X'
    ]
    species_ids = ", ".join(sids)
    reaction_ids = ", ".join(['EX_{}'.format(sid) for sid in sids])
    create_sedml(settings.SEDML_LOCATION,
                 settings.TOP_LOCATION,
                 directory=directory,
                 dt=0.01,
                 tend=3.5,
                 species_ids=species_ids,
                 reaction_ids=reaction_ids)

    return directory
def create_model(output_dir):
    """ Create all models.

    :return: directory where SBML files are located
    """
    directory = utils.versioned_directory(output_dir, version=settings.VERSION)

    # create sbml
    import time
    t_start = time.time()

    doc_fba = fba_model(settings.FBA_LOCATION, directory)
    t_fba = time.time()
    print('{:<10}: {:3.2f}'.format('fba', t_fba-t_start))

    bounds_model(settings.BOUNDS_LOCATION, directory, doc_fba=doc_fba)
    t_bounds = time.time()
    print('{:<10}: {:3.2f}'.format('bounds', t_bounds-t_fba))

    update_model(settings.UPDATE_LOCATION, directory, doc_fba=doc_fba)
    t_update = time.time()
    print('{:<10}: {:3.2f}'.format('update', t_update-t_bounds))

    emds = {
        "ecoli_fba": settings.FBA_LOCATION,
        "ecoli_bounds": settings.BOUNDS_LOCATION,
        "ecoli_update": settings.UPDATE_LOCATION,
    }

    # flatten top model
    top_model(settings.TOP_LOCATION, directory, emds, doc_fba=doc_fba)
    t_top = time.time()
    print('{:<10}: {:3.2f}'.format('top', t_top-t_update))

    comp.flattenSBMLFile(sbml_path=pjoin(directory, settings.TOP_LOCATION),
                         output_path=pjoin(directory, settings.FLATTENED_LOCATION))
    t_flat = time.time()
    print('{:<10}: {:3.2f}'.format('flat', t_flat-t_top))

    # create reports
    locations = [
        settings.FBA_LOCATION,
        settings.BOUNDS_LOCATION,
        settings.UPDATE_LOCATION,
        settings.TOP_LOCATION,
        settings.FLATTENED_LOCATION
    ]

    sbml_paths = [pjoin(directory, fname) for fname in locations]
    sbmlreport.create_sbml_reports(sbml_paths, directory, validate=False)

    # create sedml
    from sbmlutils.dfba.sedml import create_sedml
    sids = ['ac_e', 'acald_e', 'akg_e', 'co2_e', 'etoh_e', 'for_e', 'fru_e', 'fum_e', 'glc__D_e',
            'gln__L_e', 'glu__L_e', 'h_e', 'h2o_e', 'lac__D_e', 'mal__L_e', 'nh4_e', 'o2_e', 'pi_e',
            'pyr_e', 'succ_e', 'X']
    species_ids = ", ".join(sids)
    reaction_ids = ", ".join(['EX_{}'.format(sid) for sid in sids])
    create_sedml(settings.SEDML_LOCATION, settings.TOP_LOCATION, directory=directory,
                 dt=0.01, tend=3.5, species_ids=species_ids, reaction_ids=reaction_ids)

    return directory
def create_model(output_dir):
    """ Create all models.

    :return:
    """
    directory = utils.versioned_directory(output_dir, version=settings.VERSION)

    f_annotations = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 settings.ANNOTATIONS_LOCATION)
    annotations = annotator.ModelAnnotator.annotations_from_file(f_annotations)

    # create sbml
    doc_fba = fba_model(settings.FBA_LOCATION,
                        directory,
                        annotations=annotations)
    bounds_model(settings.BOUNDS_LOCATION,
                 directory,
                 doc_fba=doc_fba,
                 annotations=annotations)
    update_model(settings.UPDATE_LOCATION,
                 directory,
                 doc_fba=doc_fba,
                 annotations=annotations)
    emds = {
        "diauxic_fba": settings.FBA_LOCATION,
        "diauxic_bounds": settings.BOUNDS_LOCATION,
        "diauxic_update": settings.UPDATE_LOCATION,
    }
    top_model(settings.TOP_LOCATION,
              directory,
              emds,
              doc_fba=doc_fba,
              annotations=annotations)

    # flatten top model
    comp.flattenSBMLFile(sbml_path=pjoin(directory, settings.TOP_LOCATION),
                         output_path=pjoin(directory,
                                           settings.FLATTENED_LOCATION))

    # create reports
    locations = [
        settings.FBA_LOCATION, settings.BOUNDS_LOCATION,
        settings.UPDATE_LOCATION, settings.TOP_LOCATION,
        settings.FLATTENED_LOCATION
    ]

    sbml_paths = [pjoin(directory, fname) for fname in locations]
    sbmlreport.create_sbml_reports(sbml_paths, directory, validate=False)

    # create sedml
    from sbmlutils.dfba.sedml import create_sedml
    species_ids = ", ".join(['Ac', 'Glcxt', 'O2', 'X'])
    reaction_ids = ", ".join(
        ['vO2_transfer', 'EX_Ac', 'EX_Glcxt', 'EX_O2', 'EX_X'])
    create_sedml(settings.SEDML_LOCATION,
                 settings.TOP_LOCATION,
                 directory=directory,
                 dt=0.01,
                 tend=15,
                 species_ids=species_ids,
                 reaction_ids=reaction_ids)

    return directory