Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing pow function reformatting in bnglWriter #6

Open
pgetta opened this issue Jun 19, 2019 · 1 comment
Open

Missing pow function reformatting in bnglWriter #6

pgetta opened this issue Jun 19, 2019 · 1 comment

Comments

@pgetta
Copy link

pgetta commented Jun 19, 2019

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

@ASinanSaglam
Copy link
Contributor

First of all, thank you for looking into the reason as to why the translation didn't work, that is extremely helpful.

While I'm not the original author on this, I'm currently working on atomizer. For your issue, since you know it's already working for you, I suggest uncommenting and keep on working with that. Just make sure to take a look at the resulting BNGL to make sure it's doing what you expect it to be doing.

I will take a look into this soon and will fix the issue in an upcoming update. I will write here once the issue is fixed. Thank you again for opening the issue and for your effort into figuring out where the problem is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants