Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if self.Debug:
print(self.tabmodule)
print(self.debugfile)
pysces.lib.lex.lex(module=self, debug=self.Debug)
pysces.lib.lex.input(Model)
pysces.lib.yacc.yacc(module=self,
debug=self.Debug,
debugfile=self.debugfile,
tabmodule=self.tabmodule)
os.chdir(outdir)
while 1:
tok = pysces.lib.lex.token()
if not tok: break
if self.LexErrors != []: print('self.LexErrors = ', self.LexErrors, '\n')
while 1:
p = pysces.lib.yacc.parse(Model)
if not p: break
# we have the dictionary get rid of this stuff
del Model, p
# Create list of variable reagents and remove '[t]' from fixed reagents
for i in range(len(self.Reagents)): # johann -- new construction otherwise list elements not replaced
if self.Reagents[i][:-3] not in self.FixedReagents:
self.VarReagents.append(self.Reagents[i])
if self.Reagents[i][:-3] in self.FixedReagents:
self.Reagents[i] = self.Reagents[i][:-3]
FileT = ''
for let in FileL:
if let.isalnum():
FileT += let
self.debugfile = '_pys' + FileT[:-3] + ".dbg"
self.tabmodule = '_pys' + FileT[:-3] + "_" + "parsetab"
else:
self.debugfile = '_pys' + modelfile[:-4] + ".dbg"
self.tabmodule = '_pys' + modelfile[:-4] + "_" + "parsetab"
if self.display_debug:
print(self.tabmodule)
print(self.debugfile)
print('cwd: ', os.getcwd())
self.__lexer = pysces.lib.lex.lex(module=self, debug=self.display_debug)
self.__lexer.input(self.__Model)
self.__parser = pysces.lib.yacc.yacc(module=self,
debug=self.display_debug,
debugfile=self.debugfile,
tabmodule=self.tabmodule,
outputdir=tempDir)
while 1:
tok = self.__lexer.token()
if not tok: break
while 1:
p = self.__parser.parse(self.__Model)
if not p: break
# get to our work directory
debug [default=0]: optionally output debug information
"""
if indir == None:
indir = os.getcwd()
if outdir == None:
outdir = os.getcwd()
if os.path.exists(os.path.join(indir,File)) and File[-4:] == '.psc':
go = 1
else:
print('\nIgnoring non-PySCeS model file: ' + os.path.join(indir,File))
go = 0
if go == 1:
# clean up the modules
reload(pysces.lib.lex) # brett's bugbear code these have to be here ALWAYS!!
reload(pysces.lib.yacc)
# clean up the instance
self.ReactionIDs = [] # List of reaction names
self.Names = [] # List of all reagent, parameter and function names
self.LexErrors = [] # List of lexing errors
self.NetworkDict = {} # Dictionary containing all reaction information
self.InitStrings = [] # Initialisation strings
self.Inits = [] # Initialised entities
self.Reagents = [] # All reagents found during parsing of reactions
self.FixedReagents = [] # Fixed reagents
self.ReacParams = [] # Temporary list of reaction parameters
self.ParseErrors = []
self.InitParStrings = [] # Initialisation strings for parameters -- johann new
self.InitVarStrings = [] # Initialisation strings for variables -- johann new
for let in FileL:
if let.isalnum():
FileT += let
# instantiate the lexer and parser
self.debugfile = '_jws' + FileT[:-3] + ".dbg"
self.tabmodule = '_jws' + FileT[:-3] + "_" + "parsetab"
else:
self.debugfile = '_jws' + File[:-4] + ".dbg"
self.tabmodule = '_jws' + File[:-4] + "_" + "parsetab"
if self.Debug:
print(self.tabmodule)
print(self.debugfile)
pysces.lib.lex.lex(module=self, debug=self.Debug)
pysces.lib.lex.input(Model)
pysces.lib.yacc.yacc(module=self,
debug=self.Debug,
debugfile=self.debugfile,
tabmodule=self.tabmodule)
os.chdir(outdir)
while 1:
tok = pysces.lib.lex.token()
if not tok: break
if self.LexErrors != []: print('self.LexErrors = ', self.LexErrors, '\n')
while 1:
p = pysces.lib.yacc.parse(Model)
if not p: break
if let.isalnum():
FileT += let
# instantiate the lexer and parser
self.debugfile = '_jws' + FileT[:-3] + ".dbg"
self.tabmodule = '_jws' + FileT[:-3] + "_" + "parsetab"
else:
self.debugfile = '_jws' + File[:-4] + ".dbg"
self.tabmodule = '_jws' + File[:-4] + "_" + "parsetab"
if self.Debug:
print(self.tabmodule)
print(self.debugfile)
pysces.lib.lex.lex(module=self, debug=self.Debug)
pysces.lib.lex.input(Model)
pysces.lib.yacc.yacc(module=self,
debug=self.Debug,
debugfile=self.debugfile,
tabmodule=self.tabmodule)
os.chdir(outdir)
while 1:
tok = pysces.lib.lex.token()
if not tok: break
if self.LexErrors != []: print('self.LexErrors = ', self.LexErrors, '\n')
while 1:
p = pysces.lib.yacc.parse(Model)
if not p: break
self.TimeFunc = []
self.UserFunc = []
self.InitFunc = []
self.Functions = {}
self.Events = {}
self.AssignmentRules = {}
self.UserFuncs = {}
self.ModelInit = {}
self.cbm_FluxBounds = {} # flux bounds in a CB model
self.cbm_ObjectiveFunctions = {} # objective functions for a CB model
self.cbm_UserFluxConstraints = {} # objective functions for a CB model
self.ModelUsesNumpyFuncs = False
# 4 hrs of debugging and these two lines solve the problem .... I'm out of here!
reload(pysces.lib.lex)
reload(pysces.lib.yacc)
# fixes the obscure reload <--> garbage collection reference overload bug ... who said scripted lang's were
# easy to use :-) - brett 20040122
self.AllRateEqsGiven = 1
self.ParseOK = True
self.LexOK = True
# check to see if the last line of the file is an os defined empty line
self.CheckLastLine(os.path.join(modeldir,modelfile))
# load model data from file
Data = open(os.path.join(modeldir,modelfile),'r')
self.__Model = Data.read()
Data.close()