I am trying to parse a file with a limited knowledge in python with some loops but seems I'm doing something wrong. I want to get the genes(sp...)
if values in lst
are between the numbers in the middle. Here's the file (ast.txt
):
SPAC212.11 1 5662 -1
SPAC212.10 5726 6331 -1
SPAC212.09c 7619 9274 1
SPNCRNA.70 11027 11556 -1
SPAC212.08c 11784 12994 1
SPAC212.07c 13665 14555 1
SPAC212.12 15855 16226 1
SPAC212.06c 18042 18306 1
and here's my code:
lst=[2,6000,18042,11784]
f=open('asd.txt','r')
g=f.readlines()[0:]
for line in g:
for s in lst:
if (s)>=int(line.split()[1:2]) and (s)<=int(line.split()[2:3]):
line.split()[0:1]