Commit 0e2c4861 by Eric Coissac

Merge branch 'master' of git@git.metabarcoding.org:obitools/obitools.git

parents 42a3f984 950bae88
......@@ -246,9 +246,20 @@ if __name__ == '__main__':
restricting_ancestor = 1
t = seq[options.key_name]
# try :
# taxid = options.taxonomy.findTaxonByName(t)[0]
# except KeyError :
key_error = False
taxid = None
# check if the taxon isn't already in the taxonomy with the right ancestor
try :
possible_taxids = options.taxonomy.findTaxonByName(t)
for p in possible_taxids :
if options.taxonomy.isAncestor(restricting_ancestor, p[0]) :
taxid = p[0]
except KeyError :
key_error = True
if key_error or taxid is None :
if (resAncInHeader and options.res_anc in seq) :
taxid = addTaxonFromFile(t,'species',restricting_ancestor,options)
......@@ -290,14 +301,23 @@ if __name__ == '__main__':
if (len(t.split(' ')) >= 2 and (not numberInStr(t) or 'sp' in t.split(' ') or t[0].isupper()) \
and t.split(' ')[0] not in useless_words) :
genus,species = t.split(" ",1)
try :
options.taxonomy.findTaxonByName(genus)
possible_genuses = options.taxonomy.findTaxonByName(genus)
genus_taxid = None
for g in possible_genuses :
if options.taxonomy.isAncestor(restricting_ancestor, g[0]) :
genus_taxid = g[0]
except KeyError :
taxid = addTaxonFromFile(genus,'genus',restricting_ancestor,options)
genus_taxid = addTaxonFromFile(genus,'genus',restricting_ancestor,options)
parent = options.taxonomy.findTaxonByName(genus)
taxid = addTaxonFromFile(t, 'species', parent[0], options)
if genus_taxid is None : # Genuses matching the name were found but they weren't under the restricting ancestor
parent = restricting_ancestor
else :
parent = genus_taxid
taxid = addTaxonFromFile(t, 'species', parent, options)
else :
taxid = addTaxonFromFile(t, 'species', restricting_ancestor, options)
......
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