[Biopython-dev] Setting the NCBI Entrez tool parameter globally
Peter
biopython at maubp.freeserve.co.uk
Mon Mar 29 07:05:25 EDT 2010
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