add annotation about rank during rank filtering
This commit is contained in:
@ -62,14 +62,23 @@ def taxonomyFilterGenerator(options):
|
||||
loadTaxonomyDatabase(options)
|
||||
if options.taxonomy is not None:
|
||||
taxonomy=options.taxonomy
|
||||
def taxonomyFilter(seq):
|
||||
def taxonomyFilter(seq,rank):
|
||||
def annotateAtRank(seq):
|
||||
if 'taxid' in seq:
|
||||
taxid = seq['taxid']
|
||||
rtaxid= taxonomy.getTaxonAtRank(taxid,rank)
|
||||
if rtaxid is not None:
|
||||
seq["%s_taxid" % rank]=rtaxid
|
||||
seq[rank]=taxonomy.getScientificName(rtaxid)
|
||||
return rtaxid
|
||||
return None
|
||||
good = True
|
||||
if 'taxid' in seq:
|
||||
taxid = seq['taxid']
|
||||
# print taxid,
|
||||
if options.requiredRank:
|
||||
taxonatrank = reduce(lambda x,y: x and y,
|
||||
(taxonomy.getTaxonAtRank(taxid,rank) is not None
|
||||
(annotateAtRank(seq,rank) is not None
|
||||
for rank in options.requiredRank),True)
|
||||
good = good and taxonatrank
|
||||
# print >>sys.stderr, " Has rank : ",good,
|
||||
|
Reference in New Issue
Block a user