##################################
#                                #
# Last modified 2024/02/07       # 
#                                #
# Georgi Marinov                 #
#                                # 
##################################

import sys
import string
import os
import math

def run():

    if len(sys.argv) < 2:
        print 'usage: python %s input outfile' % sys.argv[0]
        sys.exit(1)

    input = sys.argv[1]
    outfilename = sys.argv[2]

    outfile = open(outfilename,'w')

    linelist = open(input)
    for line in linelist:
        if line.startswith('#'):
            continue
        fields = line.strip().split('\t')
        type = fields[0]
        if type == 'GO Biological Process' or type == 'Human Phenotype':
            pass
        else:
            continue
        FDR = float(fields[4])
        if FDR == 0:
            FDR = 100
        else:
            FDR = -math.log10(FDR)
        outline = type + '\t' + fields[1] + '\t' + str(FDR)
        outfile.write(outline + '\n')

    outfile.close()


run()

