Commit ee53992a by Eric Coissac

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

# Conflicts:
#	requirements.txt
parents 45736d17 1c318bd3
...@@ -47,7 +47,7 @@ if __name__ == '__main__': ...@@ -47,7 +47,7 @@ if __name__ == '__main__':
try: try:
writer(entry) writer(entry)
except: except:
print >>stderr,"Skip writing of sequence : %s" % entry.id print >>stderr,"Skipping an entry"
else: else:
writer(entry) writer(entry)
...@@ -331,7 +331,7 @@ if __name__ == '__main__': ...@@ -331,7 +331,7 @@ if __name__ == '__main__':
for t in options.newspecies: for t in options.newspecies:
genus,species = t.split(" ",1) genus,species = t.split(" ",1)
parent = options.taxonomy.findTaxonByName(genus) parent = options.taxonomy.findTaxonByName(genus)[0]
taxid = options.taxonomy.addLocalTaxon(t,'species',parent[0],options.taxashift) taxid = options.taxonomy.addLocalTaxon(t,'species',parent[0],options.taxashift)
taxon = options.taxonomy.findTaxonByTaxid(taxid) taxon = options.taxonomy.findTaxonByTaxid(taxid)
parent= options.taxonomy._taxonomy[taxon[2]] parent= options.taxonomy._taxonomy[taxon[2]]
...@@ -347,4 +347,4 @@ if __name__ == '__main__': ...@@ -347,4 +347,4 @@ if __name__ == '__main__':
ecoTaxonomyWriter(options.ecodb,options.taxonomy,onlyLocal=True) ecoTaxonomyWriter(options.ecodb,options.taxonomy,onlyLocal=True)
\ No newline at end of file
...@@ -14,7 +14,6 @@ def skipOnErrorIterator(seqIterator): ...@@ -14,7 +14,6 @@ def skipOnErrorIterator(seqIterator):
seq = si.next() seq = si.next()
yield seq yield seq
except Exception,e: except Exception,e:
print >>sys.stderr,"coucou"
if isinstance(e,StopIteration): if isinstance(e,StopIteration):
raise e raise e
else: else:
......
...@@ -29,20 +29,24 @@ def __emblparser(text): ...@@ -29,20 +29,24 @@ def __emblparser(text):
acs = acs.split() acs = acs.split()
ac = acs[0] ac = acs[0]
acs = acs[1:] acs = acs[1:]
de = _deMatcher.search(header).group() de = _deMatcher.search(header).group()
de = _cleanDe.sub(' ',de).strip().strip('.') de = _cleanDe.sub(' ',de).strip().strip('.')
except AttributeError,e: except Exception as e:
print >>sys.stderr,'=======================================================' print>>sys.stderr, "\nCould not import sequence id:", text.split()[1], "(error raised:", e, ")"
print >>sys.stderr,text # Do not raise any Exception if you need the possibility to resume the generator
print >>sys.stderr,'=======================================================' # (Python generators can't resume after any exception is raised)
raise e return None
return (ac,seq,de,header,ft,acs) return (ac,seq,de,header,ft,acs)
def emblParser(text): def emblParser(text):
return embl.EmblSequence(*__emblparser(text)) parsed_text = __emblparser(text)
if parsed_text is not None:
return embl.EmblSequence(*parsed_text)
else:
return None
def emblIterator(file): def emblIterator(file):
......
...@@ -25,16 +25,21 @@ def __gbparser(text): ...@@ -25,16 +25,21 @@ def __gbparser(text):
acs = acs[1:] acs = acs[1:]
de = _deMatcher.search(header).group() de = _deMatcher.search(header).group()
de = _cleanDe.sub(' ',de).strip().strip('.') de = _cleanDe.sub(' ',de).strip().strip('.')
except AttributeError,e: except Exception as e:
print >>sys.stderr,'=======================================================' print>>sys.stderr, "\nCould not import sequence id:", text.split()[1], "(error raised:", e, ")"
print >>sys.stderr,text # Do not raise any Exception if you need the possibility to resume the generator
print >>sys.stderr,'=======================================================' # (Python generators can't resume after any exception is raised)
raise e return None
return (ac,seq,de,header,ft,acs) return (ac,seq,de,header,ft,acs)
def genbankParser(text): def genbankParser(text):
return gb.GbSequence(*__gbparser(text)) parsed_text = __gbparser(text)
if parsed_text is not None:
return gb.GbSequence(*parsed_text)
else:
return None
def genbankIterator(file): def genbankIterator(file):
...@@ -43,7 +48,11 @@ def genbankIterator(file): ...@@ -43,7 +48,11 @@ def genbankIterator(file):
def genpepParser(text): def genpepParser(text):
return gb.GpepSequence(*__gbparser(text)) parsed_text = __gbparser(text)
if parsed_text is not None:
return gb.GpepSequence(*parsed_text)
else:
return None
def genpepIterator(file): def genpepIterator(file):
......
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