Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(40)  |  Call(40)  |  Derive(0)  |  Import(0)
Parses an XML file from the NCBI Entrez Utilities into python objects.

This function parses an XML file created by NCBI's Entrez Utilities,
returning a multilevel data structure of Python lists and dictionaries.
Most XML files returned by NCBI's Entrez Utilities can be parsed by
this function, provided its DTD is available. Biopython includes the
DTDs for most commonly used Entrez Utilities.

If validate is True (default), the parser will validate the XML file
against the DTD, and raise an error if the XML file contains tags that(more...)

        def read(handle, validate=True):
    """Parses an XML file from the NCBI Entrez Utilities into python objects.

    This function parses an XML file created by NCBI's Entrez Utilities,
    returning a multilevel data structure of Python lists and dictionaries.
    Most XML files returned by NCBI's Entrez Utilities can be parsed by
    this function, provided its DTD is available. Biopython includes the
    DTDs for most commonly used Entrez Utilities.

    If validate is True (default), the parser will validate the XML file
    against the DTD, and raise an error if the XML file contains tags that
    are not represented in the DTD. If validate is False, the parser will
    simply skip such tags.

    Whereas the data structure seems to consist of generic Python lists,
    dictionaries, strings, and so on, each of these is actually a class
    derived from the base type. This allows us to store the attributes
    (if any) of each element in a dictionary my_element.attributes, and
    the tag name in my_element.tag.
    """
    from .Parser import DataHandler
    handler = DataHandler(validate)
    record = handler.read(handle)
    return record
        


src/b/i/Bio_Eutils-1.63/Tests/test_Entrez.py   Bio_Eutils(Download)
        # >>> Bio_Eutils.Entrez.einfo()
        handle = open('Entrez/einfo1.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record["DbList"], ['pubmed',
        # >>> Bio_Eutils.Entrez.einfo(db="pubmed")
        handle = open('Entrez/einfo2.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record["DbInfo"]['DbName'], 'pubmed')
        # included some tags that are not part of the corresponding DTD.
        handle = open('Entrez/einfo3.xml', "rb")
        record = Entrez.read(handle, validate=False)
        handle.close()
        self.assertEqual(record["DbInfo"]['DbName'], 'pubmed')
        # >>> Bio_Eutils.Entrez.esearch(db="pubmed", term="biopython")
        handle = open('Entrez/esearch1.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], '5')
        #                        datetype="edat", retmax=100, usehistory="y")
        handle = open('Entrez/esearch2.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], "10238")