running modeller through python scripts
2
1
Entering edit mode
9.8 years ago
Moses ▴ 150

Hi everyone,

I installed the modeller program on my computer. I'm running a Lubuntu 32-bit system. I have python installed. I can check that by running python --version on a terminal. However whenever 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 python2.7 • 13k views
ADD COMMENT
3
Entering edit mode
9.8 years ago
João Rodrigues ★ 2.5k

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode
  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 REPLY
0
Entering edit mode

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 the 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 REPLY
0
Entering edit mode
9.8 years ago
Ram 44k

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

No I haven't installed MODELLER through anaconda, I installed it separately 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 modeller, 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 REPLY

Login before adding your answer.

Traffic: 1508 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6