import os
from collections import OrderedDict
os.chdir('G:/R/Genome/hsa')
sequence = OrderedDict()
with open ("gene.fa", 'r') as f:
for line in f:
line = line.strip()
line = line.upper()
if line.startswith('>'):
idd = line.split(' ')[0][1:]
print(idd)
sequence[idd]=''
else:
sequence[idd]+=line
position = '2:6'
find_chr = position.split(':')[0]
find_pos = position.split(':')[1]
for idd, value in sequence.items():
if find_chr == idd:
print(idd,value[int(find_pos)-1])
网友评论