Package Biskit :: Module settings
[hide private]
[frames] | no frames]

Source Code for Module Biskit.settings

  1  ## 
  2  ## Biskit, a toolkit for the manipulation of macromolecular structures 
  3  ## Copyright (C) 2004-2005 Raik Gruenberg & Johan Leckner 
  4  ## 
  5  ## This program is free software; you can redistribute it and/or 
  6  ## modify it under the terms of the GNU General Public License as 
  7  ## published by the Free Software Foundation; either version 2 of the 
  8  ## License, or any later version. 
  9  ## 
 10  ## This program is distributed in the hope that it will be useful, 
 11  ## but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 13  ## General Public License for more details. 
 14  ## 
 15  ## You find a copy of the GNU General Public License in the file 
 16  ## license.txt along with this program; if not, write to the Free 
 17  ## Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
 18  ## 
 19  ## 
 20  ## last $Author: graik $ 
 21  ## last $Date: 2006/12/19 09:25:37 $ 
 22  ## $Revision: 2.6 $ 
 23   
 24  """ 
 25  Settings 
 26  ======== 
 27   
 28  This module provides global settings as fields. Throughout Biskit a 
 29  (environment-dependent) parameter such as, e.g., ssh_bin can be addressed as: 
 30   
 31    >>> import Biskit.settings as S 
 32    >>> bin = S.ssh_bin 
 33   
 34  However, since a user should not be required to hack python modules, 
 35  ssh_bin is not actually defined in settings.py. Instead, the value is 
 36  taken from C{~/.biskit/settings.cfg} -- which should have an entry 
 37  like C{ssh_bin=/bin/ssh # comment}. If this entry (or the config file) 
 38  is not found, settings.py uses the default value from 
 39  C{biskit/external/defaults/settings.cfg}. 
 40   
 41  If missing, the user configuration file C{~/.biskit/settings.cfg} is 
 42  created automatically during the startup of Biskit (i.e. for any 
 43  import). The auto-generated file only contains parameters for which 
 44  the default values don't seem to work (invalid paths or binaries). 
 45   
 46  See L{Biskit.SettingsManager} 
 47   
 48  Summary for Biskit users 
 49  ------------------------ 
 50    If you want to change a biskit parameter, do so in C{~/.biskit/settings.cfg} 
 51   
 52  Summary for Biskit developpers 
 53  ------------------------------ 
 54    If you want to create a new user-adjustable parameter, do so in 
 55    C{biskit/external/defaults/settings.cfg}. 
 56   
 57  Summary for all 
 58  --------------- 
 59    !Dont't touch C{settings.py}! 
 60  """ 
 61  import Biskit as B 
 62  import Biskit.tools as T 
 63  import Biskit.SettingsManager as M 
 64   
 65  import user, sys 
 66   
 67  __CFG_DEFAULT = T.projectRoot() + '/external/defaults/settings.cfg' 
 68  __CFG_USER    = user.home + '/.biskit/settings.cfg' 
 69   
 70  try: 
 71      m = M.SettingsManager(__CFG_DEFAULT, __CFG_USER, createmissing=True  ) 
 72   
 73      m.updateNamespace( locals() ) 
 74   
 75  except Exception, why: 
 76      B.EHandler.fatal( 'Error importing Biskit settings') 
 77   
 78  ## 
 79  ## Create some settings on the fly 
 80  ## 
 81  python_bin = sys.executable 
 82  xterm_bin  = T.absbinary('xterm') 
 83  projectRoot= T.projectRoot() 
 84   
 85  pymol_scripts = projectRoot + '/external/pymol/' 
 86   
 87   
 88  ################################### 
 89  ## required environment variables. 
 90  ## format: ENV_NAME : path_example 
 91   
 92  ## Todo: These need to go to their Exe_*.dat files 
 93   
 94  env = {} 
 95   
 96  blast_env = {'BLASTDB':'/home/Bis/raik/data/prog/blast/db', 
 97               'BLASTMA':'/home/Bis/johan/APPLICATIONS/blast'} 
 98   
 99  amber_env = {'AMBERHOME_8':'/Bis/shared/rh73/amber8_intel-7.1'} 
100   
101  env.update(blast_env) 
102  env.update(amber_env) 
103   
104  ###################### 
105  ## clean up name space 
106   
107  del B, T, M, user, sys 
108  del __CFG_DEFAULT, __CFG_USER, m 
109