Method: Bio::NCBI::REST#efetch
- Defined in:
- lib/bio/io/ncbirest.rb
#efetch(ids, hash = {}, step = 100) ⇒ Object
Retrieve database entries by given IDs and using E-Utils (efetch) service.
For information on the possible arguments, see
Usage
ncbi = Bio::NCBI::REST.new
ncbi.efetch("185041", {"db"=>"nucleotide", "rettype"=>"gb", "retmode" => "xml"})
ncbi.efetch("J00231", {"db"=>"nuccore", "rettype"=>"gb", "retmode"=>"xml"})
ncbi.efetch("AAA52805", {"db"=>"protein", "rettype"=>"gb"})
Bio::NCBI::REST.efetch("185041", {"db"=>"nucleotide", "rettype"=>"gb", "retmode" => "xml"})
Bio::NCBI::REST.efetch("J00231", {"db"=>"nuccore", "rettype"=>"gb"})
Bio::NCBI::REST.efetch("AAA52805", {"db"=>"protein", "rettype"=>"gb"})
Arguments:
-
ids: list of NCBI entry IDs (required)
-
hash: hash of E-Utils option => “nuccore”, “rettype” => “gb”
-
db: “sequences”, “nucleotide”, “protein”, “pubmed”, “omim”, …
-
retmode: “text”, “xml”, “html”, …
-
rettype: “gb”, “gbc”, “medline”, “count”,…
-
-
step: maximum number of entries retrieved at a time
- Returns
-
String
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/bio/io/ncbirest.rb', line 205 def efetch(ids, hash = {}, step = 100) serv = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi" opts = { "tool" => "bioruby", "retmode" => "text", } opts.update(hash) case ids when Array list = ids else list = ids.to_s.split(/\s*,\s*/) end result = "" 0.step(list.size, step) do |i| opts["id"] = list[i, step].join(',') unless opts["id"].empty? ncbi_access_wait response = Bio::Command.post_form(serv, opts) result += response.body end end return result.strip #return result.strip.split(/\n\n+/) end |