SLiMSuite REST Server


Links
REST Home
EdwardsLab Homepage
EdwardsLab Blog
SLiMSuite Blog
SLiMSuite
Webservers
REST Pages
REST Status
REST Help
REST Tools
REST Alias Data
REST API
REST News
REST Sitemap

rje V4.18.0

Contains General Objects for all my (Rich's) scripts

Module: rje
Description: Contains General Objects for all my (Rich's) scripts
Version: 4.18.0
Last Edit: 28/09/16

Copyright © 2005 Richard J. Edwards - See source code for GNU License Notice


See SLiMSuite Blog for further documentation.

Function

General module containing Classes used by all my scripts plus a number of miscellaneous methods. - Output to Screen, Commandline parameters and Log Files

Commandline options are all in the form X=Y. Where Y is to include spaces, use X="Y".

General Commandline

v=X : Sets verbosity (-1 for silent) [0]
i=X : Sets interactivity (-1 for full auto) [0]
log=FILE : Redirect log to FILE [Default = calling_program.log]
newlog=T/F : Create new log file. [Default = False: append log file]
silent=T/F : If set to True will not write to screen or log. [False]
errorlog=FILE : If given, will write errors to an additional error file. [None]
help : Print help to screen

Program-Specific Commands

basefile=FILE : This will set the 'root' filename for output files (FILE.*), including the log
outfile=FILE : This will set the 'root' filename for output files (FILE.*), excluding the log
delimit=X : Sets standard delimiter for results output files [\t]
mysql=T/F : MySQL output
append=T/F : Append to results files rather than overwrite [False]
force=T/F : Force to regenerate data rather than keep old results [False]
backups=T/F : Whether to generate backup files (True) or just overwrite without asking (False) [True]
maxbin=X : Maximum number of trials for using binomial (else use Poisson) [-]

System Commandline

win32=T/F : Run in Win32 Mode [False]
osx=T/F : Run in MacOSX Mode [False]
pwin : Run in PythonWin (** Must be 'commandline', not in ini file! **)
cerberus : Run on Cerberus cluster at RCSI
memsaver=T/F : Some modules will have a memsaver option to save memory usage [False]
runpath=PATH : Run program from given path (log files and some programs only) [path called from]
rpath=PATH : Path to installation of R ['R']
webserver=T/F : Trigger webserver run and output [False]
soaplab=T/F : Implement special options/defaults for SoapLab implementations [False]
rest=X : Variable that sets the output to be returned by REST services [None]

Forking Commandline

noforks=T/F : Whether to avoid forks [False]
forks=X : Number of parallel sequences to process at once [0]
killforks=X : Number of seconds of no activity before killing all remaining forks. [36000]

Development Commandline

debug=T/F : Turn on additional debugging prints and prompts [False]
warn=T/F : Turn on program integrity check warnings (unless silent) [True]
test=T/F : Run additional testing methods and/or produce additional test outputs [False]
dev=T/F : Run development-specific code. (Added to keep main coding working during dev) [False]

Classes

[RJE_Object(log=None,cmd_list]{cmd:RJE_Object(log}=[]):
- Metclass for inheritance by other classes.
>> log:Log = rje.Log object
>> cmd_list:List = List of commandline variables
On intiation, this object:
- sets the Log object (if any)
- sets verbosity and interactive attributes
- calls the _setAttributes() method to setup class attributes
- calls the _cmdList() method to process relevant Commandline Parameters
[Log(itime=time.time(),cmd_list]{cmd:Log(itime}=[]):
- Handles log output; printing to log file and error reporting
>> itime:float = initiation time
>> cmd_list:list of commandline variables
Info(prog='Unknown',vers='X',edit='??/??/??',desc='Python script',author='Unknown',ptime=None):
- Stores intro information for a program.
>> prog:str = program name
>> vers:str = version number
>> edit:str = last edit date
>> desc:str = program description
>> author:str = author name
>> ptime:float = starting time of program, time.time()
Out(cmd=[]):
- Handles basic generic output to screen based on Verbosity and Interactivity for modules without classes.
>> cmd:list = list of command-line arguments

History Module Version History

    # 0.0 - Initial Compilation based on RJE_General01.plx. Simplified Class Names
    # 0.1 - Added comments and changed capitilisation etc.
    # 0.2 - Added RJE_Object class and 'No Log' concept
    # 0.3 - Updated RJE_Object to not need Out object (restrict Out Object to Log object?)
    # 1.0 - Better Documentation to go with GASP V:1.2
    # 1.1 - Added make Path and sorted ErrorLog
    # 1.1 - def errorLog(self, text='Missing text for errorLog() call!',quitchoice=False,printerror=True):
    # 1.2 - Added Norman's error-tracking and 'basefile/outfile' options as Object defaults
    # 2.0 - Major Overhaul of Module. Out, Log and RJE_Object will now inherit RJE_Object_Shell (see also changes below)
    # 2.1 - Added X="Y" options
    # 2.2 - Added confirm=T/F option to choice()
    # 2.3 - Added more delimited text functions
    # 2.4 - Added listFromCommand() function
    # 2.5 - Added Force opt
    # 3.0 - Added self.list and self.dict dictionaries to RJE_Object. Added 'list', 'clist' and 'glist' to cmdRead.
    # 3.1 - Added object save and load methods
    # 3.2 - Added more refined path options
    # 3.3 - Added general delimitedFileOut() method based on slim_pickings.py compileOut()
    # 3.4 - Added cmdReadList for handling lists of "standard" options
    # 3.5 - Added getFileName for interactive input of file names with confirmation/existence options and checkInputFiles()
    # 3.6 - Added dataDict() method for extracting data from delimited file into dictionary
    # 3.7 - Added extra dictionary methods for storage and retrieval of results in a dict['Data'] dictionary
    # 3.8 - Gave module a general tidy up.
    # 3.9 - Added RunPath to control where program is run.
    # 3.10- Added errorlog=FILE option to redirect errors to an additional error file.
    # 3.11- Added dictionary ranking method.
    # 3.12- Added more list methods.
    # 4.0 - Added RJE_ObjectLite for data storage objects with minimal generic methods and attributes.
    # 4.1 - Added a bioware_server switch for reading iniServer/ ini files on bioware.
    # 4.2 - Modified INI reading across the board to look in ../settings/ and look for defaults.ini as well as rje.ini.
    # 4.2 - Enabled handing on -ini FILE in addition to ini=FILE.
    # 4.3 - Added ilist and nlist types to cmdRead for objects. (Lists of integers and floats). Add ratio() function.
    # 4.4 - Added lineFromIndex(target,file,re_index='^(\S+)\s',sortunique=False,xreplace=True).
    # 4.5 - Modified randomString() and added stringShuffle() methods.
    # 4.6 - Added dev and warn options. Fixed -h lack of help.
    # 4.7 - Added self.warn list and self.warnLog() functions to Log object. Modified i=-1 quitchoice to raise not quit.
    # 4.8 - Added perc cmdtype = float that is multiplied by 100.0 if < 1.0. Removed server option from iniCmds().
    # 4.9 - Added rje.slimsuite, which determines the slimsuite home directory from rje.py file path.
    # 4.10- Added osx=T/F option for Mac-specific running options.
    # 4.11- Enabled '\t#' comments in ini files. Modified getStrLC to return '' for 'none' by default. Added listMax().
    # 4.11- Added self.name() to basic object class.
    # 4.12- Added 'bool' and 'str' to _cmdRead() to ease switchover to new RJE_Objects.
    # 4.13.0 - Added new built-in attributes/options for REST services.
    # 4.13.1 - Fixed MemSaver typo in WarnLog output. Modified mkDir() to avoid clashes raising errors.
    # 4.13.2 - Removed excess REST HTML methods.
    # 4.13.3 - Added uselower=False to dataDict() method.
    # 4.13.4 - Added maxrep=X to listCombos() method.
    # 4.14.0 - Added listToDict() method.
    # 4.14.1 - Fixed matchExp method to be able to handline multilines. (Shame re.DOTALL doesn't work!)
    # 4.14.2 - Modified integer commands to read/convert floats.
    # 4.15.0 - Added intList() and numList() functions.
    # 4.15.1 - Fixed rare errorlog printlog error vicious cycle.
    # 4.16.0 - Added list2dict(inlist,inkeys) and dict2list(indict,inkeys) functions.
    # 4.16.1 - Improved handling of integer parameters when given bad commands.
    # 4.17.0 - Added extra functions to randomList()
    # 4.18.0 - Added Roman numeral functions.

© 2015 RJ Edwards. Contact: richard.edwards@unsw.edu.au.