You are not allowed to perform this action.

Clear message

Overview

Develop Environment

Python

SPARX

EMAN2

Before you start programming

Installation

The 'SPARX' packages are installed under a user-chosen directory. Installation from source is fully compatible with your system. After download the source, the steps are

   mkdir/sparx
   tar zxvf sparx-installer.tar.gz
   cd sparx-installer
   ./install/sparx

The installer does not touch anything outside those two directories, and it works on any linux system. For further question, click HowToInstall or email to mhhohn@lbl.gov .

To update, upload, and remove individual parts

Update for sparx and EMAN2

   cd ~/sparx
   cvs up -dP
   cd ~/sparx/libpy
   cvs up -dP

   cd ~/EMAN2/src/eman2
   cvs up -dP
   cd ~/EMAN2/src/build
   cmake ../eman2
   make && make install

Upload individual parts to CVS

   cvs add filename.py
   cvs ci filename.py 

Remove individual parts to CVS

   rm /user/home/sparx/bin/filename.py 
   cvs remove filename.py
   cvs ci filename.py 

To run Python program

There are two ways to start running Pyton code. First, you can simply type the command on the window sparx and it allows your computer start the sparx console. To use SPARX library, you need to import fuctions first.

   In [1]: from sparx import *

If you want to test one specific function, for example info, in applications.py located in /user/home/sparx/lipbin, then you type on the console like below,

   In [2]: from applications import info
   In [3]: info(''file or parameter name'')

Of course, you don't want to type every single line command on the console. To make an excute pyton file, we need to put below code inside of the file. Make sure that your_python_program has to be same as the file name.

   #! /usr/bin/env python
   import os from EMAN2 
   import * from sparx 
   from optparse import OptionParser import sys
   from your_python_file import your_python_program

   def main():
       # This example recieve one string and one number as input
       progname = os.path.basename(sys.argv[0]) usage = progname + "--num = number"
       parser = OptionParser(usage,version=SPARXVERSION) 
       parser.add_option("num", type="float",default=1, help="  ")
       (options, args) = parser.parse_args() 
       your_python_program(options.num)

   if __name__ == "__main__":
      main()

Once you have an excute *.py file, you need to give it a permision on the Unix terminal.

   chmod u+x 
   source usr/.cshrc