Rafe 2019. 3. 3. 21:34

주어진 dna sequence에서 intron을 제거하고 exon만 남겨서 protein sequence를 구하는 문제이다.


단순하게 dna sequence에서 intron만 제거후 transcript하면 끝이다.


from util.read import read_fasta
from util.func_tools import DNA_CODON_TABLE
from functools import reduce
from textwrap import wrap

fasta = read_fasta('rosalind_splc.txt')

dna_seq = list(map(lambda x: x[1], fasta))
exon = reduce(lambda a,b: a[0:a.find(b)]+a[a.find(b)+len(b):], dna_seq)
print(''.join(map(lambda codon: DNA_CODON_TABLE[codon], wrap(exon, 3))))


reduce(lambda a,b: a[0:a.find(b)]+a[a.find(b)+len(b):], dna_seq)

이 코드가 핵심으로 주어진 fasta파일에서 첫번째가 타겟 sequence이고 그 뒤로는 그 sequence에 포함된 intron들이라는 점을 이용해 reduce함수로 제거한다.