EPost modules

Query

Inheritance diagram of entrezpy.epost.eposter
class entrezpy.epost.eposter.Eposter(tool, email, apikey=None, apikey_var=None, threads=None, qid=None)

Eposter implements Epost queries to E-Utilities [0]. EPost posts UIDs to the history server. Without passed WebEnv, a new WebEnv and correspndong QueryKey are returned. With a given WebEvn the posted UIDs will be added to this WebEnv and the corresponding QueryKey is returned. All parameters described in [0] are acccepted. [0]: https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.EPost

Inits Eposter instance with given attributes.

Parameters:
  • tool (str) – tool name
  • email (str) – user email
  • apikey (str) – NCBI apikey
  • apikey_var (str) – enviroment variable storing NCBI apikey
  • threads (int) – set threads for multithreading
  • qid (str) – unique query id
inquire(parameter, analyzer=<entrezpy.epost.epost_analyzer.EpostAnalyzer object>)
Implements entrezpy.base.query.inquire() and posts UIDs to Entrez.
Epost is only one request.
Parameters:
Returns:

analyzer or None if request errors have been encountered

Return type:

entrezpy.base.analyzer.EntrezpyAnalyzer instance or None

Parameter

Inheritance diagram of entrezpy.epost.epost_parameter
class entrezpy.epost.epost_parameter.EpostParameter(parameter)

EpostParameter checks query specific parameters and configures a entrezpy.epost.epost_query.EpostQuery instance. Force XML since Epost responds only XML. Epost requests don’t have follow-ups.

Parameters:

parameter (dict) – Eutils Epost parameters

Variables:
  • uids (list) – UIDs to post
  • retmode (str) – fix retmode to XML
  • query_size (int) – size of query, here number of UIDs
  • request_size (int) – size of request, here nuber if UIDs
  • expected_requests (int) – number of expected requests, here 1
check()

Implements entrezpy.base.parameter.EutilsParameter.check() by checking for missing database parameter and UIDs.

dump()

Dump instance variables

Return type:dict
haveDb()

Check for required db parameter

Return type:bool
haveExpectedRequets()

Check fo expected requests. Hints an error if no requests are expected.

Return type:bool
haveQuerykey()

Check for required QueryKey parameter

Return type:bool
haveWebenv()

Check for required WebEnv parameter

Return type:bool
useHistory()

Check if history server should be used.

Return type:bool

Request

Inheritance diagram of entrezpy.epost.epost_request
class entrezpy.epost.epost_request.EpostRequest(eutil, parameter)

EpostRequest implements a single request as part of an Epost query. It stores and prepares the parameters for a single request. See entrezpy.epost.epost_parameter.EpostParameter for parameter description.

Parameters:
get_post_parameter()

Implements entrezpy.base.request.EutilsRequest.get_post_parameter()

dump()

Dump instance attributes

Return type:dict
calc_duration()

Calculates request duration

dump_internals(extend=None)

Dumps internal attributes for request.

Parameters:extend (dict) – extend dump with additional information
get_request_id()
Returns:full request id
Return type:str
prepare_base_qry(extend=None)

Returns instance attributes required for every POST request.

Parameters:extend (dict) – parameters extending basic parameters
Returns:base parameters for POST request
Return type:dict
report_status(processed_requests=None, expected_requests=None)

Reports request status when triggered

set_request_error(error)

Sets request error and HTTP/URL error message

Parameters:error (str) – HTTP/URL error
set_status_fail()

Set status if request failed

set_status_success()

Set status if request succeeded

start_stopwatch()

Starts time to measure request duration.

Analyzer

Inheritance diagram of entrezpy.epost.epost_analyzer
class entrezpy.epost.epost_analyzer.EpostAnalyzer

EpostAnalyzer implements the analysis of EPost responses from E-Utils. Epost puts UIDs onto the History server and returnes the corresponding WebEnv and QueryKey. Epost does only XML as response, therefore a dictionary imitating a JSON input is assembled and passed as result to entrezpy.epost.epost_result.EpostResult

init_result(response, request)

Implements entrezpy.base.analyzer.EutilsAnalyzer.init_result() and inits entrezpy.epost.epost_result.EpostResult.

analyze_result(response, request)

Implements entrezpy.base.analyzer.EutilsAnalyzer.analyze_result(). The response is one WebEnv and QueryKey and the result can be initiated after parsing them.

Parameters:
  • response – EUtils response
  • request – entrezpy request
analyze_error(response, request)

Implements entrezpy.base.analyzer.EutilsAnalyzer.analyze_error().

Parameters:
  • response – EUtils response
  • request – entrezpy request

Result

Inheritance diagram of entrezpy.epost.epost_result
class entrezpy.epost.epost_result.EpostResult(response, request)

EpostResult stores WebEnv and QueryKey from posting UIDs to the History server. Since no limit is imposed on the number of UIDs which can be posted in one query, the size of the result is the size of the request and only one WebEnv and QueryKey are returned.

Parameters:
  • request – entrezpy Epost request instance
  • response (dict) – response
Request type:

entrezpy.epost.epost_request.EpostRequest

Variables:

uids (list) – posted UIDs

dump()

Dumps all instance attributes

Return type:dict
Raises:NotImplementedError – if implementation is missing

Assembles parameters for automated follow-ups. Use the query key from the first request by default.

Parameters:reqnum (int) – request number for which query_key should be returned
Returns:EUtils parameters
Return type:dict
Raises:NotImplementedError – if implementation is missing
size()

Returns result size in the corresponding ResultSize unit

Return type:int
Raises:NotImplementedError – if implementation is missing
isEmpty()

Indicates empty result.

Return type:bool
Raises:NotImplementedError – if implementation is missing