May-22-2021, 09:39 AM
(May-22-2021, 07:35 AM)Gribouillis Wrote: You would get a better structured code with a function to handle each line
def is_vcf_line(line): columns = line.split('\t') return bool( re.match(r"^chr(?:[1-9][0-9]?|[XYM])$", columns[0]) and re.match(r"^[1-9][0-9]*$", columns[1]) and re.match(r"^[ATGC]$", columns[3]) and re.match(r"^[ATGC]$", columns[4])) def is_vcf(filename): with open(filename) as lines: return all(is_vcf_line(line) for line in lines)
..gotcha, but still when I run the tests I get false even thou I should get true
BTW, maybe I didnt mentioned it but but the second column need to be int as well, does the code check that as well?