73 lines
1.9 KiB
Python
73 lines
1.9 KiB
Python
#!/usr/local/bin/python
|
|
'''
|
|
Created on 24 nov. 2011
|
|
|
|
@author: merciece
|
|
'''
|
|
|
|
import sys
|
|
|
|
|
|
def main(amplifiedSeqs, seqsFromDB, keptRanks, tax) :
|
|
|
|
BcValues = {}
|
|
|
|
#speciesid = tax.findRankByName('species')
|
|
#subspeciesid = tax.findRankByName('subspecies')
|
|
|
|
listtaxonbygroup = {}
|
|
|
|
for seq in seqsFromDB :
|
|
taxid = seq['taxid']
|
|
p = [a for a in tax.parentalTreeIterator(taxid)]
|
|
for a in p :
|
|
if a != p[0] :
|
|
if a[1] in keptRanks :
|
|
group = a
|
|
if group in listtaxonbygroup:
|
|
listtaxonbygroup[group].add(taxid)
|
|
else:
|
|
listtaxonbygroup[group]=set([taxid])
|
|
|
|
#stats = dict((x,len(listtaxonbygroup[x])) for x in listtaxonbygroup)
|
|
|
|
print>>sys.stderr, listtaxonbygroup
|
|
|
|
listtaxonbygroup = {}
|
|
|
|
for seq in amplifiedSeqs :
|
|
taxid = seq['taxid']
|
|
p = [a for a in tax.parentalTreeIterator(taxid)]
|
|
for a in p :
|
|
if a != p[0] :
|
|
if a[1] in keptRanks :
|
|
group = a
|
|
if group in listtaxonbygroup:
|
|
listtaxonbygroup[group].add(taxid)
|
|
else:
|
|
listtaxonbygroup[group]=set([taxid])
|
|
|
|
print>>sys.stderr, listtaxonbygroup
|
|
|
|
return BcValues
|
|
|
|
# dbstats= dict((x,len(listtaxonbygroup[x])) for x in listtaxonbygroup)
|
|
#
|
|
# ranks = [r for r in keptRanks]
|
|
# ranks.sort()
|
|
#
|
|
# print '%-20s\t%10s\t%10s\t%7s' % ('rank','ecopcr','db','percent')
|
|
#
|
|
# print>>sys.stderr, stats
|
|
# print>>sys.stderr, dbstats
|
|
# print>>sys.stderr, ranks
|
|
#
|
|
# for r in ranks:
|
|
# if r in dbstats and dbstats[r]:
|
|
# print '%-20s\t%10d\t%10d\t%8.2f' % (r,dbstats[r],stats[r],float(dbstats[r])/stats[r]*100)
|
|
|
|
|
|
|
|
|
|
|