module Entrez
Constants
- VERSION
Public Class Methods
EFetch(db, params = {})
click to toggle source
E.g. Entrez.EFetch
(‘snp’, id: 123, retmode: :xml)
# File lib/entrez.rb, line 18 def EFetch(db, params = {}) perform '/efetch.fcgi', db, params end
EInfo(db, params = {})
click to toggle source
E.g. Entrez.EInfo
(‘gene’, retmode: :xml)
# File lib/entrez.rb, line 23 def EInfo(db, params = {}) perform '/einfo.fcgi', db, params end
ESearch(db, search_terms = {}, params = {})
click to toggle source
E.g. Entrez.ESearch
(‘genomeprj’, {WORD: ‘hapmap’, SEQS: ‘inprogress’}, retmode: :xml) search_terms can also be string literal.
# File lib/entrez.rb, line 29 def ESearch(db, search_terms = {}, params = {}) params[:term] = search_terms.is_a?(Hash) ? convert_search_term_hash(search_terms) : search_terms response = perform '/esearch.fcgi', db, params response end
ESummary(db, params = {})
click to toggle source
E.g. Entrez.ESummary
(‘snp’, id: 123, retmode: :xml)
# File lib/entrez.rb, line 36 def ESummary(db, params = {}) perform '/esummary.fcgi', db, params end
convert_search_term_hash(hash, operator = 'AND')
click to toggle source
Take a ruby hash and convert it to an ENTREZ search term. E.g. convert_search_term_hash
{WORD: ‘low coverage’, SEQS: ‘inprogress’} #=> ‘low coverage+AND+inprogress’
# File lib/entrez.rb, line 48 def convert_search_term_hash(hash, operator = 'AND') raise UnknownOperator.new(operator) unless ['AND', 'OR'].include?(operator) str = hash.map do |field, value| value = value.join(',') if value.is_a?(Array) "#{value}[#{field}]" end.join("+#{operator}+") if operator == 'OR' str = "(#{str})" end str end
perform(utility_path, db, params = {})
click to toggle source
# File lib/entrez.rb, line 40 def perform(utility_path, db, params = {}) respect_query_limit unless ignore_query_limit? get utility_path, :query => {db: db}.merge(params) end