Question: running modeller through python scripts
1
gravatar for Moses
4.7 years ago by
Moses70
united states/ Bloomingtion/ Indiana University Bloomington
Moses70 wrote:

Hi everyone,

I installed the modeller program on my computer. I'm running a Lubuntu 32-bit system. I have python istaleld. I can check that by running: python --version on a terminal. however whenver I run a script that has modeller functions in it, like executing this script: python model-default.py > model-default.log it's giving me this result:

    Traceback (most recent call last):
    File "model-default.py", line 4, in <module>
    from modeller import *              # Load standard Modeller classes
     ImportError: No module named modeller

what should I do in order to be able to import modeller inside my python scripts? also is there an easy API for modeller so that I can run it in java? Thank you.

 

lubuntu python 2.7 python • 6.9k views
ADD COMMENTlink modified 4.7 years ago by João Rodrigues2.5k • written 4.7 years ago by Moses70
3
gravatar for João Rodrigues
4.7 years ago by
João Rodrigues2.5k
Stanford University, U
João Rodrigues2.5k wrote:

When you install MODELLER it warns you to add a few folders to the PYTHONPATH and LD_LIBRARY_PATH environment variables. Locate your MODELLER installation to find out the folders you need. You can use the command: locate _modeller.so.

Our .bashrc scripts have the following in them to load the folder at login.

if [ -z $PYTHONPATH ]
then
    export PYTHONPATH="/folder/science/modeller/lib/x86_64-intel8/python2.5/:/folder/science/modeller/modlib/"
else
    export PYTHONPATH="${PYTHONPATH}:/folder/science/modeller/lib/x86_64-intel8/python2.5:/folder/science/modeller/modlib/"
fi

if [ -z $LD_LIBRARY_PATH ]
then
    export LD_LIBRARY_PATH="/folder/science/modeller/lib/x86_64-intel8"
else
    export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/folder/science/modeller/lib/x86_64-intel8"
fi
ADD COMMENTlink written 4.7 years ago by João Rodrigues2.5k

I see, whenever I do: echo $PYTHONPATH on a terminal in LUBUNTU it's just returning me blank.    

    mossig@mossig-linux:~$ echo $PYTHONPATH

    mossig@mossig-linux:~$ 

by the result of this I'm assuming that the PYTHONPATH isn't set up, even though i've added those two folders inside Modeller to pythonpath couple of times, so each time it's resetting for some reason by the looks of it.

this script that you posted, should I copy them inside my  scripts? if yes to which script should I copy it? I didn't understand what a .bashrc scipt is. Thank you.

ADD REPLYlink written 4.7 years ago by Moses70

I copied the above code in all my .bashrc scripts. basically I did a "locate .bashrc" command in a terminal and it returned me with this:

/etc/bash.bashrc
/etc/skel/.bashrc
/home/mossig/.bashrc
/home/mossig/.bashrc-anaconda.bak
/usr/share/base-files/dot.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bashrc

Not knowing what exactly these .bashrc scripts do exactly, I've copy pasted the code that you stated in the above answer in all of the scripts ending with the extension .bashrc after that I executed the command: python model-default.py after becoming root. the command did execute and was able to locate the modeller library. Thank you. 

now I'm downloading Spyder Anaconda to use it as an IDE to develop my python scripts. I hope that the python compilers that are installed with anaconda do not conflict with the existing python compiler and I will be able to import Modeller libraries using the spyder IDE for python.

 

ADD REPLYlink written 4.7 years ago by Moses70

#1. Python is interpreted, not compiled.

#2. You should NOT run modeller as root.

#3. Editing ALL .bashrc scripts is a bad idea. Edit your own only, located in your own directory. This script is run every time you login / start the bash shell. When you change an environment variable on your terminal, it is changed only while that particular terminal window is open. Once you close it and open another one, the changes are lost. Adding a change to the .bashrc makes that change "permanent", meaning, it happens every time you login.

Anaconda is a package manager and Spyder an IDE. I'd try to find something that ties everything together, such as PyCharm so that you don't run into problems and make your life easier.

ADD REPLYlink written 4.7 years ago by João Rodrigues2.5k

all right. I've removed that piece of code from all the scripts with the extension .bashrc except the ones located under the folder with my name as you said:

/home/mossig/.bashrc
/home/mossig/.bashrc-anaconda.bak

after that I issued a command python model-default.py and it ran normally

Thank you for this.

concerning Anaconda and spyder, when I opened this exact script that I ran through the terminal model-default.py) using spyder and clicked run it returned me this as an output inside t he shell:

     Python 2.7.7 |Anaconda 2.0.1 (32-bit)| (default, Jun  2 2014, 12:37:33) 
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    Anaconda is brought to you by Continuum Analytics.
    Please check out: http://continuum.io/thanks and https://binstar.org
    >>> runfile('/home/mossig/anaconda/scripts/modeller/automodel/model-default.py',             wdir=r'/home/mossig/anaconda/scripts/modeller/automodel')
    Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
      File "/home/mossig/anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line     585, in runfile
       execfile(filename, namespace)
      File "/home/mossig/anaconda/scripts/modeller/automodel/model-default.py", line 2, in <module>
        from modeller import *              # Load standard Modeller classes
        File "/usr/lib/modeller9.14/modlib/modeller/__init__.py", line 140, in <module>
        info.jobname = nam
      File "/usr/lib/modeller9.14/modlib/modeller/information.py", line 35, in __set_jobname
        return _modeller.mod_jobname_set(val)
    TypeError: in method 'mod_jobname_set', argument 1 of type 'char const *'

However later on I changed the setting from spyder by going to: run >> configure >> under the interpreter section I chose "Execute in a new dedicated Python interpreter" rather than "Execute in current Python or IPython interpreter" which was selected by default. after I did this change and re-ran the script it ran normally and returned exactly the same output as it did in the case of running the same script using a terminal. I don't understand the reason to this. Is it wrong for me to change the interpreter setting that I mentioned and run it? Thank you.

ADD REPLYlink written 4.7 years ago by Moses70
0
gravatar for RamRS
4.7 years ago by
RamRS24k
Houston, TX
RamRS24k wrote:

Install the modeller python package and add the appropriate dir to your PATH so you can import it. Take a look at https://salilab.org/modeller/release.html#deb and http://salilab.org/archives/modeller_usage/2013/msg00177.html

ADD COMMENTlink written 4.7 years ago by RamRS24k

I changed the paths as stated at: http://salilab.org/archives/modeller_usage/2013/msg00177.html 

however when running the script still I get the same message. ImportError: No module named modeller.

should I put the python script in a specific folder to compile it? I have installed modeller by following the steps on the website found at: https://salilab.org/modeller/release.html#deb specifically the installation for LInux (Debian/Ubuntu) since my OS is Lubuntu 14 32-bit. 

when I run the command: python --version on the terminal i'm getting this:

Python 2.7.7 :: Anaconda 2.0.1 (32-bit)

should I install another version of python? I don't understand why the script is not running. Thank you.

 

ADD REPLYlink written 4.7 years ago by Moses70

unless you installed modeller through "Anaconda", it is unlikely that python will find modeller...

ADD REPLYlink written 4.7 years ago by Whetting1.5k

NoI haven't instaled MODELLER through anaconda, I installed it seperately following the steps provided at their website: 

https://salilab.org/modeller/release.html#deb. and python was already found on the system. it's just that I can't seem to find a way to compile the scripts written by modller, which are python scripts that import modeller module. I want to know the way that pythons compiler sees and compiles the modeller imports. Thank you.

ADD REPLYlink written 4.7 years ago by Moses70
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2645 users visited in the last hour