Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions bng/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@ def execute(self, context):
if hasattr(external_operators.accessFile,"info"):
del external_operators.accessFile.info

if('.bngl') in self.filepath:
is_file_xml = self.filepath.endswith('.xml')

if self.filepath.endswith('.bngl'):
bngfilepath = self.filepath # bngl file path
external_operators.filePath=findCellBlenderDirectory()+'bng{0}'.format(os.sep) + self.filepath.split(os.sep)[-1]
print ( "Calling bng_operators.execute_bionetgen("+bngfilepath+")" )
bng_operators.execute_bionetgen(self.filepath,context)
print ( "Back from bng_operators.execute_bionetgen("+bngfilepath+")" )

elif('.xml') in self.filepath:
elif is_file_xml:
sbmlfilepath = self.filepath
external_operators.filePath = sbmlfilepath
# sbml file path
Expand All @@ -67,7 +69,7 @@ def execute(self, context):
print ( "Loading release sites from external model..." )
bpy.ops.external.release_site_add()
print ( "Done Loading external model" )
if ('.xml') in self.filepath:
if is_file_xml:
#TODO:this is sbml only until we add this information on the bng side
print("Loading reaction output ...")
bpy.ops.external.reaction_output_add()
Expand All @@ -78,9 +80,7 @@ def execute(self, context):
### THIS ENTIRE SECTION IS A QUICK HACK TO HANDLE XML IMPORTING
###
###
if ('.xml' in self.filepath) and ('mcell' in context.scene):
# Note that searching for ".xml" in the filepath may not be reliable since it should end with .xml.
# Keeping the same for now.
if is_file_xml and self.add_to_model_objects and ('mcell' in context.scene):
print ( "Pulling object structure from XML file: " + self.filepath )

mcell = context.scene.mcell
Expand Down
12 changes: 6 additions & 6 deletions bng/sbml2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ def getInstanceRate(self,math,compartmentList, reversible,rReactant,rProduct):
else:
rateL, nl = self.removeFactorFromMath(math, rReactant,
rProduct)
rateL = "if({0} >= 0 ,{0},0)".format(rateL)
# rateL = "if({0} >= 0 ,{0},0)".format(rateL)
rateR, nr = self.removeFactorFromMath(math, rReactant,
rProduct)
rateR = "if({0} < 0 ,-({0}),0)".format(rateR)
# rateR = "if({0} < 0 ,-({0}),0)".format(rateR)
nl, nr = 1,1
else:
rateL, nl = (self.removeFactorFromMath(math.deepCopy(),
Expand Down Expand Up @@ -426,8 +426,8 @@ def removeFactorFromMath(self, math, reactants, products):
#remainderPatterns = [x[0] for x in reactants]
math = self.getPrunnedTree(math,remainderPatterns)
rateR = libsbml.formulaToString(math)
for element in remainderPatterns:
rateR = 'if({0} >0,({1})/{0} ,0)'.format(element,rateR)
# for element in remainderPatterns:
# rateR = 'if({0} >0,({1})/{0} ,0)'.format(element,rateR)
if highStoichoiMetryFactor != 1:
rateR = '{0}*{1}'.format(rateR, int(highStoichoiMetryFactor))

Expand Down Expand Up @@ -494,7 +494,7 @@ def getContained(compartmentList,container):
math = kineticLaw.getMath()
reversible = reaction.getReversible()

rateL, rateR = self.getInstanceRate(math,compartmentList.keys(),reversible,rReactant,rProduct)
rateL, rateR = self.getInstanceRate(math,list(compartmentList.keys()),reversible,rReactant,rProduct)
#finalReactant = [x[0]]
#testing whether we have volume-surface interactions
rcList = []
Expand Down Expand Up @@ -620,7 +620,7 @@ def getContained(compartmentList,container):
tmpR['reactants'] = ' + '.join(prdList)
if flagR:
virtualReaction= {}
virtualReaction['rxn_name'] = tmpL['rxn_name']
virtualReaction['rxn_name'] = tmpR['rxn_name']
tmpR.pop('rxn_name')
tmpR['products'] = '{0}_{1}_{2}'.format(product[0][0],reactant[0][2],reactant[0][0])
virtualReaction['reactants'] = tmpR['products']
Expand Down