Ejemplo n.º 1
0
def conf_result():
    '''
    deprecated. 
    returns the confidence result. 
    Keyscore and value score. 
    1. get arguments from parser
    2. use arguments to feed into our keydb_marginal_newkey and get_score from confidenceval
    3. return the result in json format. 
    '''
    args = parser.parse_args()
    key = args['key'] 
    value = args['value']
    cancername = args['cancer']
    if cancername.strip()=='':
        cancername  = args.get('cancer_select')
    if cancername == None:
        cancername = request.form.get('cancer_select')
        
    marginaldbname = str(cancername)+'.data'
    if key == None:
        key = request.form.get('key')
        value = request.form.get('value')
        cancername = request.form.get('cancername')
        if cancername==None:
            cancername  = request.form.get('cancer_select')
        marginaldbname = str(cancername)+'.data'
    if key==None or value == None:
        
        return ' '.join([str(item) for item in ['No info', 'key',key,'value',value,'cancername',cancername]])
    else:
        keyresult = ''
        try:
            marginaldb = keydb_marginal_load(marginaldbname)
            keyresult = keydb_marginal_newkey(key,marginaldb)
        except Exception,err:
            print err
            print 'ERROR: key db error'
        
        stringValResult = ''
        try:
            valresult = getScore(key,value,keydb_marginal_load('Valdb.data'))
            stringValResult = ' '.join([str(item) for item in valresult.values()])
        except Exception, err:
            print err
            print 'ERROR: val db error'
Ejemplo n.º 2
0
def Extract():
    '''
    depracted. Use jsontest instead. 
    this is a nice web interface for testing. 
    user only needs to input text and a univerid, 
    Returns: 
        json formated result from given text and universe_id
    '''
    args = parser.parse_args()
    note = args['text']
    cancerName = args['universe_id']
    print 'args:',args
    print 'form:',request.form
    #should ahve just check form first then the args. 
    if note == None:
        note = request.form.get('data')
        cancerName = request.form.get('cancer')
        
    if cancerName is None:
        cancerName = ''
        
    if note == None or note.strip()=='':
        return 'No info'
    else:
        result = {}
        try:
            result = checkAllcancer(note)
            result_confidence= result.copy()
            for cancer in result.keys():
                if cancerName.strip() != '':
                    marginaldbname = cancerName.lower()+'.data'
                else:
                    marginaldbname=None
                print 'marginaldbname: ',marginaldbname
                if marginaldbname is not None:
                    marginaldb = keydb_marginal_load(marginaldbname)
                else:
                    marginaldb = keydb_marginal_load()
                ########################################
                # the below code is for getting confidence score. 
                #########################################                
                for k,v in result[cancer].items():
                    #note that v is a list contains value and original value. 
                    value = v[0]
                    #now we can do value processing. 
                    #put your code here
                    
                    #now we can do key confidence processing. 
                    #it needs a library indicating which unverse it belongs to. 
                    #in here we will just try to use our pre-existing libraries. 
                    #namely, if you have breast cancer as cancer, then
                    try:
                        result_confidence[cancer][k].append(keydb_marginal_newkey(k,value,marginaldb,marginaldbname,True))
                    except Exception, err:
                        print 'ERROR: key_confidence failed'
                        print err
                    try:
                        value_score = getScore(k,value,keydb_marginal_load('Valdb.data'))
                        result_confidence[cancer][k].append(' '.join([str(item) for item in value_score.values()]))
                    except Exception, err:
                        print 'ERROR: value_confidence failed'
                        print err

            result['specimens']=get_section(note)
Ejemplo n.º 3
0
    def set_value_score(self,valdb):
#        print "key",self.key,"value",self.value
        self.value_score = getScore(self.key,self.value,valdb = valdb, add=True)