BioSIMI-Python/modules/SimpleModel.py
def createNewSpecies(self, ListOfSpecies, sComp, ListOfAmounts, sConstant, sSubstance, sBoundary = False, sHasOnlySubstance = False):
        ''' 
        Creates new Species object inside the 
        Model with the given attributes and returns a pointer to the list of Species object created
        '''
        model = self.getModel()
        allIds = self.getAllIds()
        trans = SetIdFromNames(allIds)
        check(model,'retreived model object')
        amount = []
        speciesList = []
        if (type(ListOfSpecies) is str) or  (len(ListOfSpecies) == 1):
            if (type(ListOfAmounts) is list) and (len(ListOfAmounts) > 1):
                raise SyntaxError('The amount cannot be a list of multiple items when only one species is being created')
            elif (type(ListOfAmounts) is list) and (len(ListOfAmounts) == 1):
                amount.append(ListOfAmounts[0])
            elif type(ListOfAmounts) is not list:
                if not isinstance(ListOfAmounts, (int, float)):
                    raise SyntaxError('The amount should be a real number corresponding to the species given')
                amount.append(ListOfAmounts)
            if type(ListOfSpecies) is str:
                speciesList.append(ListOfSpecies)
                
        # Multiple species
        elif (type(ListOfSpecies) is list) and (len(ListOfSpecies) > 1):
            if type(ListOfAmounts) is not list:
                raise SyntaxError('For multiple species, the initial amounts should be a list of real numbers')
            elif len(ListOfSpecies) != len(ListOfAmounts):
                raise SyntaxError('The length of ListOfSpecies and ListOfAmounts should be the same.')
            else:
                amount = ListOfAmounts[:]
            for sp_name, sp_amt in zip(ListOfSpecies, amount):
                if not isinstance(sp_amt, (int, float)):
                    raise SyntaxError('The amount should be a real number corresponding to the species given')
                if not isinstance(sp_name, str):
                    raise SyntaxError('The species name should be a string.')
            speciesList = ListOfSpecies[:]
        else:
            raise SyntaxError('ListOfSpecies should be a list type with string items and ListOfAmounts should be list type with real numbers')


        list_s_obj = []
        for sName, sInitial in zip(speciesList, amount):
            s_obj = model.createSpecies()
            check(s_obj, 'created s_obj species')
            sId = trans.getValidIdForName(sName)
            check(s_obj.setId(sId), 'set s_obj ID')
            check(s_obj.setName(sName), 'set s_obj name')
            check(s_obj.setCompartment(sComp), 'set s_obj compartment')
            check(s_obj.setInitialAmount(sInitial), 'set s_obj initial amount')
            check(s_obj.setConstant(sConstant), 'set s_obj constant')
            check(s_obj.setBoundaryCondition(sBoundary),
                'set boundary s_obj condition false')
            check(s_obj.setSubstanceUnits(sSubstance), 'set substance units s_obj')
            check(s_obj.setHasOnlySubstanceUnits(sHasOnlySubstance),
                'set has only substance units s_obj')
            list_s_obj.append(s_obj)
        return list_s_obj
 
        Creates new Species object inside the 
        Model with the given attributes and returns a pointer to the list of Species object created
        
Creates new Species object inside the
Model with the given attributes and returns a pointer to the list of Species object created
Creates new Species object inside the Model with the given attributes and returns a pointer to the list of Species object created
def createNewSpecies(self, ListOfSpecies, sComp, ListOfAmounts, sConstant, sSubstance, sBoundary = False, sHasOnlySubstance = False):
        model = self.getModel()
        allIds = self.getAllIds()
        trans = SetIdFromNames(allIds)
        check(model,'retreived model object')
        amount = []
        speciesList = []
        if (type(ListOfSpecies) is str) or  (len(ListOfSpecies) == 1):
            if (type(ListOfAmounts) is list) and (len(ListOfAmounts) > 1):
                raise SyntaxError('The amount cannot be a list of multiple items when only one species is being created')
            elif (type(ListOfAmounts) is list) and (len(ListOfAmounts) == 1):
                amount.append(ListOfAmounts[0])
            elif type(ListOfAmounts) is not list:
                if not isinstance(ListOfAmounts, (int, float)):
                    raise SyntaxError('The amount should be a real number corresponding to the species given')
                amount.append(ListOfAmounts)
            if type(ListOfSpecies) is str:
                speciesList.append(ListOfSpecies)
        elif (type(ListOfSpecies) is list) and (len(ListOfSpecies) > 1):
            if type(ListOfAmounts) is not list:
                raise SyntaxError('For multiple species, the initial amounts should be a list of real numbers')
            elif len(ListOfSpecies) != len(ListOfAmounts):
                raise SyntaxError('The length of ListOfSpecies and ListOfAmounts should be the same.')
            else:
                amount = ListOfAmounts[:]
            for sp_name, sp_amt in zip(ListOfSpecies, amount):
                if not isinstance(sp_amt, (int, float)):
                    raise SyntaxError('The amount should be a real number corresponding to the species given')
                if not isinstance(sp_name, str):
                    raise SyntaxError('The species name should be a string.')
            speciesList = ListOfSpecies[:]
        else:
            raise SyntaxError('ListOfSpecies should be a list type with string items and ListOfAmounts should be list type with real numbers')
        list_s_obj = []
        for sName, sInitial in zip(speciesList, amount):
            s_obj = model.createSpecies()
            check(s_obj, 'created s_obj species')
            sId = trans.getValidIdForName(sName)
            check(s_obj.setId(sId), 'set s_obj ID')
            check(s_obj.setName(sName), 'set s_obj name')
            check(s_obj.setCompartment(sComp), 'set s_obj compartment')
            check(s_obj.setInitialAmount(sInitial), 'set s_obj initial amount')
            check(s_obj.setConstant(sConstant), 'set s_obj constant')
            check(s_obj.setBoundaryCondition(sBoundary),
                'set boundary s_obj condition false')
            check(s_obj.setSubstanceUnits(sSubstance), 'set substance units s_obj')
            check(s_obj.setHasOnlySubstanceUnits(sHasOnlySubstance),
                'set has only substance units s_obj')
            list_s_obj.append(s_obj)
        return list_s_obj
def createNewSpecies ( self , ListOfSpecies , sComp , ListOfAmounts , sConstant , sSubstance , sBoundary = False , sHasOnlySubstance = False ) : model = self . getModel ( ) allIds = self . getAllIds ( ) trans = SetIdFromNames ( allIds ) check ( model , 'retreived model object' ) amount = [ ] speciesList = [ ] if ( type ( ListOfSpecies ) is str ) or ( len ( ListOfSpecies ) == 1 ) : if ( type ( ListOfAmounts ) is list ) and ( len ( ListOfAmounts ) > 1 ) : raise SyntaxError ( 'The amount cannot be a list of multiple items when only one species is being created' ) elif ( type ( ListOfAmounts ) is list ) and ( len ( ListOfAmounts ) == 1 ) : amount . append ( ListOfAmounts [ 0 ] ) elif type ( ListOfAmounts ) is not list : if not isinstance ( ListOfAmounts , ( int , float ) ) : raise SyntaxError ( 'The amount should be a real number corresponding to the species given' ) amount . append ( ListOfAmounts ) if type ( ListOfSpecies ) is str : speciesList . append ( ListOfSpecies ) elif ( type ( ListOfSpecies ) is list ) and ( len ( ListOfSpecies ) > 1 ) : if type ( ListOfAmounts ) is not list : raise SyntaxError ( 'For multiple species, the initial amounts should be a list of real numbers' ) elif len ( ListOfSpecies ) != len ( ListOfAmounts ) : raise SyntaxError ( 'The length of ListOfSpecies and ListOfAmounts should be the same.' ) else : amount = ListOfAmounts [ : ] for sp_name , sp_amt in zip ( ListOfSpecies , amount ) : if not isinstance ( sp_amt , ( int , float ) ) : raise SyntaxError ( 'The amount should be a real number corresponding to the species given' ) if not isinstance ( sp_name , str ) : raise SyntaxError ( 'The species name should be a string.' ) speciesList = ListOfSpecies [ : ] else : raise SyntaxError ( 'ListOfSpecies should be a list type with string items and ListOfAmounts should be list type with real numbers' ) list_s_obj = [ ] for sName , sInitial in zip ( speciesList , amount ) : s_obj = model . createSpecies ( ) check ( s_obj , 'created s_obj species' ) sId = trans . getValidIdForName ( sName ) check ( s_obj . setId ( sId ) , 'set s_obj ID' ) check ( s_obj . setName ( sName ) , 'set s_obj name' ) check ( s_obj . setCompartment ( sComp ) , 'set s_obj compartment' ) check ( s_obj . setInitialAmount ( sInitial ) , 'set s_obj initial amount' ) check ( s_obj . setConstant ( sConstant ) , 'set s_obj constant' ) check ( s_obj . setBoundaryCondition ( sBoundary ) , 'set boundary s_obj condition false' ) check ( s_obj . setSubstanceUnits ( sSubstance ) , 'set substance units s_obj' ) check ( s_obj . setHasOnlySubstanceUnits ( sHasOnlySubstance ) , 'set has only substance units s_obj' ) list_s_obj . append ( s_obj ) return list_s_obj
Creates new Species object inside the
Model with the given attributes and returns a pointer to the list of Species object created
Creates new Species object inside the Model with the given attributes and returns a pointer to the list of Species object created
''' 
        Creates new Species object inside the 
        Model with the given attributes and returns a pointer to the list of Species object created
        ''' # Multiple species
self
ListOfSpecies
sComp
ListOfAmounts
sConstant
sSubstance
sBoundary
sHasOnlySubstance