Browse files

Removing the deprecated online bits of Bio.GenBank (replaced by Bio.E…

…ntrez)
  • Loading branch information...
1 parent ff19d79 commit 4f7d50c6697a01af533c51778e646001f2478bef Peter Cock committed Mar 4, 2010
Showing with 3 additions and 169 deletions.
  1. +1 −167 Bio/GenBank/__init__.py
  2. +2 −2 DEPRECATED
View
168 Bio/GenBank/__init__.py
@@ -24,24 +24,13 @@
ErrorFeatureParser Catch errors caused during parsing.
FeatureParser Parse GenBank data in SeqRecord and SeqFeature objects.
RecordParser Parse GenBank data into a Record object.
-NCBIDictionary Access GenBank using a dictionary interface (DEPRECATED).
-
-_BaseGenBankConsumer A base class for GenBank consumer that implements
- some helpful functions that are in common between
- consumers.
-_FeatureConsumer Create SeqFeature objects from info generated by
- the Scanner
-_RecordConsumer Create a GenBank record object from Scanner info.
-_PrintingConsumer A debugging consumer.
+Exceptions:
ParserFailureError Exception indicating a failure in the parser (ie.
scanner or consumer)
LocationParserError Exception indiciating a problem with the spark based
location parser.
-Functions:
-search_for Do a query against GenBank (DEPRECATED).
-download_many Download many GenBank records (DEPRECATED).
17-MAR-2009: added wgs, wgs_scafld for GenBank whole genome shotgun master records.
These are GenBank files that summarize the content of a project, and provide lists of
@@ -1308,158 +1297,3 @@ def record_end(self, content):
self._add_feature()
-class NCBIDictionary:
- """Access GenBank using a read-only dictionary interface (DEPRECATED).
-
- This object is deprecated and will be removed in a future release of
- Biopython. Please use Bio.Entrez instead as described in the tutorial.
- """
- VALID_DATABASES = ['nucleotide', 'protein', 'genome']
- VALID_FORMATS = ['genbank', 'fasta']
- def __init__(self, database, format, parser = None):
- """Initialize an NCBI dictionary to retrieve sequences.
-
- Create a new Dictionary to access GenBank. Valid values for
- database are 'nucleotide' and 'protein'.
- Valid values for format are 'genbank' (for nucleotide genbank and
- protein genpept) and 'fasta'.
- dely and retmax are old options kept only for compatibility -- do not
- bother to set them.
- parser is an optional parser object
- to change the results into another form. If unspecified, then
- the raw contents of the file will be returned.
- """
- import warnings
- warnings.warn("Bio.GenBank.NCBIDictionary has been deprecated, and will be"\
- " removed in a future release of Biopython. Please use"\
- " Bio.Entrez instead which is described in the tutorial.",
- DeprecationWarning)
-
- self.parser = parser
- if database not in self.__class__.VALID_DATABASES:
- raise ValueError("Invalid database %s, should be one of %s" %
- (database, self.__class__.VALID_DATABASES))
- if format not in self.__class__.VALID_FORMATS:
- raise ValueError("Invalid format %s, should be one of %s" %
- (format, self.__class__.VALID_FORMATS))
-
- if format=="genbank": format = "gb"
- self.db = database
- self.format = format
-
- def __len__(self):
- raise NotImplementedError("GenBank contains lots of entries")
- def clear(self):
- raise NotImplementedError("This is a read-only dictionary")
- def __setitem__(self, key, item):
- raise NotImplementedError("This is a read-only dictionary")
- def update(self):
- raise NotImplementedError("This is a read-only dictionary")
- def copy(self):
- raise NotImplementedError("You don't need to do this...")
- def keys(self):
- raise NotImplementedError("You don't really want to do this...")
- def items(self):
- raise NotImplementedError("You don't really want to do this...")
- def values(self):
- raise NotImplementedError("You don't really want to do this...")
-
- def has_key(self, id):
- """S.has_key(id) -> bool"""
- try:
- self[id]
- except KeyError:
- return 0
- return 1
-
- def get(self, id, failobj=None):
- try:
- return self[id]
- except KeyError:
- return failobj
-
- def __getitem__(self, id):
- """Return the GenBank entry specified by the GenBank ID.
-
- Raises a KeyError if there's an error.
- """
- handle = Entrez.efetch(db = self.db, id = id, rettype = self.format)
- # Parse the record if a parser was passed in.
- if self.parser is not None:
- return self.parser.parse(handle)
- return handle.read()
-
-def search_for(search, database='nucleotide',
- reldate=None, mindate=None, maxdate=None,
- start_id = 0, max_ids = 50000000):
- """Do an online search at the NCBI, returns a list of IDs (DEPRECATED).
-
- This function is deprecated and will be removed in a future release of
- Biopython. Please use Bio.Entrez instead as described in the tutorial.
-
- Search GenBank and return a list of the GenBank identifiers (gi's)
- that match the criteria. search is the search string used to
- search the database. Valid values for database are
- 'nucleotide', 'protein', 'popset' and 'genome'. reldate is
- the number of dates prior to the current date to restrict the
- search. mindate and maxdate are the dates to restrict the search,
- e.g. 2002/12/20. start_id is the number to begin retrieval on.
- max_ids specifies the maximum number of id's to retrieve.
- """
- import warnings
- warnings.warn("Bio.GenBank.search_for has been deprecated, and will be"\
- " removed in a future release of Biopython. Please use"\
- " Bio.Entrez instead which is described in the tutorial.",
- DeprecationWarning)
-
- # mindate and maxdate are NCBI parameters in "YYYY/MM/DD" format
- # (and both should be supplied or neither)
- # relate is an NCBI parameter for "within N days"
-
- #Following date checking from Bio/EUtils/Datatypes.py,
- import re
- _date_re_match = re.compile(r"\d{4}(/\d\d(/\d\d)?)?$").match
- errinfo = None
- if mindate is not None and _date_re_match(mindate) is None:
- errinfo = ("mindate", mindate)
- elif maxdate is not None and _date_re_match(maxdate) is None:
- errinfo = ("maxdate", maxdate)
- if errinfo:
- raise TypeError(
- "%s is not in YYYY/MM/DD format (month and "
- "day are optional): %r" % errinfo)
-
- #Bio.Entrez can now ignore None arguments automatically
- handle = Entrez.esearch(database, search, retmode="xml",
- retstart=start_id, retmax=max_ids,
- mindate=mindate, maxdate=maxdate,
- reldate=reldate)
- return Entrez.read(handle)["IdList"]
-
-def download_many(ids, database = 'nucleotide'):
- """Download multiple NCBI GenBank records, returned as a handle (DEPRECATED).
-
- This function is deprecated and will be removed in a future release of
- Biopython. Please use Bio.Entrez instead as described in the tutorial.
-
- Download many records from GenBank. ids is a list of gis or
- accessions.
- """
- import warnings
- warnings.warn("Bio.GenBank.download_many has been deprecated, and will be"\
- " removed in a future release of Biopython. Please use"\
- " Bio.Entrez instead which is described in the tutorial.",
- DeprecationWarning)
-
- if database in ['nucleotide']:
- format = 'gb'
- elif database in ['protein']:
- format = 'gp'
- else:
- raise ValueError("Unexpected database: %s" % database)
- #TODO - Batch the queries?
- result_handle = Entrez.efetch(database,
- id=",".join(ids),
- retmode = "text",
- rettype = format)
- return cStringIO.StringIO(result_handle.read())
View
4 DEPRECATED
@@ -178,8 +178,8 @@ for the output of MetaTool 3.5 which is now obsolete.
Bio.GenBank
===========
The online functionality (search_for, download_many, and NCBIDictionary) was
-declared obsolete in Release 1.48, and deprecated in Release 1.50.
-Please use Bio.Entrez instead.
+declared obsolete in Release 1.48, deprecated in Release 1.50, and removed
+in Release 1.54. Please use Bio.Entrez instead.
Bio.PubMed
==========

0 comments on commit 4f7d50c

Please sign in to comment.