Method: Bio::NCBI::REST#esearch_count

Defined in:
lib/bio/io/ncbirest.rb

#esearch_count(str, hash = {}) ⇒ Object

Arguments

same as esearch method

Returns

array of entry IDs or a number of results



163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/bio/io/ncbirest.rb', line 163

def esearch_count(str, hash = {})
  serv = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi"
  opts = {
    "tool"   => "bioruby",
    "term"   => str,
  }
  opts.update(hash)
  opts.update("rettype" => "count")
  #ncbi_access_wait
  response = Bio::Command.post_form(serv, opts)
  result = response.body
  count = result.scan(/<Count>(.*?)<\/Count>/m).flatten.first.to_i
  return count
end