Bioinformatics/Rosalind
Locating Restriction Sites
Rafe
2019. 3. 4. 22:58
Resctiction enzyme은 유전자 재조합에 핵심적인 기술중 하나이다. restriction enzyme을 이용할 수 있는 restriction site를 찾는 문제이다.
문제에선 길이가 4-12인 restriction site들을 찾으라고 되어있다. restriction site는 upstream과 downstream이 일정 지점을 경계로 대칭으로 놓여있어야 하므로 결국 길이는 2n이어야 한다. 그러므로 4, 6, 8, 10, 12가 된다.
from util.read import read_fasta
data = read_fasta('rosalind_revp.txt')[0][1]
def get_complement(seq):
return ''.join(map(lambda base: 'T' if base=='A' else 'A' if base=='T' else 'C' if base=='G' else 'G', seq))
for length in range(4,13,2):
for idx in range(len(data)-length+1):
upstream = data[idx:idx+length]
if get_complement(upstream)[::-1] == upstream:
print(idx+1, length)