[Biopython-dev] Setting the NCBI Entrez tool parameter globally
Michiel de Hoon
mjldehoon at yahoo.com
Mon Mar 29 13:54:01 UTC 2010
Basically I think that this patch is OK, but why do tool and email need to be global inside the _open function?
--Michiel
--- On Mon, 3/29/10, Peter <biopython at maubp.freeserve.co.uk> wrote:
> From: Peter <biopython at maubp.freeserve.co.uk>
> Subject: Setting the NCBI Entrez tool parameter globally
> To: "Michiel de Hoon" <mjldehoon at yahoo.com>, "Biopython-Dev Mailing List" <biopython-dev at biopython.org>
> Date: Monday, March 29, 2010, 7:05 AM
> Hi Michiel et al,
>
> The NCBI looks to be encouraging more use of the email and
> tool
> parameters in their revised guidelines. To make this easy
> to use
> we have a global setting for the email - I think we should
> do the
> same for the tool (for when users are building their own
> application
> or script on top of Biopython). Something like this patch?
>
> What do you think?
>
> Peter
>
> ------------------------
>
> diff --git a/Bio/Entrez/__init__.py
> b/Bio/Entrez/__init__.py
> index 33d8d14..f64015c 100644
> --- a/Bio/Entrez/__init__.py
> +++ b/Bio/Entrez/__init__.py
> @@ -12,6 +12,9 @@ http://www.ncbi.nlm.nih.gov/Entrez/
> A list of the Entrez utilities is available at:
> http://www.ncbi.nlm.nih.gov/entrez/utils/utils_index.html
>
> +Variables:
> +email Set the Entrez email
> parameter globally (default is not set).
> +tool Set the Entrez
> tool parameter globally (defaults to biopython).
>
> Functions:
> efetch Retrieves records in
> the requested format from a list of one or
> @@ -50,7 +53,7 @@ from Bio import File
>
>
> email = None
> -
> +tool = "biopython"
>
> # XXX retmode?
> def epost(db, **keywds):
> @@ -275,6 +278,7 @@ def _open(cgi, params={}, post=False):
> This function also enforces the
> "up to three queries per second rule"
> to avoid abusing the NCBI
> servers.
> """
> + global tool, email
> # NCBI requirement: At most three
> queries per second.
> # Equivalently, at least a third
> of second between queries
> delay = 0.333333334
> @@ -291,7 +295,7 @@ def _open(cgi, params={}, post=False):
> del
> params[key]
> # Tell Entrez that we are using
> Biopython
> if not "tool" in params:
> - params["tool"] = "biopython"
> + params["tool"] = tool
> # Tell Entrez who we are
> if not "email" in params:
> if email!=None:
>
More information about the Biopython-dev
mailing list