Class: Eutils
- Inherits:
-
Object
- Object
- Eutils
- Defined in:
- lib/eutils.rb
Overview
eutils.einfo
Constant Summary collapse
- EUTILS_HOST =
Global constants
-
EUTILS_INTERVAL
"http://eutils.ncbi.nlm.nih.gov/entrez/eutils/"
- EUTILS_INTERVAL =
1.0 / 3.0
- @@last_access =
nil
- @@last_access_mutex =
nil
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#tool ⇒ Object
Returns the value of attribute tool.
Instance Method Summary collapse
-
#efetch(db, webenv, query_key = 1, params = {}) ⇒ Object
EFetch: Retrieves records in the requested format from a list of one or more primary IDs or from the user’s environment.
-
#egquery(term) ⇒ Object
EGQuery: Provides Entrez database counts in XML for a single search using Global Query.
-
#einfo(db = nil) ⇒ Object
EInfo: Provides field index term counts, last update, and available links for each database.
-
#elink ⇒ Object
ELink: Checks for the existence of an external or Related Articles link from a list of one or more primary IDs.
-
#epost(ids, db = "pubmed", params = {}) ⇒ Object
EPost: Posts a file containing a list of primary IDs for future use in the user’s environment to use with subsequent search strategies.
-
#esearch(term, db = "pubmed", params = {}) ⇒ Object
ESearch: Searches and retrieves primary IDs (for use in EFetch, ELink, and ESummary) and term translations and optionally retains results for future use in the user’s environment.
-
#espell(term) ⇒ Object
ESpell: Retrieves spelling suggestions.
-
#esummary(ids, db = "pubmed", params = {}) ⇒ Object
ESummary: Retrieves document summaries from a list of primary IDs or from the user’s environment.
-
#initialize(tool = nil, email = nil) ⇒ Eutils
constructor
A new instance of Eutils.
Constructor Details
#initialize(tool = nil, email = nil) ⇒ Eutils
Returns a new instance of Eutils.
19 20 21 |
# File 'lib/eutils.rb', line 19 def initialize(tool = nil, email = nil) @tool, @email = tool, email end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
16 17 18 |
# File 'lib/eutils.rb', line 16 def email @email end |
#tool ⇒ Object
Returns the value of attribute tool.
16 17 18 |
# File 'lib/eutils.rb', line 16 def tool @tool end |
Instance Method Details
#efetch(db, webenv, query_key = 1, params = {}) ⇒ Object
EFetch: Retrieves records in the requested format from a list of one or more primary IDs or from the user’s environment. See also: eutils.ncbi.nlm.nih.gov/corehtml/query/static/efetch_help.html
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/eutils.rb', line 76 def efetch(db, webenv, query_key = 1, params = {}) params["db"] = db params["WebEnv"] = webenv params["query_key"] = query_key params["retmode"] ||= "xml" params["retstart"] ||= 0 params["retmax"] ||= 10 server = EUTILS_HOST + "efetch.fcgi" response = post_eutils(server, params) if params["retmode"] == "xml" return Hash.from_xml(response) else return response end end |
#egquery(term) ⇒ Object
EGQuery: Provides Entrez database counts in XML for a single search using Global Query. See also: eutils.ncbi.nlm.nih.gov/corehtml/query/static/egquery_help.html
100 101 102 103 104 105 106 |
# File 'lib/eutils.rb', line 100 def egquery(term) term.strip! if term.class == String server = EUTILS_HOST + "egquery.fcgi" params = {"term" => term} response = post_eutils(server, params) return Hash.from_xml(response)["Result"] end |
#einfo(db = nil) ⇒ Object
EInfo: Provides field index term counts, last update, and available links for each database. See also: eutils.ncbi.nlm.nih.gov/corehtml/query/static/einfo_help.html
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eutils.rb', line 25 def einfo(db = nil) db.strip! if db.class == String server = EUTILS_HOST + "einfo.fcgi" params = {"db" => db} response = post_eutils(server, params) if db.nil? || db.empty? return response.scan(/<DbName>(\w+)<\/DbName>/).flatten else return Hash.from_xml(response)["eInfoResult"] end end |
#elink ⇒ Object
ELink: Checks for the existence of an external or Related Articles link from a list of one or more primary IDs. Retrieves primary IDs and relevancy scores for links to Entrez databases or Related Articles; creates a hyperlink to the primary LinkOut provider for a specific ID and database, or lists LinkOut URLs and Attributes for multiple IDs. See also: eutils.ncbi.nlm.nih.gov/corehtml/query/static/elink_help.html
94 95 96 |
# File 'lib/eutils.rb', line 94 def elink end |
#epost(ids, db = "pubmed", params = {}) ⇒ Object
EPost: Posts a file containing a list of primary IDs for future use in the user’s environment to use with subsequent search strategies. See also: eutils.ncbi.nlm.nih.gov/corehtml/query/static/epost_help.html returns: webenv, querykey. Both nil for invalid epost.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/eutils.rb', line 53 def epost(ids, db = "pubmed", params = {}) params["id"] = ids.join(",") params["db"] = db server = EUTILS_HOST + "epost.fcgi" response = post_eutils(server, params) querykey = response.scan(/<QueryKey>(\d+)<\/QueryKey>/).flatten.first.to_i querykey = nil if querykey == 0 webenv = response.scan(/<WebEnv>(\S+)<\/WebEnv>/).flatten.first return webenv, querykey end |
#esearch(term, db = "pubmed", params = {}) ⇒ Object
ESearch: Searches and retrieves primary IDs (for use in EFetch, ELink, and ESummary) and term translations and optionally retains results for future use in the user’s environment. See also: eutils.ncbi.nlm.nih.gov/corehtml/query/static/esearch_help.html eutils.esearch(“autism”)
40 41 42 43 44 45 46 47 48 |
# File 'lib/eutils.rb', line 40 def esearch(term, db = "pubmed", params = {}) term.strip! if term.class == String params["term"] = term params["db"] = db params["usehistory"] ||= "y" server = EUTILS_HOST + "esearch.fcgi" response = post_eutils(server, params) return Hash.from_xml(response)["eSearchResult"] end |
#espell(term) ⇒ Object
ESpell: Retrieves spelling suggestions. See also: eutils.ncbi.nlm.nih.gov/corehtml/query/static/espell_help.html
110 111 112 113 114 115 116 117 118 |
# File 'lib/eutils.rb', line 110 def espell(term) term.strip! if term.class == String server = EUTILS_HOST + "espell.fcgi" params = {"db" => "pubmed", "term" => term} response = post_eutils(server, params) corrected = response.scan(/<CorrectedQuery>(.+)<\/CorrectedQuery>/).flatten.first.to_s corrected = term if corrected.empty? return corrected end |
#esummary(ids, db = "pubmed", params = {}) ⇒ Object
ESummary: Retrieves document summaries from a list of primary IDs or from the user’s environment. See also: eutils.ncbi.nlm.nih.gov/corehtml/query/static/esummary_help.html
66 67 68 69 70 71 72 |
# File 'lib/eutils.rb', line 66 def esummary(ids, db = "pubmed", params = {}) params["id"] = ids.join(",") params["db"] = db server = EUTILS_HOST + "esummary.fcgi" response = post_eutils(server, params) return Hash.from_xml(response)["eSummaryResult"] end |