예제 #1
0
파일: view.py 프로젝트: tljm/eTOXlab
def main():

    endpoint = None
    ver = -99
    mol = None
    vtype = None
    background = None
    refname = None
    refver = None

    try:
        opts, args = getopt.getopt(
            sys.argv[1:], 'e:f:v:h',
            ['type=', 'background', 'refname=', 'refver='])

    except getopt.GetoptError:
        writeError('Error. Arguments not recognized')
        usage()
        sys.exit(1)

    if args:
        writeError('Error. Arguments not recognized')
        usage()
        sys.exit(1)

    if len(opts) > 0:
        for opt, arg in opts:

            if opt in '-e':
                endpoint = arg
            elif opt in '-f':
                mol = arg
            elif opt in '-v':
                if 'last' in arg:
                    ver = -1
                else:
                    try:
                        ver = int(arg)
                    except ValueError:
                        ver = -99

            elif opt in '-h':
                usage()
                sys.exit(0)
            elif opt in '--type':
                vtype = arg
            elif opt in '--background':
                background = True
            elif opt in '--refname':
                refname = arg
            elif opt in '--refver':
                try:
                    refver = int(arg)
                except:
                    refver = 0

    if not mol and ver == -99:
        usage()
        sys.exit(1)

    if not endpoint:
        usage()
        sys.exit(1)

    if vtype not in [None, 'pca', 'property', 'project', 'model']:
        print '+', property, '+'
        usage()
        sys.exit(1)

    if vtype == 'project' and (refname == None and mol == None):
        print 'project view type requires to define the reference endpoint name'
        usage()
        sys.exit(1)

    if vtype == 'project' and refver == None:
        refver = 0


##    print vtype, background, refname, refver

    result = view(endpoint, mol, ver, vtype, background, refname, refver)

    presentResults(result)
예제 #2
0
def main ():

    endpoint = None
    ver = -99
    loc = -99
    api = 0
    mol = None
    
    progress = False
    detail   = False
    extvalid = False

    try:
       opts, args = getopt.getopt(sys.argv[1:], 'abcge:f:v:s:hqx')

    except getopt.GetoptError:
       writeError('Error. Arguments not recognized')
       usage()
       sys.exit(1)

    if args:
       writeError('Error. Arguments not recognized')
       usage()
       sys.exit(1)
        
    if len( opts ) > 0:
        for opt, arg in opts:

            if opt in '-e':
                endpoint = arg
                
            elif opt in '-f':
                mol = arg
                
            elif opt in '-v':
                if 'last' in arg:
                    ver = -1
                else:
                    try:
                        ver = int(arg)
                    except ValueError:
                        ver = -99

            elif opt in '-x':   ### run external validation using embeeded activity values
                extvalid = True

            ##################################################################
            ###    Internal prediction calls
            ###
            ###    modifier     API         use
            ###     none        0           interactive, command mode use
            ###    -a           1           web service v1 (deprecated)
            ###    -b           2           web service v2 
            ###    -c           6           web service v3 
            ###    -s           3           local model (followed by local ID)
            ###    -g           4           eTOX GUI
            ###    -q           5           internal from hierarchical model
            ###
            ###     Not for use in command mode. Do not document with -h !
            ###
            ##################################################################

            elif opt in '-a':   ### web service call. API v1 (deprecated)
                api = 1
                
            elif opt in '-b':   ### web service call. API v2
                api = 2

            elif opt in '-c':   ### web service call. API v3
                api = 6
                
            elif opt in '-s':   ### call for local models (like HERG4)
                api = 3
                loc = int(arg)

            elif opt in '-g':   ### eTOXlab GUI calls
                api = 4
                
            elif opt in '-q':   ### internal call from hierarchical models (like LQT)
                api = 5

            elif opt in '-h':
                usage()
                sys.exit(0)

    if ver == -99:
        if api in (1,2,5):  # web services API v1 and v2 or hierarchical models do not define versions
            pass
        else:
            usage()
            sys.exit (1)

    if api in (1,2,3,4,5,6):
        sys.path.append ('/opt/RDKit/')
        sys.path.append ('/opt/standardiser/standardise20140206/')

    if api in (2,6):
        progress = True
        
    if not mol:
        if api==0:    # for interactive use the definition of mol is compulsory
            usage()
            sys.exit (1)
        else:         # for non-interactive calls, input_file.sdf is the default
            mol = './input_file.sdf'
        
    if not endpoint:
        usage()
        sys.exit (1)

    # make sure imodel has not been copied to eTOXlab/src. If this were true, this version will
    # be used, instead of those on the versions folder producing hard to track errors and severe
    # misfunction
    
    testimodel()

    result=predict (endpoint,mol,ver,api,loc,
                    detail, progress, extvalid)
    
    presentPrediction (result, api)
    
    sys.exit(0)
예제 #3
0
def reportError(e):
    try:
        writeError(e)
        waterLogClient.addSystemEvent(waterLogClient.ERROR_SYSTEM_EVENT)
    except:
        pass