コード例 #1
0
def readModel(file, maxDelete, bio_reaction, infinityValue, USE_GENE):
    """
    Function that reads in a model from SBML3 file
    Optional: function GrowthCondition.setCondition for setting flux values
        to mimic growth conditions
    
    - *file*                sbml filename
    - *bio_reaction*        inner objective, usually biomass reaction
    - *lp*                  primal LP, derived from model
    - *splitCouples*        list from reversible reactions that are split
    - *lpName*              name for LP, derived from filename
    - *GPRdict*             dictionary with (iso)enzymes mapped to reactions
    - *SubUdict*            dictionary with genes mapped to isoenzymes
    - *Scale*               upscale factor
    - *maxDelete*           maximum gene/reaction deletions allowed
    - *infinityValue*       boundary values that can be assumed infinite

    """

    # Read in model and set growth conditions
    model = cbm.CBRead.readSBML3FBC('Models/' + file)
    # remove equiliy bonds
    model.splitEqualityFluxBounds()
    model.setObjectiveFlux(bio_reaction, osense='maximize')
    lpName = file.replace('.xml', '')
    lpName = lpName.replace('SynthSinks/', '')
    #model = GrowthCondition.setCondition(model, bio_reaction)
    cbm.analyzeModel(model)

    # Build dictionaries for GPR associations
    GPRdict = {}
    SubUdict = {}
    if USE_GENE:
        GPRdict, SubUdict = doGeneMapping(model)

    # Upscale reaction boundaries, if needed
    model, Scale = upscaleModel(model)
    infinityValue = infinityValue * Scale

    # Write LP
    cbm.CBWrite.writeModelLP(model, work_dir='LPs', fname=lpName + '_primal')
    lp = cplex.Cplex('LPs/' + lpName + '_primal.lp')

    return lp, lpName, GPRdict, SubUdict, Scale, maxDelete, infinityValue
コード例 #2
0
ファイル: pyOpt.py プロジェクト: CocovB/GeneKnockout
def readModel(file, maxDelete, bio_reaction, infinityValue, USE_GENE):
    """
    Function that reads in a model from SBML3 file
    Optional: function GrowthCondition.setCondition for setting flux values
        to mimic growth conditions
    
    - *file*                sbml filename
    - *bio_reaction*        inner objective, usually biomass reaction
    - *lp*                  primal LP, derived from model
    - *splitCouples*        list from reversible reactions that are split
    - *lpName*              name for LP, derived from filename
    - *GPRdict*             dictionary with (iso)enzymes mapped to reactions
    - *SubUdict*            dictionary with genes mapped to isoenzymes
    - *Scale*               upscale factor
    - *maxDelete*           maximum gene/reaction deletions allowed
    - *infinityValue*       boundary values that can be assumed infinite

    """

    # Read in model and set growth conditions
    model = cbm.CBRead.readSBML3FBC(file)
    # remove equiliy bonds
    model.splitEqualityFluxBounds()
    model.setObjectiveFlux(bio_reaction, osense='maximize')
    lpName = file.replace('.xml', '')
    #model = GrowthCondition.setCondition(model, bio_reaction)
    cbm.analyzeModel(model)

    # Build dictionaries for GPR associations
    GPRdict = {}
    SubUdict = {}
    if USE_GENE:
        GPRdict, SubUdict= doGeneMapping(model)

    # Upscale reaction boundaries, if needed
    model, Scale = upscaleModel(model)
    infinityValue = infinityValue * Scale

    # Write LP
    cbm.CBWrite.writeModelLP(model, fname = 'Original')
    lp = cplex.Cplex('Original.lp')

    return lp, lpName, GPRdict, SubUdict, Scale, maxDelete, infinityValue