CiaranWelsh / pycotools3

A Python toolbox for COPASI
13 stars 3 forks source link

pycotools3: code for michaelis_menten model creation is not working #1

Closed vibha15 closed 5 years ago

vibha15 commented 5 years ago

Hi. I am coding according to the pycotools3 documentation (release 12, Jan 2019). First, i tried to code for importing all the dependencies. it worked. Second, i tried to built michaelis_menten model according to the documentation. It showed error by saying that "you should use loada in place of BuildAntimony" (files showing errors are m_m modelerr1.png and m_m modelerr1-extended.png). Third, when i use loada. it started showing some positional error in copasi file (related error showing file is m_m modelerr2.png . Thank you so much in advance for your suggestion.

*My system is Ubuntu 16.04. I downloaded Anaconda3 (2019.03) with python 3.6 on my ubuntu machine. Obviously, downloaded pycotools3 using "pip install pycotools3". My work is on chemical kinetics and model prediction, but i am doing the michaelis_menten model coding to see how pycotools3 works accroding to the given doc, prior to begin my project.

Thanks Vibha

CiaranWelsh commented 5 years ago

Hello,

The documentation you are referring to sounds a bit old (12 Jan 2019?). I've developed the project more recently than that so my first suggestion would be to just ensure you are using the most up to date version of everything. You can find the documentation here. Also, try ensuring you are using the most recent pycotools.

$ pip uninstall pycotools3

then

$ pip install pycotools3 --no-cache-dir

the --no-cache-dir option just forces pip to redownload the package, rather than using a cached version.

I've tried the following on my own machine, which works as expected.

Let me know how it goes - all the best

Ciaran

import os
import site
from pycotools3 import model, tasks, viz

working_directory = <input working directory here>
if not os.path.isdir(working_directory):
    os.makedirs(working_directory)

copasi_file = os.path.join(working_directory, 'michaelis_menten.cps')

if os.path.isfile(copasi_file):
    os.remove(copasi_file)

antimony_string = """
model michaelis_menten()
    compartment cell = 1.0
    var E in cell
    var S in cell
    var ES in cell
    var P in cell

    kf = 0.1
    kb = 1
    kcat = 0.3
    E = 75
    S = 1000

    SBindE: S + E => ES; kf*S*E
    ESUnbind: ES => S + E; kb*ES
    ProdForm: ES => P + E; kcat*ES
end
"""

with model.BuildAntimony(copasi_file) as loader:
    mm = loader.load(antimony_string)
vibha15 commented 5 years ago

Hi, Thank you so much for your input. I have few points about my machine before i begin-

-My machine has COPASI 4.24 already. Should i have to update it with recent 4.25 version?

-What i observed that mostly pycotools3 dependencies are compatible with python 3.6 (i have dowloaded it with anaconda 2019.03 version), but recent version is 3.7

Is this pycotools3 (without cash) installation compatible with 3.7 ?

Please let me know that i am not making error in the required packages needed for pycotools3 installation. As i am done i will let you know.

Thanks for your time and explanation.

Vibha


From: Ciaran Welsh notifications@github.com Sent: Thursday, June 20, 2019 3:49 AM To: CiaranWelsh/pycotools3 Cc: Vibha Tripathi (vtrpathi); Author Subject: Re: [CiaranWelsh/pycotools3] pycotools3: code for michaelis_menten model creation is not working (#1)

Hello,

The documentation you are referring to sounds a bit old (12 Jan 2019?). I've developed the project more recently than that so my first suggestion would be to just ensure you are using the most up to date version of everything. You can find the documentation herehttps://pycotools.readthedocs.io/en/master/. Also, try ensuring you are using the most recent pycotools.

$ pip uninstall pycotools3

then

$ pip install pycotools3 --no-cache-dir

the --no-cache-dir option just forces pip to redownload the package, rather than using a cached version.

I've tried the following on my own machine, which works as expected.

Let me know how it goes - all the best

Ciaran

import os import site from pycotools3 import model, tasks, viz

working_directory = if not os.path.isdir(working_directory): os.makedirs(working_directory)

copasi_file = os.path.join(working_directory, 'michaelis_menten.cps')

if os.path.isfile(copasi_file): os.remove(copasi_file)

antimony_string = """ model michaelis_menten() compartment cell = 1.0 var E in cell var S in cell var ES in cell var P in cell

kf = 0.1
kb = 1
kcat = 0.3
E = 75
S = 1000

SBindE: S + E => ES; kf*S*E
ESUnbind: ES => S + E; kb*ES
ProdForm: ES => P + E; kcat*ES

end """

with model.BuildAntimony(copasi_file) as loader: mm = loader.load(antimony_string)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/CiaranWelsh/pycotools3/issues/1?email_source=notifications&email_token=AMM3YJW5PQY64RTTKZIHX6TP3NACXA5CNFSM4HZOR2S2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYEX6WI#issuecomment-503938905, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMM3YJX4OB2JHKJJD4JRKOLP3NACXANCNFSM4HZOR2SQ.

CiaranWelsh commented 5 years ago

Hi Vibha,

I've tested pycotools3 on both Copasi 4.24 and 4.25 and behavior is the same as far as I can tell so you're best off using the most recent version.

As for Python, I've also tested this on 3.7 but ran into troubles because of a dependency (tellurium). I haven't chased this up for a while so it may work. If you wanted to quickly test it, it would be a simple case of writing a script (or notebook) that works on Python 3.6, then switching to a Python 3.7 environment and seeing if it works. However, for the time being, 3.6 works well enough.

Jupyter notebooks also work well enough. These days I tend to just use Pycharm, but notebooks are the preference for many.

Pycotools dependencies should install themselves with pycotools. The only exception is COPASI itself. The assumption is that you already have COPASI installed and the path to the copasi/bin folder (i.e. where the copasi binaries are kept) are in your path environment variable. An easy way to test this is to run the command CopasiUI and see if it opens the COPASI GUI.

Good luck,

Ciaran

vibha15 commented 5 years ago

Hi Mr Welsh, Thank you so much for all detailed info. I will go through it and let you know. Thanks

Vibha


From: Ciaran Welsh notifications@github.com Sent: Thursday, June 20, 2019 12:49 PM To: CiaranWelsh/pycotools3 Cc: Vibha Tripathi (vtrpathi); Author Subject: Re: [CiaranWelsh/pycotools3] pycotools3: code for michaelis_menten model creation is not working (#1)

Hi Vibha,

I've tested pycotools3 on both Copasi 4.24 and 4.25 and behavior is the same as far as I can tell so you're best off using the most recent version.

As for Python, I've also tested this on 3.7 but ran into troubles because of a dependency (tellurium). I haven't chased this up for a while so it may work. If you wanted to quickly test it, it would be a simple case of writing a script (or notebook) that works on Python 3.6, then switching to a Python 3.7 environment and seeing if it works. However, for the time being, 3.6 works well enough.

Jupyter notebooks also work well enough. These days I tend to just use Pycharm, but notebooks are the preference for many.

Pycotools dependencies should install themselves with pycotools. The only exception is COPASI itself. The assumption is that you already have COPASI installed and the path to the copasi/bin folder (i.e. where the copasi binaries are kept) are in your path environment variable.

Good luck,

Ciaran

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/CiaranWelsh/pycotools3/issues/1?email_source=notifications&email_token=AMM3YJXVC4CT2F62AWOBSFTP3O7K3A5CNFSM4HZOR2S2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYGEJNY#issuecomment-504120503, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMM3YJRDZ7LZM3Y6C4POZITP3O7K3ANCNFSM4HZOR2SQ.

vibha15 commented 5 years ago

Hi Mr Welsh, I wrote the michaelis menten model acordingly, it worked. Now, i am writing the code of my project, by following mm model in the pycotools doc. But it is showing error including syntax error '(' in line 8 (attached file), that i am not getting. Is code correctly written to produce an output without any input?

Code is as below-

import os import site

site.addsitedir('D:\pycotools3')

from pycotools3 import model, tasks, viz

working_directory = r'.' if not os.path.isdir(working_directory): os.makedirs(working_directory)

copasi_file = os.path.join(working_directory, 'Model_1.cps')

if os.path.isfile(copasi_file): os.remove(copasi_file)

antimony_string = """ model Model_1() compartment cell = 3e-10 var mRNA in cell var miRNA in cell

v(reaction) = 0.045
k1(reaction_1) = 0.069
v(reaction_2) = 0.07
k1(reaction_3) = 0.08
mRNA = 0
miRNA = 0

mRNA is produced:  => mRNA; v(reaction)
mRNA is degraded: mRNA => ; k1(reaction_1)*mRNA
miRNA is produced:  => miRNA; v(reaction_2)
miRNA is degraded: miRNA => ; k1(reaction_3)*miRNA

end """

KM1 = model.loada(antimony_string, copasi_file) KM1

Thanks

Vibha


From: Vibha Tripathi (vtrpathi) Sent: Thursday, June 20, 2019 7:26 PM To: CiaranWelsh/pycotools3 Subject: Re: [CiaranWelsh/pycotools3] pycotools3: code for michaelis_menten model creation is not working (#1)

Hi Mr Welsh, Thank you so much for all detailed info. I will go through it and let you know. Thanks

Vibha


From: Ciaran Welsh notifications@github.com Sent: Thursday, June 20, 2019 12:49 PM To: CiaranWelsh/pycotools3 Cc: Vibha Tripathi (vtrpathi); Author Subject: Re: [CiaranWelsh/pycotools3] pycotools3: code for michaelis_menten model creation is not working (#1)

Hi Vibha,

I've tested pycotools3 on both Copasi 4.24 and 4.25 and behavior is the same as far as I can tell so you're best off using the most recent version.

As for Python, I've also tested this on 3.7 but ran into troubles because of a dependency (tellurium). I haven't chased this up for a while so it may work. If you wanted to quickly test it, it would be a simple case of writing a script (or notebook) that works on Python 3.6, then switching to a Python 3.7 environment and seeing if it works. However, for the time being, 3.6 works well enough.

Jupyter notebooks also work well enough. These days I tend to just use Pycharm, but notebooks are the preference for many.

Pycotools dependencies should install themselves with pycotools. The only exception is COPASI itself. The assumption is that you already have COPASI installed and the path to the copasi/bin folder (i.e. where the copasi binaries are kept) are in your path environment variable.

Good luck,

Ciaran

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/CiaranWelsh/pycotools3/issues/1?email_source=notifications&email_token=AMM3YJXVC4CT2F62AWOBSFTP3O7K3A5CNFSM4HZOR2S2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYGEJNY#issuecomment-504120503, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMM3YJRDZ7LZM3Y6C4POZITP3O7K3ANCNFSM4HZOR2SQ.

CiaranWelsh commented 5 years ago

Hi Vibha,

It looks like there are syntax errors in your antimony model - In antimony, parenthesis are reserved for functions. I suspect this will work if you were to just remove them from your variable naming.

You can find some documentation here.

Something else that can be helpful is to build you model in COPASI, export the SBML and then use a tellurium function tellurium.tellurium.sbmlToAntimony(sbml) here to create an antimony string. I found this useful when I was learning how to use Antimony.

Ciaran