Map your values to int
when creating the named tuple instances:
row = Base(r[0], *map(int, r[1:]))
This keeps the r[0]
value as a string, and maps the remaining values to int()
.
This does require knowledge of the CSV columns as which ones can be converted to integer is hardcoded here.
Demo:
>>> from collections import namedtuple
>>> Base = namedtuple('Base', ['Locus', 'Total_Depth', 'Average_Depth_sample', 'Depth_for_17'])
>>> r = ['chr1:6484996', '1030', '1030', '1030']
>>> Base(r[0], *map(int, r[1:]))
Base(Locus='chr1:6484996', Total_Depth=1030, Average_Depth_sample=1030, Depth_for_17=1030)
Note that you should test against the rows, not the Base
class:
if row.Total_Depth >= 15:
within the loop, or in a new loop of collected rows.