[Biopython] Retrieve RefSeq sequence
Brad Chapman
chapmanb at 50mail.com
Tue Jan 25 12:27:48 UTC 2011
Chris;
> I'm just wondering if there's a possibility to retrieve a protein
> sequence from NCBI's RefSeq just by giving its identifier, e.g. like
> NP_031402.3 (.3 being the version). Could this be done by the
> Bio.Entrez library? If so, how would I do this?
Definitely. The tutorial has details about doing this and much more:
http://www.biopython.org/DIST/docs/tutorial/Tutorial.html
Chapter 8 describes the Entrez interface to NCBI in detail. For your
specific question, you can do this in two steps by searching for the
GI number with the identifier using esearch, then retrieving the
sequence with efetch:
In [1]: from Bio import Entrez
In [2]: Entrez.email = "you at email.com"
In [3]: rec = Entrez.read(Entrez.esearch(db="protein", term="NP_031402.3"))
In [4]: print rec["IdList"]
['110347469']
In [5]: p_handle = Entrez.efetch(db="protein", id=rec["IdList"][0], rettype="fasta")
In [6]: print p_handle.read()
>gi|110347468|ref|NP_031402.3| alpha-2-macroglobulin precursor [Mus musculus]
MRRNQLPTPAFLLLFLLLPRDATTATAKPQYVVLVPSEVYSGVPEKACVSLNHVNETVMLSLTLEYAMQQ
TKLLTDQAVDKDSFYCSPFTISGSPLPYTFITVEIKGPTQRFIKKKSIQIIKAESPVFVQTDKPIYKPGQ
IVKFRVVSVDISFRPLNETFPVVYIETPKRNRIFQWQNIHLAGGLHQLSFPLSVEPALGIYKVVVQKDSG
KKIEHSFEVKEYVLPKFEVIIKMQKTMAFLEEELPITACGVYTYGKPVPGLVTLRVCRKYSRYRSTCHNQ
NSMSICEEFSQQADDKGCFRQVVKTKVFQLRQKGHDMKIEVEAKIKEEGTGIELTGIGSCEIANALSKLK
FTKVNTNYRPGLPFSGQVLLVDEKGKPIPNKNITSVVSPLGYLSIFTTDEHGLANISIDTSNFTAPFLRV
VVTYKQNHVCYDNWWLDEFHTQADHSATLVFSPSQSYIQLELVFGTLACGQTQEIRIHYLLNEDIMKNEK
DLTFYYLIKARGSIFNLGSHVLSLEQGNMKGVFSLPIQVEPGMAPEAQLLIYAILPNEELVADAQNFEIE
KCFANKVNLSFPSAQSLPASDTHLKVKAAPLSLCALTAVDQSVLLLKPEAKLSPQSIYNLLPGKTVQGAF
FGVPVYKDHENCISGEDITHNGIVYTPKHSLGDNDAHSIFQSVGINIFTNSKIHKPRFCQEFQHYPAMGG
VAPQALAVAASGPGSSFRAMGVPMMGLDYSDEINQVVEVRETVRKYFPETWIWDLVPLDVSGDGELAVKV
PDTITEWKASAFCLSGTTGLGLSSTISLQAFQPFFLELTLPYSVVRGEAFTLKATVLNYMSHCIQIRVDL
EISPDFLAVPVGGHENSHCICGNERKTVSWAVTPKSLGEVNFTATAEALQSPELCGNKLTEVPALVHKDT
VVKSVIVEPEGIEKEQTYNTLLCPQDTELQDNWSLELPPNVVEGSARATHSVLGDILGSAMQNLQNLLQM
PYGCGEQNMVLFVPNIYVLNYLNETQQLTEAIKSKAINYLISGYQRQLNYQHSDGSYSTFGNHGGGNTPG
NTWLTAFVLKAFAQAQSHIFIEKTHITNAFNWLSMKQKENGCFQQSGYLLNNAMKGGVDDEVTLSAYITI
ALLEMPLPVTHSAVRNALFCLETAWASISQSQESHVYTKALLAYAFALAGNKAKRSELLESLNKDAVKEE
DSLHWQRPGDVQKVKALSFYQPRAPSAEVEMTAYVLLAYLTSESSRPTRDLSSSDLSTASKIVKWISKQQ
NSHGGFSSTQDTVVALQALSKYGAATFTRSQKEVLVTIESSGTFSKTFHVNSGNRLLLQEVRLPDLPGNY
VTKGSGSGCVYLQTSLKYNILPVADGKAPFALQVNTLPLNFDKAGDHRTFQIRINVSYTGERPSSNMVIV
DVKMVSGFIPMKPSVKKLQDQPNIQRTEVNTNHVLIYIEKLTNQTLGFSFAVEQDIPVKNLKPAPIKVYD
YYETDEFTVEEYSAPFSDGSEQGNA
Hope this helps,
Brad
More information about the Biopython
mailing list