Merci, Pierre! Your response implies that one cannot avoid calling efetch 300,000 times? I'm a bit scared NCBI will think I'm running a denial-of-service attack!!
Also, is it possible to get eutils output in .txt rather than xml?
I want to download all EST sequences from Genbank that are in the Order Hymenoptera.
This is easy by pointing and clicking: http://www.ncbi.nlm.nih.gov/sites/entrez?term=Hymenoptera&cmd=Search&db=nucest
However, I cannot get the efetch/eutils syntax right to do this in the commandline.
Note that contrarily to the following question, I do not know the identifiers for these ESTs: How To Retrive The Dna Sequence From A List Of Embl And Geneid
Thanks!
yannick
try db=nucest, retmax=300000 and term=Hymenoptera[Organism]
and then call efetch with the list of ID, e.g:
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=281381068&rettype=fasta
Merci, Pierre! Your response implies that one cannot avoid calling efetch 300,000 times? I'm a bit scared NCBI will think I'm running a denial-of-service attack!!
Also, is it possible to get eutils output in .txt rather than xml?
no, you can also use the parameter 'usehistory' in esearch (http://eutils.ncbi.nlm.nih.gov/entrez/query/static/esearch_help.html#History), this will give your a 'WebEnv' that you'll later use with one and only efetch query
or you can put more than one id with the same parameter 'id':
curl 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nuccore&id=281381068<,281381069,281381067&rettype=fasta'
excellent, thanks!
And bioruby provides a great wrapper. http://bioruby.org/rdoc/classes/Bio/NCBI/REST.html
You can start with TaxonomyBrowser:
thanks - but I was looking for "non-clicking" approach to this (see Pierre's answer)
Following up on Pierre's answer & my comment, here's how to do it in ruby, using NCBI's eutils.
#!/sw/bin/ruby
require 'bio'
ncbi = Bio::NCBI::REST.new
Bio::NCBI.default_email = "your@email.address"
sequenceIDs = ncbi.esearch("Hymenoptera[organism]",
{ "db"=>"protein", "rettype"=>"gb", "retmax"=> 10000000})
sequences = ncbi.efetch(ids = sequenceIDs,
{"db"=>"protein", "rettype"=>"fasta", "retmax"=> 10000000})
# ncbi returns a single big string with records separated by two newlines
sequences.gsub!("\n\n", "\n")
File.open('genbankHymenopteranProts.fasta', 'w') {|f| f.write(sequences +"\n") }
Error:
/usr/lib/ruby/gems/1.8/gems/bio-1.4.3.0001/lib/bio/io/ncbirest.rb:151:in `ncbi_check_parameters': Set email parameter for the query, or set Bio::NCBI.default_email = "(your email address)" (RuntimeError)
from /usr/lib/ruby/gems/1.8/gems/bio-1.4.3.0001/lib/bio/io/ncbirest.rb:128:in `ncbi_post_form'
from /usr/lib/ruby/gems/1.8/gems/bio-1.4.3.0001/lib/bio/io/ncbirest.rb:268:in `esearch'
from /usr/lib/ruby/gems/1.8/gems/bio-1.4.3.0001/lib/bio/io/ncbirest.rb:265:in `step'
from /usr/lib/ruby/gems/1.8/gems/bio-1.4.3.0001/lib/bio/io/ncbirest.rb:265:in `esearch'
from eftech.ry:7
Indeed you need to supply your email (I didn't want to put my own; added a blank one above):
Bio::NCBI.default_email = "your email"
Log in to answer this question.