Question: Accessing Uniprot Info Via Python
1
gravatar for sonnett.matt
4.6 years ago by
sonnett.matt10
sonnett.matt10 wrote:

Does anyone here regularly access uniprot info using python? If so how?

I tried downloading

https://github.com/boscoh/uniprot through github but was unable to figure out the installation. What does everyone here use?

python uniprot • 4.3k views
ADD COMMENTlink modified 4.6 years ago by Egon Willighagen5.2k • written 4.6 years ago by sonnett.matt10
1

which operating system do you have? On Ubuntu, try sudo apt-get install python-setuptools , and then sudo easy_install uniprot

ADD REPLYlink written 4.6 years ago by Giovanni M Dall'Olio26k

Yes, the instructions assume that you have the pip package installer.

ADD REPLYlink modified 4.6 years ago • written 4.6 years ago by Neilfws48k

I have windows 7 with pip installed. When trying to install I typed 'pip install uniprot'

ADD REPLYlink written 4.6 years ago by sonnett.matt10

The installation through pip or easy_install works fine for me, in Ubuntu. In any case you can probably simply download the uniprot.py script from there, and import it from the same folder.

ADD REPLYlink written 4.6 years ago by Giovanni M Dall'Olio26k
1
gravatar for Egon Willighagen
4.6 years ago by
Maastricht
Egon Willighagen5.2k wrote:

I do not regularly access Uniprot from Python, but just today solved a matching Rosalind task. My solution uses the urllib library to download the data:

import urllib
code = "Q7Z7W5"
data = urllib.urlopen("http://www.uniprot.org/uniprot/" + code + ".txt").read()

And then uses split() to process the file line by line. Each line has some structure and starts with a two character code, like "DR". The content of the lines is reasonably well structured, and, as the Rosalind task requires, allows you to extract GO ontology term annotation.

ADD COMMENTlink written 4.6 years ago by Egon Willighagen5.2k
1

This script will work correctly for an exercise, but if you want to download many entries you should consider adding a time.sleep() condition after the call, in order to not overload the Uniprot server. You should also consider adding your email address to the User-Agent header, as requested in the Uniprot's FAQs (http://www.uniprot.org/faq/28)

ADD REPLYlink written 4.6 years ago by Giovanni M Dall'Olio26k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 988 users visited in the last hour