Commit 0b044510 by Celine Mercier

added a bad iterator/parser for a specific file (for Pierre)

parent c0834dac
......@@ -93,6 +93,20 @@ def SILVAIterator(f, tax):
yield s
def PierreFileIterator(f) :
fastaEntryIterator = genericEntryIteratorGenerator(startEntry='>')
for entry in fastaEntryIterator(f) :
all = entry.split('\n')
header = all[0]
fields = header.split('|')
id = fields[0][1:]
seq = all[1]
s = NucSequence(id, seq)
s['species_name'] = fields[-1].replace('+',' ')
print>>sys.stderr, s['species_name']
yield s
def lookForSimilarSpeciesNameInGenus(species_name, species_list):
genus_species = species_name.split(' ')
......@@ -275,6 +289,7 @@ def addTaxonomyOptions(optionManager):
"specified ancestor. If it's a word, it's the field containing the ancestor's taxid "
"in each sequence's header (can be different for each sequence). If it's a number, "
"it's the taxid of the ancestor (in which case it's the same for all the sequences)")
# optionManager.add_option('-L','--species_list',
# action='store_true', dest="species_list",
......@@ -298,20 +313,23 @@ if __name__=='__main__':
tax=loadTaxonomyDatabase(options)
if options.db_type == 'raw' :
entryIterator=fastaIterator
entryIterator = fastaIterator
entries = entryIterator(entries)
elif options.db_type == 'UNITE' :
entryIterator=UNITEIterator
entryIterator = UNITEIterator
entries = entryIterator(entries)
elif options.db_type == 'SILVA' :
entryIterator=SILVAIterator
entryIterator = SILVAIterator
entries = entryIterator(entries, tax)
options.tagname = 'species_name'
elif options.db_type == 'Pierre' :
entryIterator = PierreFileIterator
entries = entryIterator(entries)
#entries = entryIterator(entries)
openFiles(options)
if (options.db_type == 'raw') or (options.db_type == 'SILVA') :
if (options.db_type == 'raw') or (options.db_type == 'SILVA') or (options.db_type == 'Pierre') :
if options.res_anc == '' :
restricting_ancestor = None
......
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