<s> '''<STR_LIT>''' <EOL> import os <EOL> import tempfile <EOL> import subprocess <EOL> import shutil <EOL> from types import * <EOL> from CGAT import Experiment as Experiment <EOL> from CGAT import Mali as Mali <EOL> class Error ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def __str__ ( self ) : <EOL> return str ( self . message ) <EOL> class ParsingError ( Error ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , message , line ) : <EOL> self . message = message + "<STR_LIT>" + line <EOL> class UsageError ( Error ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , message ) : <EOL> self . message = message <EOL> class Muscle : <EOL> mExecutable = "<STR_LIT>" <EOL> def __init__ ( self ) : <EOL> self . mTempdir = None <EOL> def __del__ ( self ) : <EOL> if self . mTempdir and self . mTempdir != "<STR_LIT>" : <EOL> os . system ( "<STR_LIT>" % self . mTempdir ) <EOL> def Run ( self , mali , <EOL> tree = None , <EOL> dump = <NUM_LIT:0> , <EOL> test = False , <EOL> options = { } ) : <EOL> self . mTempdir = tempfile . mkdtemp ( ) <EOL> self . mFilenameInput = "<STR_LIT:input>" <EOL> self . mFilenameOutput = "<STR_LIT>" <EOL> if test : <EOL> print "<STR_LIT>" % self . mTempdir <EOL> mali . writeToFile ( open ( self . mTempdir + "<STR_LIT:/>" + self . mFilenameInput , "<STR_LIT:w>" ) , <EOL> format = "<STR_LIT>" ) <EOL> statement = "<STR_LIT:U+0020>" . join ( ( self . mExecutable , <EOL> "<STR_LIT>" % self . mFilenameInput , <EOL> "<STR_LIT>" % self . mFilenameOutput ) ) <EOL> s = subprocess . Popen ( statement , <EOL> shell = True , <EOL> stdout = subprocess . PIPE , <EOL> stderr = subprocess . PIPE , <EOL> cwd = self . mTempdir , <EOL> close_fds = True ) <EOL> ( out , err ) = s . communicate ( ) <EOL> if s . returncode != <NUM_LIT:0> : <EOL> raise UsageError , "<STR_LIT>" % ( <EOL> self . mExecutable , err , out , self . mTempdir ) <EOL> if dump : <EOL> print "<STR_LIT>" % ( self . mExecutable , out ) <EOL> result = Mali . Mali ( ) <EOL> result . readFromFile ( <EOL> open ( "<STR_LIT>" % ( self . mTempdir , self . mFilenameOutput ) , "<STR_LIT:r>" ) , format = "<STR_LIT>" ) <EOL> if not test : <EOL> shutil . rmtree ( self . mTempdir ) <EOL> return result <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> parser = E . OptionParser ( <EOL> version = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( <EOL> filename_input_tree = None , <EOL> filename_output_tree = None , <EOL> program = None , <EOL> options = "<STR_LIT>" , <EOL> ) <EOL> ( options , args ) = Experiment . Start ( parser ) <EOL> Experiment . Stop ( ) </s>
