Mercurial > repos > qfab > rdp_multiclassifier
view rdpmulticlassifier/scripts/.svn/text-base/generateOTUtable.py.svn-base @ 0:a73ae72b47aa draft default tip
Uploaded
author | qfab |
---|---|
date | Thu, 29 May 2014 02:27:56 -0400 (2014-05-29) |
parents | |
children |
line wrap: on
line source
# create OTU Table by merging pre otu table with taxonomy assign by # rdpmulticlassifier # Tab-separated fields: # 1=OTU Label, 2=Count, 3=Sequence, 4 and following=Assigned taxonomy by # RDP Multi Classifier import sys, os OTUtable = sys.argv[1] PreOTUtable = sys.argv[2] RdpTaxonomy = sys.argv[3] def merge(output, preotu, tax): writeoutput = open(output, 'w') lookup = {} with open(tax) as f: for x in f: list = x.split('\t') length = len(list) rest ='' for k in range(1, length): item= list[k].replace(' ','') item= item.replace('\n','') rest = rest+ item + '\t' lookup[list[0]] = rest with open(preotu) as f: for x in f: columns = x.split('\t') otu = columns[0].replace(' ','') taxonomy = lookup[otu] line = x.replace('\n','') writeoutput.write(line+taxonomy+'\n') merge(OTUtable, PreOTUtable, RdpTaxonomy)