def setProcessList( self, processList ): ''' set and detect a pathway processList: (list) a list of process full ID ''' # check the existence of processes, # and create relatedVariableList self.__processList = [] self.__variableList = [] for processFullID in processList: # if not self.theEmlSupport.isEntityExist( processFullID ): # continue self.__processList.append( processFullID ) try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) if self.__variableList.count( fullIDString ) == 0: self.__variableList.append( fullIDString )
def addVariable( self, variableFullID ): ''' recover a removed variable to the pathway variableFullID: (str) a variable full ID ''' if not self.__variableList.count( variableFullID ) == 0: return 1 # elif not ecell.eml.Eml.isEntityExist( variableFullID ): # return 0 for processFullID in self.__processList: try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = fullID[ 1 ] + ':' + fullID[ 2 ] if fullIDString == variableFullID: self.__variableList.append( variableFullID ) self.__variableList.sort() return 1
def getStoichiometryMatrix( self ): ''' create the stoichiometry matrix (array) return stoichiometryMatrix ''' stoichiometryMatrix = numpy.zeros( ( len( self.__variableList ), len( self.__processList ) ), float ) for j in range( len( self.__processList ) ): processFullID = self.__processList[ j ] try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) try: i = self.__variableList.index( fullIDString ) except ValueError: # should some warning message be showed? continue if len( aVariableReference ) > 2: coeff = int( aVariableReference[ 2 ] ) if coeff != 0: stoichiometryMatrix[ i ][ j ] += coeff
def removeProcess( self, processIndexList ): ''' remove processes from the pathway processIndexList: (list) a list of indices of processes ''' indexList = copy.copy( processIndexList ) indexList.sort() indexList.reverse() removedProcessList = [] for i in indexList: if len( self.__processList ) > i: removedProcessList.append( self.__processList.pop( i ) ) removedVariableList = [] for processFullID in removedProcessList: # if not ecell.eml.Eml.isEntityExist( self.theEmlSupport, processFullID ): # continue try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) if removedVariableList.count( fullIDString ) == 0: removedVariableList.append( fullIDString )
def getIncidentMatrix(self, mode=0): ''' create the incident matrix (array) mode: (0 or 1) 0 means that only the \'write\' variables are checked. 0 is set as default. return incidentMatrix ''' incidentMatrix = numpy.zeros( (len(self.__variableList), len(self.__processList))) for j in range(len(self.__processList)): processFullID = self.__processList[j] try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList') except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID(aVariableReference[1], processFullID) fullIDString = ecell.ecssupport.createFullIDString(fullID) try: i = self.__variableList.index(fullIDString) except ValueError: # should some warning message be showed? continue if mode: if len(aVariableReference) > 2: coeff = int(aVariableReference[2]) if coeff != 0: incidentMatrix[i][j] = 1 else: incidentMatrix[i][j] = 1
def getIncidentMatrix( self, mode=0 ): ''' create the incident matrix (array) mode: (0 or 1) 0 means that only the \'write\' variables are checked. 0 is set as default. return incidentMatrix ''' incidentMatrix = numpy.zeros( ( len( self.__variableList ), len( self.__processList ) ) ) for j in range( len( self.__processList ) ): processFullID = self.__processList[ j ] try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: continue for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) try: i = self.__variableList.index( fullIDString ) except ValueError: # should some warning message be showed? continue if mode: if len( aVariableReference ) > 2: coeff = int( aVariableReference[ 2 ] ) if coeff != 0: incidentMatrix[ i ][ j ] = 1 else: incidentMatrix[ i ][ j ] = 1
# elif not ecell.eml.Eml.isEntityExist( processFullID ): # return # add process self.__processList.append( processFullID ) self.__processList.sort() # update the related variable list try: aVariableReferenceList = self.theEmlSupport.getEntityProperty( processFullID + ':VariableReferenceList' ) except AttributeError, e: return for aVariableReference in aVariableReferenceList: fullID = createVariableReferenceFullID( aVariableReference[ 1 ], processFullID ) fullIDString = ecell.ecssupport.createFullIDString( fullID ) if self.__variableList.count( fullIDString ) == 0: self.__variableList.append( fullIDString ) self.__variableList.sort() # end of addProcess def removeProcess( self, processIndexList ): ''' remove processes from the pathway processIndexList: (list) a list of indices of processes '''