Commit 0e2f8598 by Eric Coissac

Patch bug in the -E option of ecotag and add the -M option to limit the

action of the -E option 
parent 23717f58
#!/usr/local/bin/python
#!/usr/local/OBITools-1.1.22/bin/python
'''
:py:mod:`ecotag`: assigns sequences to taxa
===========================================
......@@ -145,9 +145,16 @@ def addSearchOptions(optionManager):
optionManager.add_option('-E','--errors',
action='store',dest='error',
type='float',
default=0.0,
help='Tolerated rate of wrong assignation')
optionManager.add_option('-M','--min-matches',
action='store',dest='minmatches',
type="int",
default=1,
help='Minimum congruent assignation')
optionManager.add_option('--cache-size',
action='store',dest='cache',
type='int',
......@@ -333,10 +340,10 @@ if __name__=='__main__':
rankid = taxonomy.findRankByName(options.explain)
for seq in db:
id = seq.id[0:46]
seq.id=id
assert id not in taxonlink
taxonlink[id]=int(seq['taxid'])
seqid = seq.id[0:46]
seq.id=seqid
assert seqid not in taxonlink
taxonlink[seqid]=int(seq['taxid'])
if options.uniq:
......@@ -363,7 +370,12 @@ if __name__=='__main__':
if best[0]:
taxlist = set(taxonlink[p[0].id] for p in match)
lca = taxonomy.betterCommonTaxon(options.error,*tuple(taxlist))
if options.error > 0.0 and len(match) >= options.minmatches:
lca = taxonomy.betterCommonTaxon(options.error,
*tuple(taxlist))
else:
lca = taxonomy.betterCommonTaxon(0.0,*tuple(taxlist))
scname = taxonomy.getScientificName(lca)
rank = taxonomy.getRank(lca)
if len(taxlist) < 15:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment