Commit bb4170df by Celine Mercier

in obitaxonomy, fixed a typo, and a problem when adding taxa from a file with an associated path

parent 9893dba6
......@@ -76,7 +76,7 @@ Several types of editing are possible:
from obitools.options.taxonomyfilter import addTaxonomyDBOptions,loadTaxonomyDatabase
from obitools.options import getOptionManager
from obitools.ecopcr.taxonomy import ecoTaxonomyWriter
from obitools.fasta import fastaIterator, formatFasta
from obitools.fasta import fastaIterator
import sys
......@@ -133,7 +133,7 @@ def editTaxonomyOptions(optionManager):
metavar="<file name>",
default=None,
help="Add all the species from a fasta file to the taxonomy. The header of"
" the sequences must contain the field defined by the -S option")
" the sequences must contain the field defined by the -k option")
optionManager.add_option('-k','--key_name',
action="store", dest="key_name",
......@@ -267,27 +267,24 @@ if __name__ == '__main__':
ancestors = [t]
for a in ancestors :
try:
previous = options.taxonomy.findTaxonByName(a)
taxid = previous[0]
except KeyError :
if (
options.taxonomy._ranks[previous[1]] == 'genus'
or (a == ancestors[-1]
and len(a.split(' ')) >= 2
and ((not numberInStr(a))
or 'sp' in a.split(' ')
or t[0].isupper()))
) : #super sale ca
rank = 'species'
possible_previous = options.taxonomy.findTaxonByName(a)
keyError = True
for p in possible_previous :
if options.taxonomy.isAncestor(restricting_ancestor, p[0]) :
previous = p
keyError = False
if keyError :
raise KeyError()
elif (len(ancestors) > 1 and a == ancestors[-2] and len(ancestors[-1].split(' ')) >= 2 \
and ((not numberInStr(a)) or 'sp' in a.split(' '))) : #a voirrrrr, trop restrictif ?
rank = 'genus'
else :
rank = 'no rank'
taxid = addTaxonFromFile(a,rank,previous[0],options)
previous = (taxid, options.taxonomy.findRankByName(rank))
except KeyError :
if (len(ancestors) > 1 and a == ancestors[-2] and len(ancestors[-1].split(' ')) >= 2 and ((not numberInStr(a)) or 'sp' in a.split(' '))) : #a voirrrrr, trop restrictif ?
rank = 'genus'
elif a == ancestors[-1] :
rank = 'species'
else :
rank = 'no rank'
taxid = addTaxonFromFile(a,rank,previous[0],options)
previous = (taxid, options.taxonomy.findRankByName(rank))
else :
......
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