BioSIMI-Python/modules/Subsystem.py
def modelReduce(self, timepoints):
        ''' 
        Reduces the model by removing the reactions which are set as fast
        in the Subsystem model. The timepoints are used to simulate the
        fast reactions for these timepoints. The steady state values of 
        the involved species in the fast reactions are used in the
        reduced model as their initial value. 
        Returns the Subsystem object with the reduced model obtained.
        '''
        reducedSubsystem = self.getSystem().createNewSubsystem(3,1)
        model_orig = self.getSubsystemDoc().getModel()
        reducedSubsystem.getSubsystemDoc().setModel(model_orig)
        mod = reducedSubsystem.getSubsystemDoc().getModel()

        fastRxns = self.getFastReactions()
        fastSubsystem = self.getSystem().createNewSubsystem(3,1)
        fastModel = fastSubsystem.createNewModel('fastModel', mod.getTimeUnits(), mod.getExtentUnits(), mod.getSubstanceUnits() )
        # adding all global (model level) components of the model
        # to the fastModel, except reactions and species
        if mod.getNumCompartmentTypes() != 0:
            for each_compartmentType in mod.getListOfCompartmentType():
                fastModel.addCompartment(each_compartmentType)
        if mod.getNumConstraints() != 0:
            for each_constraint in mod.getListOfConstraints():
                fastModel.addConstraint(each_constraint)
        if mod.getNumInitialAssignments() != 0:
            for each_initialAssignment in mod.getListOfInitialAssignments():
                fastModel.addInitialAssignment(each_initialAssignment)
        if mod.getNumFunctionDefinitions() != 0:
            for each_functionDefinition in mod.getListOfFunctionDefinitions():
                fastModel.addFunctionDefinition(each_functionDefinition)
        if mod.getNumRules() != 0:
            for each_rule in mod.getListOfRules():
                fastModel.addRule(each_rule)
        if mod.getNumEvents() != 0:
            for each_event in mod.getListOfEvents():
                fastModel.addEvent(each_event)
        if mod.getNumCompartments() != 0:
            for each_compartment in mod.getListOfCompartments():
                fastModel.addCompartment(each_compartment)
        if mod.getNumParameters() != 0:
            for each_parameter in mod.getListOfParameters():
                fastModel.addParameter(each_parameter)
        if mod.getNumUnitDefinitions() != 0:
            for each_unit in mod.getListOfUnitDefinitions():
                fastModel.addUnitDefinition(each_unit)
        fastModel.setAreaUnits(mod.getAreaUnits())
        fastModel.setExtentUnits(mod.getExtentUnits())
        fastModel.setLengthUnits(mod.getLengthUnits())
        fastModel.setSubstanceUnits(mod.getSubstanceUnits())
        fastModel.setTimeUnits(mod.getTimeUnits())
        fastModel.setVolumeUnits(mod.getVolumeUnits())

       # adding the reactions that are fast and the species used in them to 
        # the fast model
        for rxn in fastRxns:
            fastModel.addReaction(rxn)
            mod.removeReaction(rxn.getId())
            for reactant_ref in rxn.getListOfReactants():
                fastModel.addSpecies(mod.getElementBySId(reactant_ref.getSpecies()))
            for product_ref in rxn.getListOfProducts():
                fastModel.addSpecies(mod.getElementBySId(product_ref.getSpecies()))
        
        # get equilibrium values for species in fast reactions
        # writeSBML(fastSubsystem.getSubsystemDoc(), 'models/intermediate_model.xml')
        print('###### Simulating the fast reactions in the model...All other species and parameters will be marked useless')
        time.sleep(2)
        data, m = fastSubsystem.simulateSbmlWithBioscrape(0,timepoints)
        allSpecies = fastModel.getListOfSpecies()
        for i in range(len(allSpecies)):
            species = mod.getElementBySId(allSpecies.get(i).getId())
            newAmount = data[:,m.get_species_index(species.getId())][-1]
            if newAmount > 0:
                species.setInitialAmount(newAmount)
            else:
                species.setInitialAmount(0)
        return reducedSubsystem
 
        Reduces the model by removing the reactions which are set as fast
        in the Subsystem model. The timepoints are used to simulate the
        fast reactions for these timepoints. The steady state values of 
        the involved species in the fast reactions are used in the
        reduced model as their initial value. 
        Returns the Subsystem object with the reduced model obtained.
        
Reduces the model by removing the reactions which are set as fast
in the Subsystem model. The timepoints are used to simulate the
fast reactions for these timepoints. The steady state values of
the involved species in the fast reactions are used in the
reduced model as their initial value.
Returns the Subsystem object with the reduced model obtained.
Reduces the model by removing the reactions which are set as fast in the Subsystem model . The timepoints are used to simulate the fast reactions for these timepoints . The steady state values of the involved species in the fast reactions are used in the reduced model as their initial value . Returns the Subsystem object with the reduced model obtained .
def modelReduce(self, timepoints):
        reducedSubsystem = self.getSystem().createNewSubsystem(3,1)
        model_orig = self.getSubsystemDoc().getModel()
        reducedSubsystem.getSubsystemDoc().setModel(model_orig)
        mod = reducedSubsystem.getSubsystemDoc().getModel()
        fastRxns = self.getFastReactions()
        fastSubsystem = self.getSystem().createNewSubsystem(3,1)
        fastModel = fastSubsystem.createNewModel('fastModel', mod.getTimeUnits(), mod.getExtentUnits(), mod.getSubstanceUnits() )
        if mod.getNumCompartmentTypes() != 0:
            for each_compartmentType in mod.getListOfCompartmentType():
                fastModel.addCompartment(each_compartmentType)
        if mod.getNumConstraints() != 0:
            for each_constraint in mod.getListOfConstraints():
                fastModel.addConstraint(each_constraint)
        if mod.getNumInitialAssignments() != 0:
            for each_initialAssignment in mod.getListOfInitialAssignments():
                fastModel.addInitialAssignment(each_initialAssignment)
        if mod.getNumFunctionDefinitions() != 0:
            for each_functionDefinition in mod.getListOfFunctionDefinitions():
                fastModel.addFunctionDefinition(each_functionDefinition)
        if mod.getNumRules() != 0:
            for each_rule in mod.getListOfRules():
                fastModel.addRule(each_rule)
        if mod.getNumEvents() != 0:
            for each_event in mod.getListOfEvents():
                fastModel.addEvent(each_event)
        if mod.getNumCompartments() != 0:
            for each_compartment in mod.getListOfCompartments():
                fastModel.addCompartment(each_compartment)
        if mod.getNumParameters() != 0:
            for each_parameter in mod.getListOfParameters():
                fastModel.addParameter(each_parameter)
        if mod.getNumUnitDefinitions() != 0:
            for each_unit in mod.getListOfUnitDefinitions():
                fastModel.addUnitDefinition(each_unit)
        fastModel.setAreaUnits(mod.getAreaUnits())
        fastModel.setExtentUnits(mod.getExtentUnits())
        fastModel.setLengthUnits(mod.getLengthUnits())
        fastModel.setSubstanceUnits(mod.getSubstanceUnits())
        fastModel.setTimeUnits(mod.getTimeUnits())
        fastModel.setVolumeUnits(mod.getVolumeUnits())
        for rxn in fastRxns:
            fastModel.addReaction(rxn)
            mod.removeReaction(rxn.getId())
            for reactant_ref in rxn.getListOfReactants():
                fastModel.addSpecies(mod.getElementBySId(reactant_ref.getSpecies()))
            for product_ref in rxn.getListOfProducts():
                fastModel.addSpecies(mod.getElementBySId(product_ref.getSpecies()))
        print('###### Simulating the fast reactions in the model...All other species and parameters will be marked useless')
        time.sleep(2)
        data, m = fastSubsystem.simulateSbmlWithBioscrape(0,timepoints)
        allSpecies = fastModel.getListOfSpecies()
        for i in range(len(allSpecies)):
            species = mod.getElementBySId(allSpecies.get(i).getId())
            newAmount = data[:,m.get_species_index(species.getId())][-1]
            if newAmount > 0:
                species.setInitialAmount(newAmount)
            else:
                species.setInitialAmount(0)
        return reducedSubsystem
def modelReduce ( self , timepoints ) : reducedSubsystem = self . getSystem ( ) . createNewSubsystem ( 3 , 1 ) model_orig = self . getSubsystemDoc ( ) . getModel ( ) reducedSubsystem . getSubsystemDoc ( ) . setModel ( model_orig ) mod = reducedSubsystem . getSubsystemDoc ( ) . getModel ( ) fastRxns = self . getFastReactions ( ) fastSubsystem = self . getSystem ( ) . createNewSubsystem ( 3 , 1 ) fastModel = fastSubsystem . createNewModel ( 'fastModel' , mod . getTimeUnits ( ) , mod . getExtentUnits ( ) , mod . getSubstanceUnits ( ) ) if mod . getNumCompartmentTypes ( ) != 0 : for each_compartmentType in mod . getListOfCompartmentType ( ) : fastModel . addCompartment ( each_compartmentType ) if mod . getNumConstraints ( ) != 0 : for each_constraint in mod . getListOfConstraints ( ) : fastModel . addConstraint ( each_constraint ) if mod . getNumInitialAssignments ( ) != 0 : for each_initialAssignment in mod . getListOfInitialAssignments ( ) : fastModel . addInitialAssignment ( each_initialAssignment ) if mod . getNumFunctionDefinitions ( ) != 0 : for each_functionDefinition in mod . getListOfFunctionDefinitions ( ) : fastModel . addFunctionDefinition ( each_functionDefinition ) if mod . getNumRules ( ) != 0 : for each_rule in mod . getListOfRules ( ) : fastModel . addRule ( each_rule ) if mod . getNumEvents ( ) != 0 : for each_event in mod . getListOfEvents ( ) : fastModel . addEvent ( each_event ) if mod . getNumCompartments ( ) != 0 : for each_compartment in mod . getListOfCompartments ( ) : fastModel . addCompartment ( each_compartment ) if mod . getNumParameters ( ) != 0 : for each_parameter in mod . getListOfParameters ( ) : fastModel . addParameter ( each_parameter ) if mod . getNumUnitDefinitions ( ) != 0 : for each_unit in mod . getListOfUnitDefinitions ( ) : fastModel . addUnitDefinition ( each_unit ) fastModel . setAreaUnits ( mod . getAreaUnits ( ) ) fastModel . setExtentUnits ( mod . getExtentUnits ( ) ) fastModel . setLengthUnits ( mod . getLengthUnits ( ) ) fastModel . setSubstanceUnits ( mod . getSubstanceUnits ( ) ) fastModel . setTimeUnits ( mod . getTimeUnits ( ) ) fastModel . setVolumeUnits ( mod . getVolumeUnits ( ) ) for rxn in fastRxns : fastModel . addReaction ( rxn ) mod . removeReaction ( rxn . getId ( ) ) for reactant_ref in rxn . getListOfReactants ( ) : fastModel . addSpecies ( mod . getElementBySId ( reactant_ref . getSpecies ( ) ) ) for product_ref in rxn . getListOfProducts ( ) : fastModel . addSpecies ( mod . getElementBySId ( product_ref . getSpecies ( ) ) ) print ( '###### Simulating the fast reactions in the model...All other species and parameters will be marked useless' ) time . sleep ( 2 ) data , m = fastSubsystem . simulateSbmlWithBioscrape ( 0 , timepoints ) allSpecies = fastModel . getListOfSpecies ( ) for i in range ( len ( allSpecies ) ) : species = mod . getElementBySId ( allSpecies . get ( i ) . getId ( ) ) newAmount = data [ : , m . get_species_index ( species . getId ( ) ) ] [ - 1 ] if newAmount > 0 : species . setInitialAmount ( newAmount ) else : species . setInitialAmount ( 0 ) return reducedSubsystem
Reduces the model by removing the reactions which are set as fast
in the Subsystem model.
Reduces the model by removing the reactions which are set as fast in the Subsystem model .
''' 
        Reduces the model by removing the reactions which are set as fast
        in the Subsystem model. The timepoints are used to simulate the
        fast reactions for these timepoints. The steady state values of 
        the involved species in the fast reactions are used in the
        reduced model as their initial value. 
        Returns the Subsystem object with the reduced model obtained.
        ''' # adding all global (model level) components of the model # to the fastModel, except reactions and species # adding the reactions that are fast and the species used in them to  # the fast model # get equilibrium values for species in fast reactions # writeSBML(fastSubsystem.getSubsystemDoc(), 'models/intermediate_model.xml')
self
timepoints