INNER CODE UNIT · Python
sniff_whitelist
timoast/sinto · sinto/addbarcodes.py:58
def sniff_whitelist(filename, nr=100):
# possibly the dumbest function ever written
nl = 0 # number of lines sniffed
nc = 0 # max number of corrected bc found
nf = 0 # max number of fields
with open(filename) as fh:
while nl < nr:
line = fh.readline()
nl += 1
l = len(line.split())
if l > nf:
nf = l
if l > 1:
l = len(line.split()[1].split(','))
if l > nc:
nc = l
if nf > 2 and nc > 1:
# assuming a UMI-tools whitelist contains at least