SampleId = GetSampleId(uc.QueryLabel) if SampleId not in SampleIds: SampleIds.append(SampleId) N = fasta.GetSizeFromLabel(uc.QueryLabel, 1) try: OTUTable[OTUId][SampleId] += N except: OTUTable[OTUId][SampleId] = N OTUIds = [] SampleIds = [] OTUTable = {} uc.ReadRecs(FileName, OnRec) s = "OTUId" for SampleId in SampleIds: s += "\t" + SampleId print s for OTUId in OTUIds: s = OTUId for SampleId in SampleIds: try: n = OTUTable[OTUId][SampleId] except: n = 0 s += "\t" + str(n) print s
SampleId = GetSampleId(uc.QueryLabel) if SampleId not in SampleIds: SampleIds.append(SampleId) N = fasta.GetSizeFromLabel(uc.QueryLabel, 1) try: OTUTable[OTUId][SampleId] += N except: OTUTable[OTUId][SampleId] = N OTUIds = [] SampleIds = [] OTUTable = {} uc.ReadRecs(ucFileName, OnRec) fout = open(outFileName, 'wb') s = "OTUId" for SampleId in SampleIds: s += "\t" + SampleId #print s fout.write("%s\n" % s) for OTUId in OTUIds: s = OTUId for SampleId in SampleIds: try: n = OTUTable[OTUId][SampleId] except: