Example #1
0
def input_file_run(objs, infile, outfile, detail):
    '''
    Run TCSS when input file is provided.
    '''
    file = open(infile, 'r')
    result = ""
    for line in file:
        line = line.strip().split(",")
        if len(line) > 2:
            print('File format not proper: refer README')
            sys.exit()
        result += calculate_semantic_similarity(objs, line[0], line[1], detail)
    file.close()
    output_results(result, outfile)
Example #2
0
def input_file_run(objs, infile, outfile, detail):
    '''
    Run TCSS when input file is provided.
    '''
    file = open(infile, 'r')
    result = ""
    for line in file:
        line = line.strip().split(",")
        if len(line) > 2:
            print 'File format not proper: refer README'
            sys.exit()
        result += calculate_semantic_similarity(objs, line[0], line[1], detail)
    file.close()
    output_results(result, outfile)     
Example #3
0
    Output the results on screen or on file. 
    '''
    if outfile:
        try:
            file = open(outfile, 'w')
            file.write(result)
            file.close()
        except:
            print(
                "Cannot open output file: check path or permissions \n Printing results on screen"
            )
            print(result)
    else:
        print(result)


if __name__ == '__main__':

    options = _command_line_arguments(sys.argv[1:])
    objs = load_semantic_similarity(options['go'], options['gene'],
                                    options['ontology'], options['drop'])

    if options['input']:
        input_file_run(objs, options['input'], options['output'],
                       options['detail'])
    else:
        result = calculate_semantic_similarity(objs, options['args'][0],
                                               options['args'][1],
                                               options['detail'])
        output_results(result, options['output'])
Example #4
0
        
        
def output_results(result, outfile):
    '''
    Output the results on screen or on file. 
    '''
    if outfile:
        try:
            file = open(outfile, 'w')
            file.write(result)
            file.close()
        except:
            print "Cannot open output file: check path or permissions \n Printing results on screen"
            print result
    else:
        print result
        

    
if __name__ == '__main__':
    
    options = _command_line_arguments(sys.argv[1:])
    objs = load_semantic_similarity(options['go'], options['gene'], options['ontology'], options['drop'])
    
    if options['input']:
        input_file_run(objs, options['input'], options['output'], options['detail'])
    else:
        result = calculate_semantic_similarity(objs, options['args'][0], options['args'][1], options['detail'])
        output_results(result, options['output'])