#!/usr/bin/python # this script find full taxonomy from file of tax ID # usage: python id_to_tax.py id_file.txt > full_tax.txt import sys import taxonomy_finder for line in open(sys.argv[1], "r"): print line.strip() + "\t" + taxonomy_finder.from_id(line.strip())
#print len(dict) #process normal_counts count = open(sys.argv[1],'r') fwrite = open(sys.argv[4],'w') lines = count.next() fwrite.write(lines.strip()+'\t'+'organism'+'\t'+'function'+'\t'+'ec'+'\t'+'full_tax'+'\n') for line in count: splt = line.strip().split('\t') organism = "null" function = "null" ecnum = "null" fulltax = "null" if(dict.has_key(splt[0])): md5 = dict[splt[0]][0] function = dict[splt[0]][2] ecs = function.split("EC:") if(len(ecs)>1): ec = ecs[1].split(")") ecnum = ec[0] if(ordict.has_key(splt[0])): organism = ordict[splt[0]][2] taxid = mg_rast_jason.get_taxid(md5) if(str(taxid)!="null"): fulltax = taxonomy_finder.from_id(str(taxid)) fwrite.write(line.strip()+'\t'+ organism+'\t' + function+'\t'+ecnum+'\t'+fulltax+'\n')
#!/usr/bin/python #this script find full taxonomy from file of tax ID #usage: python id_to_tax.py id_file.txt > full_tax.txt import sys import taxonomy_finder for line in open(sys.argv[1], 'r'): print line.strip() + "\t" + taxonomy_finder.from_id(line.strip())