count: added option to specify the count column
This commit is contained in:
@ -29,6 +29,12 @@ def addOptions(parser):
|
|||||||
default=False,
|
default=False,
|
||||||
help="Prints only the total count of sequence records (if a sequence has no `count` attribute, its default count is 1) (default: False).")
|
help="Prints only the total count of sequence records (if a sequence has no `count` attribute, its default count is 1) (default: False).")
|
||||||
|
|
||||||
|
group.add_argument('-c','--count-tag',
|
||||||
|
action="store", dest="count:countcol",
|
||||||
|
default='COUNT',
|
||||||
|
type=str,
|
||||||
|
help="Name of the tag/column associated with the count information (default: COUNT).")
|
||||||
|
|
||||||
|
|
||||||
def run(config):
|
def run(config):
|
||||||
|
|
||||||
@ -42,17 +48,19 @@ def run(config):
|
|||||||
raise Exception("Could not read input")
|
raise Exception("Could not read input")
|
||||||
entries = input[1]
|
entries = input[1]
|
||||||
|
|
||||||
|
countcol = config['count']['countcol']
|
||||||
|
|
||||||
count1 = len(entries)
|
count1 = len(entries)
|
||||||
count2 = 0
|
count2 = 0
|
||||||
|
|
||||||
if COUNT_COLUMN in entries and ((config['count']['sequence'] == config['count']['all']) or (config['count']['all'])) :
|
if countcol in entries and ((config['count']['sequence'] == config['count']['all']) or (config['count']['all'])) :
|
||||||
for e in entries:
|
for e in entries:
|
||||||
PyErr_CheckSignals()
|
PyErr_CheckSignals()
|
||||||
count2+=e[COUNT_COLUMN]
|
count2+=e[countcol]
|
||||||
|
|
||||||
if COUNT_COLUMN in entries and (config['count']['sequence'] == config['count']['all']):
|
if countcol in entries and (config['count']['sequence'] == config['count']['all']):
|
||||||
print(count1,count2)
|
print(count1,count2)
|
||||||
elif COUNT_COLUMN in entries and config['count']['all']:
|
elif countcol in entries and config['count']['all']:
|
||||||
print(count2)
|
print(count2)
|
||||||
else:
|
else:
|
||||||
print(count1)
|
print(count1)
|
||||||
|
Reference in New Issue
Block a user