i am getting an syntax error after (cat fiile_with_ids.txt); i am getting an syntax error at (;)
HI
I have more than 10,000 protein IDS, I'm interested in extracting all the fasta sequences of these proteins ids from uniprot.
What I did so, far-- Already I downloaded all the fasta sequences of the organism I'm interested in.
How can I do, need suggestions.
3 answers
You can fetch them directly from Uniprot, if you know the uniprot ID the fasta sequence can be retrieved from the URL https://www.uniprot.org/uniprot/{UNIPROT_ID}.fasta
So, if you have a file with the IDs (one per line):
for ID in $(cat file_with_ids.txt); do wget https://www.uniprot.org/uniprot/$ID.fasta; done
i want all the fasta files in one output file
You can upload your list of identifiers to the UniProt batch retrieval tool at https://www.uniprot.org/uploadlists Please don't hesitate to contact the UniProt helpdesk if you have any additional questions.
import urllib.request
my_uniprot_IDs=set(open('my_uniprot_IDs').read().split())
template='https://www.uniprot.org/uniprot/%s.fasta'
outfile_fasta = open('my_uniprot_IDs.fasta', 'w')
outfile_obsolete = open('obsolete', 'w')
outfile_success = open('success', 'w')
for anID in my_uniprot_IDs:
try:
this_url=template%anID
fasta_text=urllib.request.urlopen(this_url).read().decode('utf-8')
outfile_fasta.write(fasta_text)
outfile_success.write(anID+'\n')
except :
urllib.error.HTTPError:
outfile_obsolete.write(anID+'\n')
outfile_fasta.close()
outfile_obsolete.close()
outfile_success.close()
Please post actual code not screenshots of code. You will also want to describe what the code does and how to use it.
Use the 101010 button to format code when in edit mode.
Log in to answer this question.
Use
blast+preformattednrdatabase along withblastdbcmdutility. Use-entry_batchoption to do a large number of accessions.An example for a single accession below.
Moving this to a comment since
nrmay not contain all UniProt ID's and if that is all you have then this would not be sufficient.