Untitled

mail@pastecode.io avatar
unknown
python
3 years ago
499 B
3
Indexable
Never
with open('sample.txt') as file:
    dna = ''
    for line in file:
        data = line.strip()
        if data[0] == '>':
            dna = ''
        else:
            dna += data

for k in range(4, 13):
    for i in range(len(dna)-k+1):
        dnak = dna[i:k+i]
        dnakversed = dnak[::-1].replace('A', 't').replace('T',
                                                          'a').replace('C', 'g').replace('G', 'c').upper()
        if dnak == dnakversed:
            print(f'{i+1} {k}')