Add a rank option allowing to add a rank attribute to sequences containing an integer value indicating the position of the sequence in the input file.
This commit is contained in:
@ -18,10 +18,16 @@ from obitools.format._format import printOutput
|
|||||||
|
|
||||||
from array import array
|
from array import array
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def addInputFormatOption(optionManager):
|
def addInputFormatOption(optionManager):
|
||||||
|
optionManager.add_option('--rank',
|
||||||
|
action="store_true", dest='addrank',
|
||||||
|
default=False,
|
||||||
|
help="add a rank attribute to the sequence "
|
||||||
|
"indicating the sequence position in the input data")
|
||||||
optionManager.add_option('--genbank',
|
optionManager.add_option('--genbank',
|
||||||
action="store_const", dest="seqinformat",
|
action="store_const", dest="seqinformat",
|
||||||
default=None,
|
default=None,
|
||||||
@ -127,6 +133,15 @@ def autoEntriesIterator(options):
|
|||||||
|
|
||||||
return iterator
|
return iterator
|
||||||
|
|
||||||
|
def withRankIterator(formatIterator):
|
||||||
|
def iterator(lineiterator):
|
||||||
|
rank=0
|
||||||
|
for s in formatIterator(lineiterator):
|
||||||
|
rank+=1
|
||||||
|
s['rank']=rank
|
||||||
|
yield s
|
||||||
|
|
||||||
|
return iterator
|
||||||
def withQualIterator(qualityfile):
|
def withQualIterator(qualityfile):
|
||||||
options.outputFormater=formatFastq
|
options.outputFormater=formatFastq
|
||||||
options.outputFormat="fastq"
|
options.outputFormat="fastq"
|
||||||
@ -206,7 +221,9 @@ def autoEntriesIterator(options):
|
|||||||
reader=withQualIterator(qualfile)
|
reader=withQualIterator(qualfile)
|
||||||
options.outputFormater=formatFastq
|
options.outputFormater=formatFastq
|
||||||
options.outputFormat="fastq"
|
options.outputFormat="fastq"
|
||||||
|
|
||||||
|
if options.addrank:
|
||||||
|
reader = withRankIterator(reader)
|
||||||
return reader
|
return reader
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user