Finding a Protein Motif(단백질 모티프 찾기)
https://rosalind.info/problems/mprt/
ROSALIND | Finding a Protein Motif
It appears that your browser has JavaScript disabled. Rosalind requires your browser to be JavaScript enabled. Finding a Protein Motif solved by 6295 2012년 12월 4일 7:02:27 오전 by Rosalind Team Topics: File Formats, Proteomics Motif Implies Function
rosalind.info
Problem
To allow for the presence of its varying forms, a protein motif is represented by a shorthand as follows: [XY] means "either X or Y" and {X} means "any amino acid except X." For example, the N-glycosylation motif is written as N{P}[ST]{P}.
You can see the complete description and features of a particular protein by its access ID "uniprot_id" in the UniProt database, by inserting the ID number into
http://www.uniprot.org/uniprot/uniprot_id
Alternatively, you can obtain a protein sequence in FASTA format by following
http://www.uniprot.org/uniprot/uniprot_id.fasta
For example, the data for protein B5ZC00 can be found at http://www.uniprot.org/uniprot/B5ZC00.
Given: At most 15 UniProt Protein Database access IDs.
Return: For each protein possessing the N-glycosylation motif, output its given access ID followed by a list of locations in the protein string where the motif can be found.
Sample Dataset
A2Z669
B5ZC00
P07204_TRBM_HUMAN
P20840_SAG1_YEAST
Sample Output
B5ZC00
85 118 142 306 395
P07204_TRBM_HUMAN
47 115 116 382 409
P20840_SAG1_YEAST
79 109 135 248 306 348 364 402 485 501 614
이 문제는 uniprot 아이디들이 주어지고 이 아이디들을 이용해 uniprot사이트에서 서열을 찾아 N-glycosylation 모티프가 있는지? 있다면 어느 위치에 있는지를 찾아야한다.
이 문제를 풀기 위한 알고리즘은 크게 ID와 서열을 찾는 부분, 모티프가 있는지 찾는 부분으로 나눌 수 있다.
ID와 서열을 찾는 부분은 Biopython의 내장모듈인 ExPassy와 SeqIO를 이용해서 구할 수 있다. 그리고 모티프를 찾는 부분은 if문들을 잘 세워서 구할 수 있다.
이렇게만 하면 수월하게 풀릴 것 같다만 몇몇 uniprot ID의 경우 없어지거나 달라지는 경우가 생겨버려 결국은 풀지 못한 문제이다.
from Bio import ExPASy
from Bio import SeqIO
with open(r"파일경로",'r') as file:
lines=file.readlines()
for id in lines:
id=id.rstrip()
handle = ExPASy.get_sprot_raw(id)
seq = SeqIO.read(handle,'swiss').seq
idxs=[]
for idx in range(len(seq)-3):
if seq[idx]=='N':
if seq[idx+1]!='P' and seq[idx+3]!='P':
if seq[idx+2]=='S' or seq[idx+2]=='T':
idxs.append(idx+1)
if idxs:
print(id)
print(*idxs)