Skip to content

Missing pow function reformatting in bnglWriter #6

@pgetta

Description

@pgetta

Hello,

While trying to convert SBML model (http://www.ebi.ac.uk/biomodels-main/MODEL1603270000) got an exception:

Traceback (most recent call last):
  File "/Users/getta/dev/tmp/atomizer/SBMLparser/writer/bnglWriter.py", line 101, in rindex
    return next(dropwhile(lambda x: lst[x] != item, reversed(range(len(lst)))))
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "sbmlTranslator.py", line 68, in <module>
    main()
  File "sbmlTranslator.py", line 58, in main
    atomize=options['atomize'], bioGrid=False, pathwaycommons=options['pathwaycommons'], ignore=options['ignore'], noConversion = options['noConversion'])
  File "/Users/getta/dev/tmp/atomizer/SBMLparser/libsbml2bngl.py", line 539, in analyzeFile
    returnArray = analyzeHelper(document, reactionDefinitions, useID, outputFile, speciesEquivalence, atomize, translator, database)
  File "/Users/getta/dev/tmp/atomizer/SBMLparser/libsbml2bngl.py", line 663, in analyzeHelper
    observablesDict, translator)
  File "/Users/getta/dev/tmp/atomizer/SBMLparser/sbml2bngl.py", line 1117, in getAssignmentRules
    artificialObservables[rawArule[0]] = writer.bnglFunction(rawArule[1][0],rawArule[0]+'()',[],compartments=compartmentList,reactionDict=self.reactionDictionary)
  File "/Users/getta/dev/tmp/atomizer/SBMLparser/writer/bnglWriter.py", line 246, in bnglFunction
    rule = constructFromList(argList[0],['floor','ceil','pow','sqrt','sqr','root','and','or'])
  File "/Users/getta/dev/tmp/atomizer/SBMLparser/writer/bnglWriter.py", line 142, in constructFromList
    parsedString += '(' + constructFromList(argList[idx],optionList) + ')'
  File "/Users/getta/dev/tmp/atomizer/SBMLparser/writer/bnglWriter.py", line 142, in constructFromList
    parsedString += '(' + constructFromList(argList[idx],optionList) + ')'
  File "/Users/getta/dev/tmp/atomizer/SBMLparser/writer/bnglWriter.py", line 151, in constructFromList
    index = rindex(argList[idx+1],',')
  File "/Users/getta/dev/tmp/atomizer/SBMLparser/writer/bnglWriter.py", line 103, in rindex
    raise ValueError("rindex(lst, item): item not in list")
ValueError: rindex(lst, item): item not in list

Further investigation showed that pow reformatting call is disabled on line 235 of https://github.com/RuleWorld/atomizer/blob/master/SBMLparser/writer/bnglWriter.py
Atomizer was able to translate the model after that line had been enabled, and looks like math expressions with pow were translated correctly as well.

Is that supposed to be this way for some reason or can we use that line enabled safely for general cases?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions