[Biopython-dev] [Bug 2475] BioSQL.Loader should reuse existing taxon entries in lineage

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Sat Apr 5 12:33:09 UTC 2008


http://bugzilla.open-bio.org/show_bug.cgi?id=2475





------- Comment #15 from ericgibert at yahoo.fr  2008-04-05 08:33 EST -------
Created an attachment (id=895)
 --> (http://bugzilla.open-bio.org/attachment.cgi?id=895&action=view)
Parser for Taxonomic Data from NCBI for Bio.Entrez

All right, following Michiel email, I wrote this third version, based on the
existing parser in Bio.Entrez CVS. Integration with Bio.Entrez.__init__.py is
straight forward:

class DataHandler(ContentHandler):
    from Bio.Entrez import EInfo, ESearch, ESummary, EPost, ETaxonomy   # eric
gibert
    _NameToModule = {"eInfoResult": EInfo,
                     "eSearchResult": ESearch,
                     "eSummaryResult": ESummary,
                     "ePostResult": EPost,
                     "TaxaSet": ETaxonomy,    # eric gibert
                    }


That's it.

A Unit test script will be like:

import Bio.Entrez

def print_record(taxrec):
    print taxrec["Rank"], taxrec["ScientificName"], "has the TaxId ",
taxrec["TaxId"], "and its parent is", taxrec["ParentTaxId"]
    print taxrec["OtherNames"]
    print taxrec["Division"], "with Genetic Code:", taxrec["GeneticCode"], "and
Mitochondrial Genetic Code:", taxrec["MitoGeneticCode"]
    print taxrec["Lineage"]
    print taxrec["LineageEx"]
    print "Record Created on %s, updated on %s and published on %s."
%(taxrec["CreateDate"],taxrec["UpdateDate"],taxrec["PubDate"])

# simple test: get the dog...
handle = Bio.Entrez.efetch(db = "taxonomy", id = 9615, retmode = "XML")
taxonomic_record = Bio.Entrez.read(handle)
print_record(taxonomic_record)


# get multiple answers
search_handle = Bio.Entrez.esearch(db = "taxonomy", term = "orthetrum c*",
retmode = "XML")
IdList = Bio.Entrez.read(search_handle)["IdList"]

for id in IdList:
    handle = Bio.Entrez.efetch(db = "taxonomy", id = id, retmode = "XML")
    orthetrum = Bio.Entrez.read(handle)
    print_record(orthetrum)


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list