# Copyright 2008-2010 by Michiel de Hoon.  All rights reserved.
# Revisions copyright 2009-2013 by Peter Cock. All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license.  Please see the LICENSE file that should have been included
# as part of this package.
'''Testing code for Bio.Entrez parsers.
'''

import unittest

import os
if os.name == 'java':
    try:
        from xml.parsers.expat import XML_PARAM_ENTITY_PARSING_ALWAYS
        del XML_PARAM_ENTITY_PARSING_ALWAYS
    except ImportError:
        from Bio import MissingPythonDependencyError
        raise MissingPythonDependencyError("The Bio.Entrez XML parser fails on "
                                  "Jython, see http://bugs.jython.org/issue1447")


from Bio import Entrez


class GeneralTests(unittest.TestCase):
    '''General tests for Bio.Entrez'''
    def test_closed_handle(self):
        '''Test parsing closed handle fails gracefully
        '''
        handle = open('Entrez/einfo1.xml', "rb")
        handle.close()
        self.assertRaises(IOError, Entrez.read, handle)


class EInfoTest(unittest.TestCase):
    '''Tests for parsing XML output returned by EInfo
    '''
    def test_list(self):
        '''Test parsing database list returned by EInfo
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.einfo()
        handle = open('Entrez/einfo1.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record["DbList"], ['pubmed',
                                            'protein',
                                            'nucleotide',
                                            'nuccore',
                                            'nucgss',
                                            'nucest',
                                            'structure',
                                            'genome',
                                            'books',
                                            'cancerchromosomes',
                                            'cdd',
                                            'gap',
                                            'domains',
                                            'gene',
                                            'genomeprj',
                                            'gensat',
                                            'geo',
                                            'gds',
                                            'homologene',
                                            'journals',
                                            'mesh',
                                            'ncbisearch',
                                            'nlmcatalog',
                                            'omia',
                                            'omim',
                                            'pmc',
                                            'popset',
                                            'probe',
                                            'proteinclusters',
                                            'pcassay',
                                            'pccompound',
                                            'pcsubstance',
                                            'snp',
                                            'taxonomy',
                                            'toolkit',
                                            'unigene',
                                            'unists'
                                           ])

    def test_pubmed1(self):
        '''Test parsing database info returned by EInfo
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.einfo(db="pubmed")
        handle = open('Entrez/einfo2.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record["DbInfo"]['DbName'], 'pubmed')
        self.assertEqual(record["DbInfo"]['MenuName'], 'PubMed')
        self.assertEqual(record["DbInfo"]['Description'], 'PubMed bibliographic record')
        self.assertEqual(record["DbInfo"]['Count'], "17905967")
        self.assertEqual(record["DbInfo"]['LastUpdate'], '2008/04/15 06:42')

        self.assertEqual(len(record["DbInfo"]['FieldList']), 40)

        self.assertEqual(record["DbInfo"]['FieldList'][0]['Name'], 'ALL')
        self.assertEqual(record["DbInfo"]['FieldList'][0]['FullName'], 'All Fields')
        self.assertEqual(record["DbInfo"]['FieldList'][0]['Description'], 'All terms from all searchable fields')
        self.assertEqual(record["DbInfo"]['FieldList'][0]['TermCount'], "70792830")
        self.assertEqual(record["DbInfo"]['FieldList'][0]['IsDate'], 'N')
        self.assertEqual(record["DbInfo"]['FieldList'][0]['IsNumerical'], 'N')
        self.assertEqual(record["DbInfo"]['FieldList'][0]['SingleToken'], 'N')
        self.assertEqual(record["DbInfo"]['FieldList'][0]['Hierarchy'], 'N')
        self.assertEqual(record["DbInfo"]['FieldList'][0]['IsHidden'], 'N')

        self.assertEqual(len(record["DbInfo"]['LinkList']), 46)

        self.assertEqual(record["DbInfo"]['LinkList'][0]['Name'], 'pubmed_books_refs')
        self.assertEqual(record["DbInfo"]['LinkList'][0]['Menu'], 'Cited in Books')
        self.assertEqual(record["DbInfo"]['LinkList'][0]['Description'], 'PubMed links associated with Books')
        self.assertEqual(record["DbInfo"]['LinkList'][0]['DbTo'], 'books')

    def test_pubmed2(self):
        '''Test validating the XML against the DTD
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.einfo(db="pubmed")
        # Starting some time in 2010, the results returned by Bio.Entrez
        # included some tags that are not part of the corresponding DTD.
        from Bio.Entrez import Parser
        handle = open('Entrez/einfo3.xml', "rb")
        self.assertRaises(Parser.ValidationError, Entrez.read, handle)
        handle.close()

    def test_pubmed3(self):
        '''Test non-validating parser on XML with an inconsistent DTD
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.einfo(db="pubmed")
        # Starting some time in 2010, the results returned by Bio.Entrez
        # 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')
        self.assertEqual(record["DbInfo"]['MenuName'], 'PubMed')
        self.assertEqual(record["DbInfo"]['Description'], 'PubMed bibliographic record')
        self.assertEqual(record["DbInfo"]['Count'], "20161961")
        self.assertEqual(record["DbInfo"]['LastUpdate'], "2010/09/10 04:52")

        self.assertEqual(len(record["DbInfo"]['FieldList']), 45)
        self.assertEqual(record["DbInfo"]["FieldList"][0]["Name"], "ALL")
        self.assertEqual(record["DbInfo"]["FieldList"][0]["FullName"], "All Fields")
        self.assertEqual(record["DbInfo"]["FieldList"][0]["Description"], "All terms from all searchable fields")
        self.assertEqual(record["DbInfo"]["FieldList"][0]["TermCount"], "89981460")
        self.assertEqual(record["DbInfo"]["FieldList"][0]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][0]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][0]["SingleToken"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][0]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][0]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][1]["Name"], "UID")
        self.assertEqual(record["DbInfo"]["FieldList"][1]["FullName"], "UID")
        self.assertEqual(record["DbInfo"]["FieldList"][1]["Description"], "Unique number assigned to publication")
        self.assertEqual(record["DbInfo"]["FieldList"][1]["TermCount"], "0")
        self.assertEqual(record["DbInfo"]["FieldList"][1]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][1]["IsNumerical"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][1]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][1]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][1]["IsHidden"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][2]["Name"], "FILT")
        self.assertEqual(record["DbInfo"]["FieldList"][2]["FullName"], "Filter")
        self.assertEqual(record["DbInfo"]["FieldList"][2]["Description"], "Limits the records")
        self.assertEqual(record["DbInfo"]["FieldList"][2]["TermCount"], "4070")
        self.assertEqual(record["DbInfo"]["FieldList"][2]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][2]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][2]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][2]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][2]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][3]["Name"], "TITL")
        self.assertEqual(record["DbInfo"]["FieldList"][3]["FullName"], "Title")
        self.assertEqual(record["DbInfo"]["FieldList"][3]["Description"], "Words in title of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][3]["TermCount"], "12475481")
        self.assertEqual(record["DbInfo"]["FieldList"][3]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][3]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][3]["SingleToken"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][3]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][3]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][4]["Name"], "WORD")
        self.assertEqual(record["DbInfo"]["FieldList"][4]["FullName"], "Text Word")
        self.assertEqual(record["DbInfo"]["FieldList"][4]["Description"], "Free text associated with publication")
        self.assertEqual(record["DbInfo"]["FieldList"][4]["TermCount"], "39413498")
        self.assertEqual(record["DbInfo"]["FieldList"][4]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][4]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][4]["SingleToken"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][4]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][4]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][5]["Name"], "MESH")
        self.assertEqual(record["DbInfo"]["FieldList"][5]["FullName"], "MeSH Terms")
        self.assertEqual(record["DbInfo"]["FieldList"][5]["Description"], "Medical Subject Headings assigned to publication")
        self.assertEqual(record["DbInfo"]["FieldList"][5]["TermCount"], "554666")
        self.assertEqual(record["DbInfo"]["FieldList"][5]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][5]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][5]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][5]["Hierarchy"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][5]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][6]["Name"], "MAJR")
        self.assertEqual(record["DbInfo"]["FieldList"][6]["FullName"], "MeSH Major Topic")
        self.assertEqual(record["DbInfo"]["FieldList"][6]["Description"], "MeSH terms of major importance to publication")
        self.assertEqual(record["DbInfo"]["FieldList"][6]["TermCount"], "493091")
        self.assertEqual(record["DbInfo"]["FieldList"][6]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][6]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][6]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][6]["Hierarchy"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][6]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][7]["Name"], "AUTH")
        self.assertEqual(record["DbInfo"]["FieldList"][7]["FullName"], "Author")
        self.assertEqual(record["DbInfo"]["FieldList"][7]["Description"], "Author(s) of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][7]["TermCount"], "11268262")
        self.assertEqual(record["DbInfo"]["FieldList"][7]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][7]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][7]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][7]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][7]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][8]["Name"], "JOUR")
        self.assertEqual(record["DbInfo"]["FieldList"][8]["FullName"], "Journal")
        self.assertEqual(record["DbInfo"]["FieldList"][8]["Description"], "Journal abbreviation of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][8]["TermCount"], "118354")
        self.assertEqual(record["DbInfo"]["FieldList"][8]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][8]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][8]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][8]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][8]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][9]["Name"], "AFFL")
        self.assertEqual(record["DbInfo"]["FieldList"][9]["FullName"], "Affiliation")
        self.assertEqual(record["DbInfo"]["FieldList"][9]["Description"], "Author's institutional affiliation and address")
        self.assertEqual(record["DbInfo"]["FieldList"][9]["TermCount"], "17538809")
        self.assertEqual(record["DbInfo"]["FieldList"][9]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][9]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][9]["SingleToken"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][9]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][9]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][10]["Name"], "ECNO")
        self.assertEqual(record["DbInfo"]["FieldList"][10]["FullName"], "EC/RN Number")
        self.assertEqual(record["DbInfo"]["FieldList"][10]["Description"], "EC number for enzyme or CAS registry number")
        self.assertEqual(record["DbInfo"]["FieldList"][10]["TermCount"], "82892")
        self.assertEqual(record["DbInfo"]["FieldList"][10]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][10]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][10]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][10]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][10]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][11]["Name"], "SUBS")
        self.assertEqual(record["DbInfo"]["FieldList"][11]["FullName"], "Substance Name")
        self.assertEqual(record["DbInfo"]["FieldList"][11]["Description"], "CAS chemical name or MEDLINE Substance Name")
        self.assertEqual(record["DbInfo"]["FieldList"][11]["TermCount"], "204197")
        self.assertEqual(record["DbInfo"]["FieldList"][11]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][11]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][11]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][11]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][11]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][12]["Name"], "PDAT")
        self.assertEqual(record["DbInfo"]["FieldList"][12]["FullName"], "Publication Date")
        self.assertEqual(record["DbInfo"]["FieldList"][12]["Description"], "Date of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][12]["TermCount"], "35200")
        self.assertEqual(record["DbInfo"]["FieldList"][12]["IsDate"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][12]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][12]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][12]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][12]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][13]["Name"], "EDAT")
        self.assertEqual(record["DbInfo"]["FieldList"][13]["FullName"], "Entrez Date")
        self.assertEqual(record["DbInfo"]["FieldList"][13]["Description"], "Date publication first accessible through Entrez")
        self.assertEqual(record["DbInfo"]["FieldList"][13]["TermCount"], "33978")
        self.assertEqual(record["DbInfo"]["FieldList"][13]["IsDate"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][13]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][13]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][13]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][13]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][14]["Name"], "VOL")
        self.assertEqual(record["DbInfo"]["FieldList"][14]["FullName"], "Volume")
        self.assertEqual(record["DbInfo"]["FieldList"][14]["Description"], "Volume number of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][14]["TermCount"], "12026")
        self.assertEqual(record["DbInfo"]["FieldList"][14]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][14]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][14]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][14]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][14]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][15]["Name"], "PAGE")
        self.assertEqual(record["DbInfo"]["FieldList"][15]["FullName"], "Pagination")
        self.assertEqual(record["DbInfo"]["FieldList"][15]["Description"], "Page number(s) of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][15]["TermCount"], "1274867")
        self.assertEqual(record["DbInfo"]["FieldList"][15]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][15]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][15]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][15]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][15]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][16]["Name"], "PTYP")
        self.assertEqual(record["DbInfo"]["FieldList"][16]["FullName"], "Publication Type")
        self.assertEqual(record["DbInfo"]["FieldList"][16]["Description"], "Type of publication (e.g., review)")
        self.assertEqual(record["DbInfo"]["FieldList"][16]["TermCount"], "71")
        self.assertEqual(record["DbInfo"]["FieldList"][16]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][16]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][16]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][16]["Hierarchy"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][16]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][17]["Name"], "LANG")
        self.assertEqual(record["DbInfo"]["FieldList"][17]["FullName"], "Language")
        self.assertEqual(record["DbInfo"]["FieldList"][17]["Description"], "Language of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][17]["TermCount"], "57")
        self.assertEqual(record["DbInfo"]["FieldList"][17]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][17]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][17]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][17]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][17]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][18]["Name"], "ISS")
        self.assertEqual(record["DbInfo"]["FieldList"][18]["FullName"], "Issue")
        self.assertEqual(record["DbInfo"]["FieldList"][18]["Description"], "Issue number of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][18]["TermCount"], "16835")
        self.assertEqual(record["DbInfo"]["FieldList"][18]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][18]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][18]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][18]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][18]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][19]["Name"], "SUBH")
        self.assertEqual(record["DbInfo"]["FieldList"][19]["FullName"], "MeSH Subheading")
        self.assertEqual(record["DbInfo"]["FieldList"][19]["Description"], "Additional specificity for MeSH term")
        self.assertEqual(record["DbInfo"]["FieldList"][19]["TermCount"], "83")
        self.assertEqual(record["DbInfo"]["FieldList"][19]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][19]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][19]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][19]["Hierarchy"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][19]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][20]["Name"], "SI")
        self.assertEqual(record["DbInfo"]["FieldList"][20]["FullName"], "Secondary Source ID")
        self.assertEqual(record["DbInfo"]["FieldList"][20]["Description"], "Cross-reference from publication to other databases")
        self.assertEqual(record["DbInfo"]["FieldList"][20]["TermCount"], "3821402")
        self.assertEqual(record["DbInfo"]["FieldList"][20]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][20]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][20]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][20]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][20]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][21]["Name"], "MHDA")
        self.assertEqual(record["DbInfo"]["FieldList"][21]["FullName"], "MeSH Date")
        self.assertEqual(record["DbInfo"]["FieldList"][21]["Description"], "Date publication was indexed with MeSH terms")
        self.assertEqual(record["DbInfo"]["FieldList"][21]["TermCount"], "33923")
        self.assertEqual(record["DbInfo"]["FieldList"][21]["IsDate"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][21]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][21]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][21]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][21]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][22]["Name"], "TIAB")
        self.assertEqual(record["DbInfo"]["FieldList"][22]["FullName"], "Title/Abstract")
        self.assertEqual(record["DbInfo"]["FieldList"][22]["Description"], "Free text associated with Abstract/Title")
        self.assertEqual(record["DbInfo"]["FieldList"][22]["TermCount"], "35092258")
        self.assertEqual(record["DbInfo"]["FieldList"][22]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][22]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][22]["SingleToken"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][22]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][22]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][23]["Name"], "OTRM")
        self.assertEqual(record["DbInfo"]["FieldList"][23]["FullName"], "Other Term")
        self.assertEqual(record["DbInfo"]["FieldList"][23]["Description"], "Other terms associated with publication")
        self.assertEqual(record["DbInfo"]["FieldList"][23]["TermCount"], "333870")
        self.assertEqual(record["DbInfo"]["FieldList"][23]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][23]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][23]["SingleToken"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][23]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][23]["IsHidden"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][24]["Name"], "INVR")
        self.assertEqual(record["DbInfo"]["FieldList"][24]["FullName"], "Investigator")
        self.assertEqual(record["DbInfo"]["FieldList"][24]["Description"], "Investigator")
        self.assertEqual(record["DbInfo"]["FieldList"][24]["TermCount"], "516245")
        self.assertEqual(record["DbInfo"]["FieldList"][24]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][24]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][24]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][24]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][24]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][25]["Name"], "COLN")
        self.assertEqual(record["DbInfo"]["FieldList"][25]["FullName"], "Corporate Author")
        self.assertEqual(record["DbInfo"]["FieldList"][25]["Description"], "Corporate Author of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][25]["TermCount"], "132665")
        self.assertEqual(record["DbInfo"]["FieldList"][25]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][25]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][25]["SingleToken"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][25]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][25]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][26]["Name"], "CNTY")
        self.assertEqual(record["DbInfo"]["FieldList"][26]["FullName"], "Place of Publication")
        self.assertEqual(record["DbInfo"]["FieldList"][26]["Description"], "Country of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][26]["TermCount"], "279")
        self.assertEqual(record["DbInfo"]["FieldList"][26]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][26]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][26]["SingleToken"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][26]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][26]["IsHidden"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][27]["Name"], "PAPX")
        self.assertEqual(record["DbInfo"]["FieldList"][27]["FullName"], "Pharmacological Action")
        self.assertEqual(record["DbInfo"]["FieldList"][27]["Description"], "MeSH pharmacological action pre-explosions")
        self.assertEqual(record["DbInfo"]["FieldList"][27]["TermCount"], "420")
        self.assertEqual(record["DbInfo"]["FieldList"][27]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][27]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][27]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][27]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][27]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][28]["Name"], "GRNT")
        self.assertEqual(record["DbInfo"]["FieldList"][28]["FullName"], "Grant Number")
        self.assertEqual(record["DbInfo"]["FieldList"][28]["Description"], "NIH Grant Numbers")
        self.assertEqual(record["DbInfo"]["FieldList"][28]["TermCount"], "2588283")
        self.assertEqual(record["DbInfo"]["FieldList"][28]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][28]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][28]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][28]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][28]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][29]["Name"], "MDAT")
        self.assertEqual(record["DbInfo"]["FieldList"][29]["FullName"], "Modification Date")
        self.assertEqual(record["DbInfo"]["FieldList"][29]["Description"], "Date of last modification")
        self.assertEqual(record["DbInfo"]["FieldList"][29]["TermCount"], "2777")
        self.assertEqual(record["DbInfo"]["FieldList"][29]["IsDate"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][29]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][29]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][29]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][29]["IsHidden"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][30]["Name"], "CDAT")
        self.assertEqual(record["DbInfo"]["FieldList"][30]["FullName"], "Completion Date")
        self.assertEqual(record["DbInfo"]["FieldList"][30]["Description"], "Date of completion")
        self.assertEqual(record["DbInfo"]["FieldList"][30]["TermCount"], "9268")
        self.assertEqual(record["DbInfo"]["FieldList"][30]["IsDate"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][30]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][30]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][30]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][30]["IsHidden"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][31]["Name"], "PID")
        self.assertEqual(record["DbInfo"]["FieldList"][31]["FullName"], "Publisher ID")
        self.assertEqual(record["DbInfo"]["FieldList"][31]["Description"], "Publisher ID")
        self.assertEqual(record["DbInfo"]["FieldList"][31]["TermCount"], "8894288")
        self.assertEqual(record["DbInfo"]["FieldList"][31]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][31]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][31]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][31]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][31]["IsHidden"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][32]["Name"], "FAUT")
        self.assertEqual(record["DbInfo"]["FieldList"][32]["FullName"], "First Author")
        self.assertEqual(record["DbInfo"]["FieldList"][32]["Description"], "First Author of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][32]["TermCount"], "6068222")
        self.assertEqual(record["DbInfo"]["FieldList"][32]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][32]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][32]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][32]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][32]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][33]["Name"], "FULL")
        self.assertEqual(record["DbInfo"]["FieldList"][33]["FullName"], "Full Author Name")
        self.assertEqual(record["DbInfo"]["FieldList"][33]["Description"], "Full Author Name(s) of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][33]["TermCount"], "6419103")
        self.assertEqual(record["DbInfo"]["FieldList"][33]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][33]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][33]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][33]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][33]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][34]["Name"], "FINV")
        self.assertEqual(record["DbInfo"]["FieldList"][34]["FullName"], "Full Investigator Name")
        self.assertEqual(record["DbInfo"]["FieldList"][34]["Description"], "Full name of investigator")
        self.assertEqual(record["DbInfo"]["FieldList"][34]["TermCount"], "243898")
        self.assertEqual(record["DbInfo"]["FieldList"][34]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][34]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][34]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][34]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][34]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][35]["Name"], "TT")
        self.assertEqual(record["DbInfo"]["FieldList"][35]["FullName"], "Transliterated Title")
        self.assertEqual(record["DbInfo"]["FieldList"][35]["Description"], "Words in transliterated title of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][35]["TermCount"], "2177885")
        self.assertEqual(record["DbInfo"]["FieldList"][35]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][35]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][35]["SingleToken"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][35]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][35]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][36]["Name"], "LAUT")
        self.assertEqual(record["DbInfo"]["FieldList"][36]["FullName"], "Last Author")
        self.assertEqual(record["DbInfo"]["FieldList"][36]["Description"], "Last Author of publication")
        self.assertEqual(record["DbInfo"]["FieldList"][36]["TermCount"], "5655625")
        self.assertEqual(record["DbInfo"]["FieldList"][36]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][36]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][36]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][36]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][36]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][37]["Name"], "PPDT")
        self.assertEqual(record["DbInfo"]["FieldList"][37]["FullName"], "Print Publication Date")
        self.assertEqual(record["DbInfo"]["FieldList"][37]["Description"], "Date of print publication")
        self.assertEqual(record["DbInfo"]["FieldList"][37]["TermCount"], "35164")
        self.assertEqual(record["DbInfo"]["FieldList"][37]["IsDate"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][37]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][37]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][37]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][37]["IsHidden"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][38]["Name"], "EPDT")
        self.assertEqual(record["DbInfo"]["FieldList"][38]["FullName"], "Electronic Publication Date")
        self.assertEqual(record["DbInfo"]["FieldList"][38]["Description"], "Date of Electronic publication")
        self.assertEqual(record["DbInfo"]["FieldList"][38]["TermCount"], "4282")
        self.assertEqual(record["DbInfo"]["FieldList"][38]["IsDate"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][38]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][38]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][38]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][38]["IsHidden"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][39]["Name"], "LID")
        self.assertEqual(record["DbInfo"]["FieldList"][39]["FullName"], "Location ID")
        self.assertEqual(record["DbInfo"]["FieldList"][39]["Description"], "ELocation ID")
        self.assertEqual(record["DbInfo"]["FieldList"][39]["TermCount"], "56212")
        self.assertEqual(record["DbInfo"]["FieldList"][39]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][39]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][39]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][39]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][39]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][40]["Name"], "CRDT")
        self.assertEqual(record["DbInfo"]["FieldList"][40]["FullName"], "Create Date")
        self.assertEqual(record["DbInfo"]["FieldList"][40]["Description"], "Date publication first accessible through Entrez")
        self.assertEqual(record["DbInfo"]["FieldList"][40]["TermCount"], "27563")
        self.assertEqual(record["DbInfo"]["FieldList"][40]["IsDate"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][40]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][40]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][40]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][40]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][41]["Name"], "BOOK")
        self.assertEqual(record["DbInfo"]["FieldList"][41]["FullName"], "Book")
        self.assertEqual(record["DbInfo"]["FieldList"][41]["Description"], "ID of the book that contains the document")
        self.assertEqual(record["DbInfo"]["FieldList"][41]["TermCount"], "342")
        self.assertEqual(record["DbInfo"]["FieldList"][41]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][41]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][41]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][41]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][41]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][42]["Name"], "ED")
        self.assertEqual(record["DbInfo"]["FieldList"][42]["FullName"], "Editor")
        self.assertEqual(record["DbInfo"]["FieldList"][42]["Description"], "Section's Editor")
        self.assertEqual(record["DbInfo"]["FieldList"][42]["TermCount"], "335")
        self.assertEqual(record["DbInfo"]["FieldList"][42]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][42]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][42]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][42]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][42]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][43]["Name"], "ISBN")
        self.assertEqual(record["DbInfo"]["FieldList"][43]["FullName"], "ISBN")
        self.assertEqual(record["DbInfo"]["FieldList"][43]["Description"], "ISBN")
        self.assertEqual(record["DbInfo"]["FieldList"][43]["TermCount"], "189")
        self.assertEqual(record["DbInfo"]["FieldList"][43]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][43]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][43]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][43]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][43]["IsHidden"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][44]["Name"], "PUBN")
        self.assertEqual(record["DbInfo"]["FieldList"][44]["FullName"], "Publisher")
        self.assertEqual(record["DbInfo"]["FieldList"][44]["Description"], "Publisher's name")
        self.assertEqual(record["DbInfo"]["FieldList"][44]["TermCount"], "161")
        self.assertEqual(record["DbInfo"]["FieldList"][44]["IsDate"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][44]["IsNumerical"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][44]["SingleToken"], "Y")
        self.assertEqual(record["DbInfo"]["FieldList"][44]["Hierarchy"], "N")
        self.assertEqual(record["DbInfo"]["FieldList"][44]["IsHidden"], "N")
        self.assertEqual(len(record["DbInfo"]["LinkList"]), 57)
        self.assertEqual(record["DbInfo"]["LinkList"][0]["Name"], "pubmed_biosample")
        self.assertEqual(record["DbInfo"]["LinkList"][0]["Menu"], "BioSample Links")
        self.assertEqual(record["DbInfo"]["LinkList"][0]["Description"], "BioSample links")
        self.assertEqual(record["DbInfo"]["LinkList"][0]["DbTo"], "biosample")
        self.assertEqual(record["DbInfo"]["LinkList"][1]["Name"], "pubmed_biosystems")
        self.assertEqual(record["DbInfo"]["LinkList"][1]["Menu"], "BioSystem Links")
        self.assertEqual(record["DbInfo"]["LinkList"][1]["Description"], "Pathways and biological systems (BioSystems) that cite the current articles. Citations are from the BioSystems source databases (KEGG and BioCyc).")
        self.assertEqual(record["DbInfo"]["LinkList"][1]["DbTo"], "biosystems")
        self.assertEqual(record["DbInfo"]["LinkList"][2]["Name"], "pubmed_books_refs")
        self.assertEqual(record["DbInfo"]["LinkList"][2]["Menu"], "Cited in Books")
        self.assertEqual(record["DbInfo"]["LinkList"][2]["Description"], "NCBI Bookshelf books that cite the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][2]["DbTo"], "books")
        self.assertEqual(record["DbInfo"]["LinkList"][3]["Name"], "pubmed_cancerchromosomes")
        self.assertEqual(record["DbInfo"]["LinkList"][3]["Menu"], "CancerChrom Links")
        self.assertEqual(record["DbInfo"]["LinkList"][3]["Description"], "Cancer chromosome records that cite the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][3]["DbTo"], "cancerchromosomes")
        self.assertEqual(record["DbInfo"]["LinkList"][4]["Name"], "pubmed_cdd")
        self.assertEqual(record["DbInfo"]["LinkList"][4]["Menu"], "Domain Links")
        self.assertEqual(record["DbInfo"]["LinkList"][4]["Description"], "Conserved Domain Database (CDD) records that cite the current articles. Citations are from the CDD source database records (PFAM, SMART).")
        self.assertEqual(record["DbInfo"]["LinkList"][4]["DbTo"], "cdd")
        self.assertEqual(record["DbInfo"]["LinkList"][5]["Name"], "pubmed_domains")
        self.assertEqual(record["DbInfo"]["LinkList"][5]["Menu"], "3D Domain Links")
        self.assertEqual(record["DbInfo"]["LinkList"][5]["Description"], "Structural domains in the NCBI Structure database that are parts of the 3D structures reported in the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][5]["DbTo"], "domains")
        self.assertEqual(record["DbInfo"]["LinkList"][6]["Name"], "pubmed_epigenomics")
        self.assertEqual(record["DbInfo"]["LinkList"][6]["Menu"], "Epigenomics Links")
        self.assertEqual(record["DbInfo"]["LinkList"][6]["Description"], "Related Epigenomics records")
        self.assertEqual(record["DbInfo"]["LinkList"][6]["DbTo"], "epigenomics")
        self.assertEqual(record["DbInfo"]["LinkList"][7]["Name"], "pubmed_gap")
        self.assertEqual(record["DbInfo"]["LinkList"][7]["Menu"], "dbGaP Links")
        self.assertEqual(record["DbInfo"]["LinkList"][7]["Description"], "Genotypes and Phenotypes (dbGaP) studies that cite the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][7]["DbTo"], "gap")
        self.assertEqual(record["DbInfo"]["LinkList"][8]["Name"], "pubmed_gds")
        self.assertEqual(record["DbInfo"]["LinkList"][8]["Menu"], "GEO DataSet Links")
        self.assertEqual(record["DbInfo"]["LinkList"][8]["Description"], "Gene expression and molecular abundance data reported in the current articles that are also included in the curated Gene Expression Omnibus (GEO) DataSets.")
        self.assertEqual(record["DbInfo"]["LinkList"][8]["DbTo"], "gds")
        self.assertEqual(record["DbInfo"]["LinkList"][9]["Name"], "pubmed_gene")
        self.assertEqual(record["DbInfo"]["LinkList"][9]["Menu"], "Gene Links")
        self.assertEqual(record["DbInfo"]["LinkList"][9]["Description"], "Gene records that cite the current articles. Citations in Gene are added manually by NCBI or imported from outside public resources.")
        self.assertEqual(record["DbInfo"]["LinkList"][9]["DbTo"], "gene")
        self.assertEqual(record["DbInfo"]["LinkList"][10]["Name"], "pubmed_gene_bookrecords")
        self.assertEqual(record["DbInfo"]["LinkList"][10]["Menu"], "Gene (from Bookshelf)")
        self.assertEqual(record["DbInfo"]["LinkList"][10]["Description"], "Gene records in this citation")
        self.assertEqual(record["DbInfo"]["LinkList"][10]["DbTo"], "gene")
        self.assertEqual(record["DbInfo"]["LinkList"][11]["Name"], "pubmed_gene_citedinomim")
        self.assertEqual(record["DbInfo"]["LinkList"][11]["Menu"], "Gene (OMIM) Links")
        self.assertEqual(record["DbInfo"]["LinkList"][11]["Description"], "Gene records associated with Online Mendelian Inheritance in Man (OMIM) records that cite the current articles in their reference lists.")
        self.assertEqual(record["DbInfo"]["LinkList"][11]["DbTo"], "gene")
        self.assertEqual(record["DbInfo"]["LinkList"][12]["Name"], "pubmed_gene_rif")
        self.assertEqual(record["DbInfo"]["LinkList"][12]["Menu"], "Gene (GeneRIF) Links")
        self.assertEqual(record["DbInfo"]["LinkList"][12]["Description"], "Gene records that have the current articles as Reference into Function citations (GeneRIFs). NLM staff reviewing the literature while indexing MEDLINE add GeneRIFs manually.")
        self.assertEqual(record["DbInfo"]["LinkList"][12]["DbTo"], "gene")
        self.assertEqual(record["DbInfo"]["LinkList"][13]["Name"], "pubmed_genome")
        self.assertEqual(record["DbInfo"]["LinkList"][13]["Menu"], "Genome Links")
        self.assertEqual(record["DbInfo"]["LinkList"][13]["Description"], "Genome records that include the current articles as references. These are typically the articles that report the sequencing and analysis of the genome.")
        self.assertEqual(record["DbInfo"]["LinkList"][13]["DbTo"], "genome")
        self.assertEqual(record["DbInfo"]["LinkList"][14]["Name"], "pubmed_genomeprj")
        self.assertEqual(record["DbInfo"]["LinkList"][14]["Menu"], "Project Links")
        self.assertEqual(record["DbInfo"]["LinkList"][14]["Description"], "Genome Project records that cite the current articles. References on Genome Projects include manually added citations and those included on sequences in the project.")
        self.assertEqual(record["DbInfo"]["LinkList"][14]["DbTo"], "genomeprj")
        self.assertEqual(record["DbInfo"]["LinkList"][15]["Name"], "pubmed_gensat")
        self.assertEqual(record["DbInfo"]["LinkList"][15]["Menu"], "GENSAT Links")
        self.assertEqual(record["DbInfo"]["LinkList"][15]["Description"], "Gene Expression Nervous System Atlas (GENSAT) records that cite the current articles. References on GENSAT records are provided by GENSAT investigators, and also include references on the corresponding NCBI Gene record.")
        self.assertEqual(record["DbInfo"]["LinkList"][15]["DbTo"], "gensat")
        self.assertEqual(record["DbInfo"]["LinkList"][16]["Name"], "pubmed_geo")
        self.assertEqual(record["DbInfo"]["LinkList"][16]["Menu"], "GEO Profile Links")
        self.assertEqual(record["DbInfo"]["LinkList"][16]["Description"], "Gene Expression Omnibus (GEO) Profiles of molecular abundance data. The current articles are references on the Gene record associated with the GEO profile.")
        self.assertEqual(record["DbInfo"]["LinkList"][16]["DbTo"], "geo")
        self.assertEqual(record["DbInfo"]["LinkList"][17]["Name"], "pubmed_homologene")
        self.assertEqual(record["DbInfo"]["LinkList"][17]["Menu"], "HomoloGene Links")
        self.assertEqual(record["DbInfo"]["LinkList"][17]["Description"], "HomoloGene clusters of homologous genes and sequences that cite the current articles. These are references on the Gene and sequence records in the HomoloGene entry.")
        self.assertEqual(record["DbInfo"]["LinkList"][17]["DbTo"], "homologene")
        self.assertEqual(record["DbInfo"]["LinkList"][18]["Name"], "pubmed_nuccore")
        self.assertEqual(record["DbInfo"]["LinkList"][18]["Menu"], "Nucleotide Links")
        self.assertEqual(record["DbInfo"]["LinkList"][18]["Description"], "Primary database (GenBank) nucleotide records reported in the current articles as well as Reference Sequences (RefSeqs) that include the articles as references.")
        self.assertEqual(record["DbInfo"]["LinkList"][18]["DbTo"], "nuccore")
        self.assertEqual(record["DbInfo"]["LinkList"][19]["Name"], "pubmed_nuccore_refseq")
        self.assertEqual(record["DbInfo"]["LinkList"][19]["Menu"], "Nucleotide (RefSeq) Links")
        self.assertEqual(record["DbInfo"]["LinkList"][19]["Description"], "NCBI nucleotide Reference Sequences (RefSeqs) that are cited in the current articles, included in the corresponding Gene Reference into Function, or that include the PubMed articles as references.")
        self.assertEqual(record["DbInfo"]["LinkList"][19]["DbTo"], "nuccore")
        self.assertEqual(record["DbInfo"]["LinkList"][20]["Name"], "pubmed_nuccore_weighted")
        self.assertEqual(record["DbInfo"]["LinkList"][20]["Menu"], "Nucleotide (Weighted) Links")
        self.assertEqual(record["DbInfo"]["LinkList"][20]["Description"], "Nucleotide records associated with the current articles through the Gene database. These are the related sequences on the Gene record that are added manually by NCBI.")
        self.assertEqual(record["DbInfo"]["LinkList"][20]["DbTo"], "nuccore")
        self.assertEqual(record["DbInfo"]["LinkList"][21]["Name"], "pubmed_nucest")
        self.assertEqual(record["DbInfo"]["LinkList"][21]["Menu"], "EST Links")
        self.assertEqual(record["DbInfo"]["LinkList"][21]["Description"], "Expressed Sequence Tag (EST) nucleotide sequence records reported in the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][21]["DbTo"], "nucest")
        self.assertEqual(record["DbInfo"]["LinkList"][22]["Name"], "pubmed_nucgss")
        self.assertEqual(record["DbInfo"]["LinkList"][22]["Menu"], "GSS Links")
        self.assertEqual(record["DbInfo"]["LinkList"][22]["Description"], "Genome Survey Sequence (GSS) nucleotide records reported in the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][22]["DbTo"], "nucgss")
        self.assertEqual(record["DbInfo"]["LinkList"][23]["Name"], "pubmed_omia")
        self.assertEqual(record["DbInfo"]["LinkList"][23]["Menu"], "OMIA Links")
        self.assertEqual(record["DbInfo"]["LinkList"][23]["Description"], "Online Mendelian Inheritance in Animals (OMIA) records that cite the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][23]["DbTo"], "omia")
        self.assertEqual(record["DbInfo"]["LinkList"][24]["Name"], "pubmed_omim_bookrecords")
        self.assertEqual(record["DbInfo"]["LinkList"][24]["Menu"], "OMIM (from Bookshelf)")
        self.assertEqual(record["DbInfo"]["LinkList"][24]["Description"], "OMIM records in this citation")
        self.assertEqual(record["DbInfo"]["LinkList"][24]["DbTo"], "omim")
        self.assertEqual(record["DbInfo"]["LinkList"][25]["Name"], "pubmed_omim_calculated")
        self.assertEqual(record["DbInfo"]["LinkList"][25]["Menu"], "OMIM (calculated) Links")
        self.assertEqual(record["DbInfo"]["LinkList"][25]["Description"], "Online Mendelian Inheritance in Man (OMIM) records that include the current articles as references in the light bulb links within or in the citations at the end of the OMIM record. The references available through the light bulb link are collected using the PubMed related articles algorithm to identify records with similar terminology to the OMIM record.")
        self.assertEqual(record["DbInfo"]["LinkList"][25]["DbTo"], "omim")
        self.assertEqual(record["DbInfo"]["LinkList"][26]["Name"], "pubmed_omim_cited")
        self.assertEqual(record["DbInfo"]["LinkList"][26]["Menu"], "OMIM (cited) Links")
        self.assertEqual(record["DbInfo"]["LinkList"][26]["Description"], "Online Mendelian Inheritance in Man (OMIM) records that include the current articles as reference cited at the end of the OMIM record.")
        self.assertEqual(record["DbInfo"]["LinkList"][26]["DbTo"], "omim")
        self.assertEqual(record["DbInfo"]["LinkList"][27]["Name"], "pubmed_pcassay")
        self.assertEqual(record["DbInfo"]["LinkList"][27]["Menu"], "BioAssay Links")
        self.assertEqual(record["DbInfo"]["LinkList"][27]["Description"], "PubChem BioAssay experiments on the biological activities of small molecules that cite the current articles. The depositors of BioAssay data provide these references.")
        self.assertEqual(record["DbInfo"]["LinkList"][27]["DbTo"], "pcassay")
        self.assertEqual(record["DbInfo"]["LinkList"][28]["Name"], "pubmed_pccompound")
        self.assertEqual(record["DbInfo"]["LinkList"][28]["Menu"], "Compound Links")
        self.assertEqual(record["DbInfo"]["LinkList"][28]["Description"], "PubChem chemical compound records that cite the current articles. These references are taken from those provided on submitted PubChem chemical substance records. Multiple substance records may contribute to the PubChem compound record.")
        self.assertEqual(record["DbInfo"]["LinkList"][28]["DbTo"], "pccompound")
        self.assertEqual(record["DbInfo"]["LinkList"][29]["Name"], "pubmed_pccompound_mesh")
        self.assertEqual(record["DbInfo"]["LinkList"][29]["Menu"], "Compound (MeSH Keyword)")
        self.assertEqual(record["DbInfo"]["LinkList"][29]["Description"], "PubChem chemical compound records that are classified under the same Medical Subject Headings (MeSH) controlled vocabulary as the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][29]["DbTo"], "pccompound")
        self.assertEqual(record["DbInfo"]["LinkList"][30]["Name"], "pubmed_pccompound_publisher")
        self.assertEqual(record["DbInfo"]["LinkList"][30]["Menu"], "Compound (Publisher) Links")
        self.assertEqual(record["DbInfo"]["LinkList"][30]["Description"], "Link to publisher deposited structures in the PubChem Compound database.")
        self.assertEqual(record["DbInfo"]["LinkList"][30]["DbTo"], "pccompound")
        self.assertEqual(record["DbInfo"]["LinkList"][31]["Name"], "pubmed_pcsubstance")
        self.assertEqual(record["DbInfo"]["LinkList"][31]["Menu"], "Substance Links")
        self.assertEqual(record["DbInfo"]["LinkList"][31]["Description"], "PubChem chemical substance records that cite the current articles. These references are taken from those provided on submitted PubChem chemical substance records.")
        self.assertEqual(record["DbInfo"]["LinkList"][31]["DbTo"], "pcsubstance")
        self.assertEqual(record["DbInfo"]["LinkList"][32]["Name"], "pubmed_pcsubstance_bookrecords")
        self.assertEqual(record["DbInfo"]["LinkList"][32]["Menu"], "PubChem Substance (from Bookshelf)")
        self.assertEqual(record["DbInfo"]["LinkList"][32]["Description"], "Structures in the PubChem Substance database in this citation")
        self.assertEqual(record["DbInfo"]["LinkList"][32]["DbTo"], "pcsubstance")
        self.assertEqual(record["DbInfo"]["LinkList"][33]["Name"], "pubmed_pcsubstance_mesh")
        self.assertEqual(record["DbInfo"]["LinkList"][33]["Menu"], "Substance (MeSH Keyword)")
        self.assertEqual(record["DbInfo"]["LinkList"][33]["Description"], "PubChem chemical substance (submitted) records that are classified under the same Medical Subject Headings (MeSH) controlled vocabulary as the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][33]["DbTo"], "pcsubstance")
        self.assertEqual(record["DbInfo"]["LinkList"][34]["Name"], "pubmed_pcsubstance_publisher")
        self.assertEqual(record["DbInfo"]["LinkList"][34]["Menu"], "Substance (Publisher) Links")
        self.assertEqual(record["DbInfo"]["LinkList"][34]["Description"], "Publisher deposited structures in the PubChem Compound database that are reported in the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][34]["DbTo"], "pcsubstance")
        self.assertEqual(record["DbInfo"]["LinkList"][35]["Name"], "pubmed_pepdome")
        self.assertEqual(record["DbInfo"]["LinkList"][35]["Menu"], "Peptidome Links")
        self.assertEqual(record["DbInfo"]["LinkList"][35]["Description"], "Protein mass spectrometry and other proteomics data from the Peptidome database reported in the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][35]["DbTo"], "pepdome")
        self.assertEqual(record["DbInfo"]["LinkList"][36]["Name"], "pubmed_pmc")
        self.assertEqual(record["DbInfo"]["LinkList"][36]["Menu"], "PMC Links")
        self.assertEqual(record["DbInfo"]["LinkList"][36]["Description"], "Free full-text versions of the current articles in the PubMed Central database.")
        self.assertEqual(record["DbInfo"]["LinkList"][36]["DbTo"], "pmc")
        self.assertEqual(record["DbInfo"]["LinkList"][37]["Name"], "pubmed_pmc_bookrecords")
        self.assertEqual(record["DbInfo"]["LinkList"][37]["Menu"], "References in PMC for this Bookshelf citation")
        self.assertEqual(record["DbInfo"]["LinkList"][37]["Description"], "Full text of articles in PubMed Central cited in this record")
        self.assertEqual(record["DbInfo"]["LinkList"][37]["DbTo"], "pmc")
        self.assertEqual(record["DbInfo"]["LinkList"][38]["Name"], "pubmed_pmc_embargo")
        self.assertEqual(record["DbInfo"]["LinkList"][38]["Menu"], "")
        self.assertEqual(record["DbInfo"]["LinkList"][38]["Description"], "Embargoed PMC article associated with PubMed")
        self.assertEqual(record["DbInfo"]["LinkList"][38]["DbTo"], "pmc")
        self.assertEqual(record["DbInfo"]["LinkList"][39]["Name"], "pubmed_pmc_local")
        self.assertEqual(record["DbInfo"]["LinkList"][39]["Menu"], "")
        self.assertEqual(record["DbInfo"]["LinkList"][39]["Description"], "Free full text articles in PMC")
        self.assertEqual(record["DbInfo"]["LinkList"][39]["DbTo"], "pmc")
        self.assertEqual(record["DbInfo"]["LinkList"][40]["Name"], "pubmed_pmc_refs")
        self.assertEqual(record["DbInfo"]["LinkList"][40]["Menu"], "Cited in PMC")
        self.assertEqual(record["DbInfo"]["LinkList"][40]["Description"], "Full-text articles in the PubMed Central Database that cite the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][40]["DbTo"], "pmc")
        self.assertEqual(record["DbInfo"]["LinkList"][41]["Name"], "pubmed_popset")
        self.assertEqual(record["DbInfo"]["LinkList"][41]["Menu"], "PopSet Links")
        self.assertEqual(record["DbInfo"]["LinkList"][41]["Description"], "Sets of sequences from population and evolutionary genetic studies in the PopSet database reported in the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][41]["DbTo"], "popset")
        self.assertEqual(record["DbInfo"]["LinkList"][42]["Name"], "pubmed_probe")
        self.assertEqual(record["DbInfo"]["LinkList"][42]["Menu"], "Probe Links")
        self.assertEqual(record["DbInfo"]["LinkList"][42]["Description"], "Molecular reagents in the Probe database that cite the current articles. References in Probe are provided by submitters of the data.")
        self.assertEqual(record["DbInfo"]["LinkList"][42]["DbTo"], "probe")
        self.assertEqual(record["DbInfo"]["LinkList"][43]["Name"], "pubmed_protein")
        self.assertEqual(record["DbInfo"]["LinkList"][43]["Menu"], "Protein Links")
        self.assertEqual(record["DbInfo"]["LinkList"][43]["Description"], "Protein translation features of primary database (GenBank) nucleotide records reported in the current articles as well as Reference Sequences (RefSeqs) that include the articles as references.")
        self.assertEqual(record["DbInfo"]["LinkList"][43]["DbTo"], "protein")
        self.assertEqual(record["DbInfo"]["LinkList"][44]["Name"], "pubmed_protein_refseq")
        self.assertEqual(record["DbInfo"]["LinkList"][44]["Menu"], "Protein (RefSeq) Links")
        self.assertEqual(record["DbInfo"]["LinkList"][44]["Description"], "NCBI protein Reference Sequences (RefSeqs) that are cited in the current articles, included in the corresponding Gene Reference into Function, or that include the PubMed articles as references.")
        self.assertEqual(record["DbInfo"]["LinkList"][44]["DbTo"], "protein")
        self.assertEqual(record["DbInfo"]["LinkList"][45]["Name"], "pubmed_protein_weighted")
        self.assertEqual(record["DbInfo"]["LinkList"][45]["Menu"], "Protein (Weighted) Links")
        self.assertEqual(record["DbInfo"]["LinkList"][45]["Description"], "Protein records associated with the current articles through related Gene database records. These are the related sequences on the Gene record that are added manually by NCBI.")
        self.assertEqual(record["DbInfo"]["LinkList"][45]["DbTo"], "protein")
        self.assertEqual(record["DbInfo"]["LinkList"][46]["Name"], "pubmed_proteinclusters")
        self.assertEqual(record["DbInfo"]["LinkList"][46]["Menu"], "Protein Cluster Links")
        self.assertEqual(record["DbInfo"]["LinkList"][46]["Description"], "Clusters of related proteins from the Protein Clusters database that cite the current articles. Sources of references in Protein Clusters include the associated Gene and Conserved Domain records as well as NCBI added citations.")
        self.assertEqual(record["DbInfo"]["LinkList"][46]["DbTo"], "proteinclusters")
        self.assertEqual(record["DbInfo"]["LinkList"][47]["Name"], "pubmed_pubmed")
        self.assertEqual(record["DbInfo"]["LinkList"][47]["Menu"], "Related Citations")
        self.assertEqual(record["DbInfo"]["LinkList"][47]["Description"], u"Calculated set of PubMed citations closely related to the selected article(s) retrieved using a word weight algorithm. Related articles are displayed in ranked order from most to least relevant, with the \u201clinked from\u201d citation displayed first.")
        self.assertEqual(record["DbInfo"]["LinkList"][47]["DbTo"], "pubmed")
        self.assertEqual(record["DbInfo"]["LinkList"][48]["Name"], "pubmed_pubmed_bookrecords")
        self.assertEqual(record["DbInfo"]["LinkList"][48]["Menu"], "References for this Bookshelf citation")
        self.assertEqual(record["DbInfo"]["LinkList"][48]["Description"], "PubMed abstracts for articles cited in this record")
        self.assertEqual(record["DbInfo"]["LinkList"][48]["DbTo"], "pubmed")
        self.assertEqual(record["DbInfo"]["LinkList"][49]["Name"], "pubmed_pubmed_refs")
        self.assertEqual(record["DbInfo"]["LinkList"][49]["Menu"], "References for PMC Articles")
        self.assertEqual(record["DbInfo"]["LinkList"][49]["Description"], "Citation referenced in PubMed article. Only valid for PubMed citations that are also in PMC.")
        self.assertEqual(record["DbInfo"]["LinkList"][49]["DbTo"], "pubmed")
        self.assertEqual(record["DbInfo"]["LinkList"][50]["Name"], "pubmed_snp")
        self.assertEqual(record["DbInfo"]["LinkList"][50]["Menu"], "SNP Links")
        self.assertEqual(record["DbInfo"]["LinkList"][50]["Description"], "Nucleotide polymorphism records from dbSNP that have current articles as submitter-provided references.")
        self.assertEqual(record["DbInfo"]["LinkList"][50]["DbTo"], "snp")
        self.assertEqual(record["DbInfo"]["LinkList"][51]["Name"], "pubmed_snp_cited")
        self.assertEqual(record["DbInfo"]["LinkList"][51]["Menu"], "SNP (Cited)")
        self.assertEqual(record["DbInfo"]["LinkList"][51]["Description"], "Nucleotide polymorphism records from dbSNP that have NCBI dbSNP identifiers reported in the PubMed abstract of the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][51]["DbTo"], "snp")
        self.assertEqual(record["DbInfo"]["LinkList"][52]["Name"], "pubmed_sra")
        self.assertEqual(record["DbInfo"]["LinkList"][52]["Menu"], "SRA Links")
        self.assertEqual(record["DbInfo"]["LinkList"][52]["Description"], "Massively-parallel sequencing project data in the Short Read Archive (SRA) that are reported in the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][52]["DbTo"], "sra")
        self.assertEqual(record["DbInfo"]["LinkList"][53]["Name"], "pubmed_structure")
        self.assertEqual(record["DbInfo"]["LinkList"][53]["Menu"], "Structure Links")
        self.assertEqual(record["DbInfo"]["LinkList"][53]["Description"], "Three-dimensional structure records in the NCBI Structure database for data reported in the current articles.")
        self.assertEqual(record["DbInfo"]["LinkList"][53]["DbTo"], "structure")
        self.assertEqual(record["DbInfo"]["LinkList"][54]["Name"], "pubmed_taxonomy_entrez")
        self.assertEqual(record["DbInfo"]["LinkList"][54]["Menu"], "Taxonomy via GenBank")
        self.assertEqual(record["DbInfo"]["LinkList"][54]["Description"], "Taxonomy records associated with the current articles through taxonomic information on related molecular database records (Nucleotide, Protein, Gene, SNP, Structure).")
        self.assertEqual(record["DbInfo"]["LinkList"][54]["DbTo"], "taxonomy")
        self.assertEqual(record["DbInfo"]["LinkList"][55]["Name"], "pubmed_unigene")
        self.assertEqual(record["DbInfo"]["LinkList"][55]["Menu"], "UniGene Links")
        self.assertEqual(record["DbInfo"]["LinkList"][55]["Description"], "UniGene clusters of expressed sequences that are associated with the current articles through references on the clustered sequence records and related Gene records.")
        self.assertEqual(record["DbInfo"]["LinkList"][55]["DbTo"], "unigene")
        self.assertEqual(record["DbInfo"]["LinkList"][56]["Name"], "pubmed_unists")
        self.assertEqual(record["DbInfo"]["LinkList"][56]["Menu"], "UniSTS Links")
        self.assertEqual(record["DbInfo"]["LinkList"][56]["Description"], "Genetic, physical, and sequence mapping reagents in the UniSTS database associated with the current articles through references on sequence tagged site (STS) submissions as well as automated searching of PubMed abstracts and full-text PubMed Central articles for marker names.")
        self.assertEqual(record["DbInfo"]["LinkList"][56]["DbTo"], "unists")

    def test_corrupted(self):
        '''Test if corrupted XML is handled correctly
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.einfo()
        # and manually delete the last couple of lines
        from Bio.Entrez import Parser
        handle = open('Entrez/einfo4.xml', "rb")
        self.assertRaises(Parser.CorruptedXMLError, Entrez.read, handle)
        handle.close()


class ESearchTest(unittest.TestCase):
    '''Tests for parsing XML output returned by ESearch
    '''
    def test_pubmed1(self):
        '''Test parsing XML returned by ESearch from PubMed (first test)
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.esearch(db="pubmed", term="biopython")
        handle = open('Entrez/esearch1.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], '5')
        self.assertEqual(record['RetMax'], '5')
        self.assertEqual(record['RetStart'], '0')
        self.assertEqual(len(record['IdList']), 5)
        self.assertEqual(record['IdList'][0], '16403221')
        self.assertEqual(record['IdList'][1], '16377612')
        self.assertEqual(record['IdList'][2], '14871861')
        self.assertEqual(record['IdList'][3], '14630660')
        self.assertEqual(record['IdList'][4], '12230038')
        self.assertEqual(len(record['TranslationSet']), 0)
        self.assertEqual(len(record['TranslationStack']), 2)
        self.assertEqual(record['TranslationStack'][0]['Term'], 'biopython[All Fields]')
        self.assertEqual(record['TranslationStack'][0]['Field'], 'All Fields')
        self.assertEqual(record['TranslationStack'][0]['Count'], '5')
        self.assertEqual(record['TranslationStack'][0]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][1], 'GROUP')
        self.assertEqual(record['QueryTranslation'], 'biopython[All Fields]')

    def test_pubmed2(self):
        '''Test parsing XML returned by ESearch from PubMed (second test)
        '''
        # Search in PubMed for the term cancer for the entrez date from
        # the last 60 days and retrieve the first 100 IDs and translations
        # using the history parameter.
        # To create the XML file, use
        # >>> Bio.Entrez.esearch(db="pubmed", term="cancer", reldate=60,
        #                        datetype="edat", retmax=100, usehistory="y")
        handle = open('Entrez/esearch2.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], "10238")
        self.assertEqual(record['RetMax'], "100")
        self.assertEqual(record['RetStart'], "0")
        self.assertEqual(record['QueryKey'], '12')
        self.assertEqual(record['WebEnv'], '0rYFb69LfbTFXfG7-0HPo2BU-ZFWF1s_51WtYR5e0fAzThQCR0WIW12inPQRRIj1xUzSfGgG9ovT9-@263F6CC86FF8F760_0173SID')
        self.assertEqual(len(record['IdList']), 100)
        self.assertEqual(record['IdList'][0], '18411453')
        self.assertEqual(record['IdList'][1], '18411431')
        self.assertEqual(record['IdList'][2], '18411430')
        self.assertEqual(record['IdList'][3], '18411429')
        self.assertEqual(record['IdList'][4], '18411428')
        self.assertEqual(record['IdList'][5], '18411402')
        self.assertEqual(record['IdList'][6], '18411381')
        self.assertEqual(record['IdList'][7], '18411373')
        self.assertEqual(record['IdList'][8], '18411372')
        self.assertEqual(record['IdList'][9], '18411371')
        self.assertEqual(record['IdList'][10], '18411370')
        self.assertEqual(record['IdList'][11], '18411367')
        self.assertEqual(record['IdList'][12], '18411306')
        self.assertEqual(record['IdList'][13], '18411292')
        self.assertEqual(record['IdList'][14], '18411277')
        self.assertEqual(record['IdList'][15], '18411260')
        self.assertEqual(record['IdList'][16], '18411234')
        self.assertEqual(record['IdList'][17], '18411200')
        self.assertEqual(record['IdList'][18], '18411199')
        self.assertEqual(record['IdList'][19], '18411198')
        self.assertEqual(record['IdList'][20], '18411197')
        self.assertEqual(record['IdList'][21], '18411195')
        self.assertEqual(record['IdList'][22], '18411194')
        self.assertEqual(record['IdList'][23], '18411193')
        self.assertEqual(record['IdList'][24], '18411192')
        self.assertEqual(record['IdList'][25], '18411191')
        self.assertEqual(record['IdList'][26], '18411052')
        self.assertEqual(record['IdList'][27], '18411048')
        self.assertEqual(record['IdList'][28], '18411046')
        self.assertEqual(record['IdList'][29], '18411019')
        self.assertEqual(record['IdList'][30], '18411018')
        self.assertEqual(record['IdList'][31], '18411017')
        self.assertEqual(record['IdList'][32], '18411015')
        self.assertEqual(record['IdList'][33], '18411014')
        self.assertEqual(record['IdList'][34], '18411011')
        self.assertEqual(record['IdList'][35], '18411010')
        self.assertEqual(record['IdList'][36], '18411005')
        self.assertEqual(record['IdList'][37], '18411003')
        self.assertEqual(record['IdList'][38], '18411001')
        self.assertEqual(record['IdList'][39], '18411000')
        self.assertEqual(record['IdList'][40], '18410999')
        self.assertEqual(record['IdList'][41], '18410998')
        self.assertEqual(record['IdList'][42], '18410997')
        self.assertEqual(record['IdList'][43], '18410995')
        self.assertEqual(record['IdList'][44], '18410977')
        self.assertEqual(record['IdList'][45], '18410975')
        self.assertEqual(record['IdList'][46], '18410966')
        self.assertEqual(record['IdList'][47], '18410954')
        self.assertEqual(record['IdList'][48], '18410953')
        self.assertEqual(record['IdList'][49], '18410934')
        self.assertEqual(record['IdList'][50], '18410925')
        self.assertEqual(record['IdList'][51], '18410903')
        self.assertEqual(record['IdList'][52], '18410826')
        self.assertEqual(record['IdList'][53], '18410739')
        self.assertEqual(record['IdList'][54], '18410720')
        self.assertEqual(record['IdList'][55], '18410716')
        self.assertEqual(record['IdList'][56], '18410709')
        self.assertEqual(record['IdList'][57], '18410705')
        self.assertEqual(record['IdList'][58], '18410692')
        self.assertEqual(record['IdList'][59], '18410690')
        self.assertEqual(record['IdList'][60], '18410634')
        self.assertEqual(record['IdList'][61], '18410618')
        self.assertEqual(record['IdList'][62], '18410610')
        self.assertEqual(record['IdList'][63], '18410593')
        self.assertEqual(record['IdList'][64], '18410587')
        self.assertEqual(record['IdList'][65], '18410567')
        self.assertEqual(record['IdList'][66], '18410539')
        self.assertEqual(record['IdList'][67], '18410530')
        self.assertEqual(record['IdList'][68], '18410528')
        self.assertEqual(record['IdList'][69], '18410461')
        self.assertEqual(record['IdList'][70], '18410455')
        self.assertEqual(record['IdList'][71], '18410444')
        self.assertEqual(record['IdList'][72], '18410443')
        self.assertEqual(record['IdList'][73], '18410442')
        self.assertEqual(record['IdList'][74], '18410441')
        self.assertEqual(record['IdList'][75], '18410440')
        self.assertEqual(record['IdList'][76], '18410439')
        self.assertEqual(record['IdList'][77], '18410437')
        self.assertEqual(record['IdList'][78], '18410436')
        self.assertEqual(record['IdList'][79], '18410435')
        self.assertEqual(record['IdList'][80], '18410431')
        self.assertEqual(record['IdList'][81], '18410430')
        self.assertEqual(record['IdList'][82], '18410428')
        self.assertEqual(record['IdList'][83], '18410427')
        self.assertEqual(record['IdList'][84], '18410405')
        self.assertEqual(record['IdList'][85], '18410404')
        self.assertEqual(record['IdList'][86], '18410355')
        self.assertEqual(record['IdList'][87], '18410327')
        self.assertEqual(record['IdList'][88], '18410312')
        self.assertEqual(record['IdList'][89], '18410311')
        self.assertEqual(record['IdList'][90], '18410307')
        self.assertEqual(record['IdList'][91], '18410259')
        self.assertEqual(record['IdList'][92], '18410249')
        self.assertEqual(record['IdList'][93], '18410245')
        self.assertEqual(record['IdList'][94], '18410243')
        self.assertEqual(record['IdList'][95], '18410242')
        self.assertEqual(record['IdList'][96], '18410060')
        self.assertEqual(record['IdList'][97], '18410013')
        self.assertEqual(record['IdList'][98], '18409992')
        self.assertEqual(record['IdList'][99], '18409991')
        self.assertEqual(len(record['TranslationSet']), 1)
        self.assertEqual(record['TranslationSet'][0]['From'], 'cancer')
        self.assertEqual(record['TranslationSet'][0]['To'], '(("neoplasms"[TIAB] NOT Medline[SB]) OR "neoplasms"[MeSH Terms] OR cancer[Text Word])')
        self.assertEqual(len(record['TranslationStack']), 13)
        self.assertEqual(record['TranslationStack'][0]['Term'], '"neoplasms"[TIAB]')
        self.assertEqual(record['TranslationStack'][0]['Field'], 'TIAB')
        self.assertEqual(record['TranslationStack'][0]['Count'], "52104")
        self.assertEqual(record['TranslationStack'][0]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][1]['Term'], 'Medline[SB]')
        self.assertEqual(record['TranslationStack'][1]['Field'], 'SB')
        self.assertEqual(record['TranslationStack'][1]['Count'], "16509514")
        self.assertEqual(record['TranslationStack'][1]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][2], 'NOT')
        self.assertEqual(record['TranslationStack'][3], 'GROUP')
        self.assertEqual(record['TranslationStack'][4]['Term'], '"neoplasms"[MeSH Terms]')
        self.assertEqual(record['TranslationStack'][4]['Field'], 'MeSH Terms')
        self.assertEqual(record['TranslationStack'][4]['Count'], "1918010")
        self.assertEqual(record['TranslationStack'][4]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][5], 'OR')
        self.assertEqual(record['TranslationStack'][6]['Term'], 'cancer[Text Word]')
        self.assertEqual(record['TranslationStack'][6]['Field'], 'Text Word')
        self.assertEqual(record['TranslationStack'][6]['Count'], "638849")
        self.assertEqual(record['TranslationStack'][6]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][7], 'OR')
        self.assertEqual(record['TranslationStack'][8], 'GROUP')
        self.assertEqual(record['TranslationStack'][9]['Term'], '2008/02/16[EDAT]')
        self.assertEqual(record['TranslationStack'][9]['Field'], 'EDAT')
        self.assertEqual(record['TranslationStack'][9]['Count'], "-1")
        self.assertEqual(record['TranslationStack'][9]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][10]['Term'], '2008/04/16[EDAT]')
        self.assertEqual(record['TranslationStack'][10]['Field'], 'EDAT')
        self.assertEqual(record['TranslationStack'][10]['Count'], "-1")
        self.assertEqual(record['TranslationStack'][10]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][11], 'RANGE')
        self.assertEqual(record['TranslationStack'][12], 'AND')
        self.assertEqual(record['QueryTranslation'], '(("neoplasms"[TIAB] NOT Medline[SB]) OR "neoplasms"[MeSH Terms] OR cancer[Text Word]) AND 2008/02/16[EDAT] : 2008/04/16[EDAT]')

    def test_pubmed3(self):
        '''Test parsing XML returned by ESearch from PubMed (third test)
        '''
        # Search in PubMed for the journal PNAS Volume 97, and retrieve
        # 6 IDs starting at ID 7.
        # To create the XML file, use
        # >>> Bio.Entrez.esearch(db="pubmed", term="PNAS[ta] AND 97[vi]",
        #                        retstart=6, retmax=6)
        handle = open('Entrez/esearch3.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], '2652')
        self.assertEqual(record['RetMax'], '6')
        self.assertEqual(record['RetStart'], '6')
        self.assertEqual(len(record['IdList']), 6)
        self.assertEqual(record['IdList'][0], '11121077')
        self.assertEqual(record['IdList'][1], '11121076')
        self.assertEqual(record['IdList'][2], '11121075')
        self.assertEqual(record['IdList'][3], '11121074')
        self.assertEqual(record['IdList'][4], '11121073')
        self.assertEqual(record['IdList'][5], '11121072')
        self.assertEqual(len(record['TranslationSet']), 1)
        self.assertEqual(record['TranslationSet'][0]['From'], 'PNAS[ta]')
        self.assertEqual(record['TranslationSet'][0]['To'], '"Proc Natl Acad Sci U S A"[Journal:__jrid6653]')
        self.assertEqual(len(record['TranslationStack']), 3)
        self.assertEqual(record['TranslationStack'][0]['Term'], '"Proc Natl Acad Sci U S A"[Journal]')
        self.assertEqual(record['TranslationStack'][0]['Field'], 'Journal')
        self.assertEqual(record['TranslationStack'][0]['Count'], '91806')
        self.assertEqual(record['TranslationStack'][0]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][1]['Term'], '97[vi]')
        self.assertEqual(record['TranslationStack'][1]['Field'], 'vi')
        self.assertEqual(record['TranslationStack'][1]['Count'], '58681')
        self.assertEqual(record['TranslationStack'][1]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][2], 'AND')
        self.assertEqual(record['QueryTranslation'], '"Proc Natl Acad Sci U S A"[Journal] AND 97[vi]')

    def test_journals(self):
        '''Test parsing XML returned by ESearch from the Journals database
        '''
        # Search in Journals for the term obstetrics.
        # To create the XML file, use
        # >>> Bio.Entrez.esearch(db="journals", term="obstetrics")
        handle = open('Entrez/esearch4.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], '177')
        self.assertEqual(record['RetMax'], '20')
        self.assertEqual(record['RetStart'], '0')
        self.assertEqual(len(record['IdList']), 20)
        self.assertEqual(record['IdList'][0], '75')
        self.assertEqual(record['IdList'][1], '138')
        self.assertEqual(record['IdList'][2], '136')
        self.assertEqual(record['IdList'][3], '137')
        self.assertEqual(record['IdList'][4], '139')
        self.assertEqual(record['IdList'][5], '140')
        self.assertEqual(record['IdList'][6], '355')
        self.assertEqual(record['IdList'][7], '354')
        self.assertEqual(record['IdList'][8], '27731')
        self.assertEqual(record['IdList'][9], '439')
        self.assertEqual(record['IdList'][10], '564')
        self.assertEqual(record['IdList'][11], '617')
        self.assertEqual(record['IdList'][12], '749')
        self.assertEqual(record['IdList'][13], '735')
        self.assertEqual(record['IdList'][14], '815')
        self.assertEqual(record['IdList'][15], '905')
        self.assertEqual(record['IdList'][16], '903')
        self.assertEqual(record['IdList'][17], '932')
        self.assertEqual(record['IdList'][18], '933')
        self.assertEqual(record['IdList'][19], '875')
        self.assertEqual(len(record['TranslationSet']), 0)
        self.assertEqual(len(record['TranslationStack']), 2)
        self.assertEqual(record['TranslationStack'][0]['Term'], 'obstetrics[All Fields]')
        self.assertEqual(record['TranslationStack'][0]['Field'], 'All Fields')
        self.assertEqual(record['TranslationStack'][0]['Count'], '177')
        self.assertEqual(record['TranslationStack'][0]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][0].tag, "TermSet")
        self.assertEqual(record['TranslationStack'][1], 'GROUP')
        self.assertEqual(record['TranslationStack'][1].tag, "OP")
        self.assertEqual(record['QueryTranslation'], 'obstetrics[All Fields]')

    def test_pmc(self):
        '''Test parsing XML returned by ESearch from PubMed Central
        '''
        # Search in PubMed Central for stem cells in free fulltext articles.
        # To create the XML file, use
        # >>> Bio.Entrez.esearch(db="pmc",
        #                        term="stem cells AND free fulltext[filter]")
        handle = open('Entrez/esearch5.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], '23492')
        self.assertEqual(record['RetMax'], '20')
        self.assertEqual(record['RetStart'], '0')
        self.assertEqual(len(record['IdList']), 20)
        self.assertEqual(record['IdList'][0], '1894783')
        self.assertEqual(record['IdList'][1], '2064507')
        self.assertEqual(record['IdList'][2], '520747')
        self.assertEqual(record['IdList'][3], '2043120')
        self.assertEqual(record['IdList'][4], '2118723')
        self.assertEqual(record['IdList'][5], '1815228')
        self.assertEqual(record['IdList'][6], '1253596')
        self.assertEqual(record['IdList'][7], '2077853')
        self.assertEqual(record['IdList'][8], '1308908')
        self.assertEqual(record['IdList'][9], '2233634')
        self.assertEqual(record['IdList'][10], '556262')
        self.assertEqual(record['IdList'][11], '1925137')
        self.assertEqual(record['IdList'][12], '1860068')
        self.assertEqual(record['IdList'][13], '1626529')
        self.assertEqual(record['IdList'][14], '2217616')
        self.assertEqual(record['IdList'][15], '1584276')
        self.assertEqual(record['IdList'][16], '2000702')
        self.assertEqual(record['IdList'][17], '186324')
        self.assertEqual(record['IdList'][18], '1959362')
        self.assertEqual(record['IdList'][19], '1413911')
        self.assertEqual(len(record['TranslationSet']), 1)
        self.assertEqual(record['TranslationSet'][0]['From'], 'stem cells')
        self.assertEqual(record['TranslationSet'][0]['To'], '("stem cells"[MeSH Terms] OR stem cells[Acknowledgments] OR stem cells[Figure/Table Caption] OR stem cells[Section Title] OR stem cells[Body - All Words] OR stem cells[Title] OR stem cells[Abstract])')
        self.assertEqual(len(record['TranslationStack']), 16)
        self.assertEqual(record['TranslationStack'][0]['Term'], '"stem cells"[MeSH Terms]')
        self.assertEqual(record['TranslationStack'][0]['Field'], 'MeSH Terms')
        self.assertEqual(record['TranslationStack'][0]['Count'], '12224')
        self.assertEqual(record['TranslationStack'][0]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][1]['Term'], 'stem cells[Acknowledgments]')
        self.assertEqual(record['TranslationStack'][1]['Field'], 'Acknowledgments')
        self.assertEqual(record['TranslationStack'][1]['Count'], '79')
        self.assertEqual(record['TranslationStack'][1]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][2], 'OR')
        self.assertEqual(record['TranslationStack'][3]['Term'], 'stem cells[Figure/Table Caption]')
        self.assertEqual(record['TranslationStack'][3]['Field'], 'Figure/Table Caption')
        self.assertEqual(record['TranslationStack'][3]['Count'], '806')
        self.assertEqual(record['TranslationStack'][3]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][4], 'OR')
        self.assertEqual(record['TranslationStack'][5]['Term'], 'stem cells[Section Title]')
        self.assertEqual(record['TranslationStack'][5]['Field'], 'Section Title')
        self.assertEqual(record['TranslationStack'][5]['Count'], '522')
        self.assertEqual(record['TranslationStack'][5]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][6], 'OR')
        self.assertEqual(record['TranslationStack'][7]['Term'], 'stem cells[Body - All Words]')
        self.assertEqual(record['TranslationStack'][7]['Field'], 'Body - All Words')
        self.assertEqual(record['TranslationStack'][7]['Count'], '13936')
        self.assertEqual(record['TranslationStack'][7]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][8], 'OR')
        self.assertEqual(record['TranslationStack'][9]['Term'], 'stem cells[Title]')
        self.assertEqual(record['TranslationStack'][9]['Field'], 'Title')
        self.assertEqual(record['TranslationStack'][9]['Count'], '1005')
        self.assertEqual(record['TranslationStack'][9]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][10], 'OR')
        self.assertEqual(record['TranslationStack'][11]['Term'], 'stem cells[Abstract]')
        self.assertEqual(record['TranslationStack'][11]['Field'], 'Abstract')
        self.assertEqual(record['TranslationStack'][11]['Count'], '2503')
        self.assertEqual(record['TranslationStack'][11]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][12], 'OR')
        self.assertEqual(record['TranslationStack'][13], 'GROUP')
        self.assertEqual(record['TranslationStack'][14]['Term'], 'free fulltext[filter]')
        self.assertEqual(record['TranslationStack'][14]['Field'], 'filter')
        self.assertEqual(record['TranslationStack'][14]['Count'], '1412839')
        self.assertEqual(record['TranslationStack'][14]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][15], 'AND')
        self.assertEqual(record['QueryTranslation'], '("stem cells"[MeSH Terms] OR stem cells[Acknowledgments] OR stem cells[Figure/Table Caption] OR stem cells[Section Title] OR stem cells[Body - All Words] OR stem cells[Title] OR stem cells[Abstract]) AND free fulltext[filter]')

    def test_nucleotide(self):
        '''Test parsing XML returned by ESearch from the Nucleotide database
        '''
        # Search in Nucleotide for a property of the sequence,
        # To create the XML file, use
        # >>> Bio.Entrez.esearch(db="nucleotide", term="biomol trna[prop]")
        handle = open('Entrez/esearch6.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], "699")
        self.assertEqual(record['RetMax'], "20")
        self.assertEqual(record['RetStart'], "0")
        self.assertEqual(len(record['IdList']), 20)
        self.assertEqual(record['IdList'][0], '220161')
        self.assertEqual(record['IdList'][1], '220160')
        self.assertEqual(record['IdList'][2], '220159')
        self.assertEqual(record['IdList'][3], '220263')
        self.assertEqual(record['IdList'][4], '220162')
        self.assertEqual(record['IdList'][5], '159885659')
        self.assertEqual(record['IdList'][6], '156572228')
        self.assertEqual(record['IdList'][7], '2648075')
        self.assertEqual(record['IdList'][8], '287595')
        self.assertEqual(record['IdList'][9], '402544')
        self.assertEqual(record['IdList'][10], '402506')
        self.assertEqual(record['IdList'][11], '402505')
        self.assertEqual(record['IdList'][12], '287594')
        self.assertEqual(record['IdList'][13], '287593')
        self.assertEqual(record['IdList'][14], '287592')
        self.assertEqual(record['IdList'][15], '287591')
        self.assertEqual(record['IdList'][16], '287590')
        self.assertEqual(record['IdList'][17], '287589')
        self.assertEqual(record['IdList'][18], '287588')
        self.assertEqual(record['IdList'][19], '287587')
        self.assertEqual(len(record['TranslationSet']), 0)
        self.assertEqual(record['QueryTranslation'], '')

    def test_protein(self):
        '''Test parsing XML returned by ESearch from the Protein database
        '''
        # Search in Protein for a molecular weight
        # To create the XML file, use
        # >>> Bio.Entrez.esearch(db="protein", term="200020[molecular weight]")
        handle = open('Entrez/esearch7.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], '3')
        self.assertEqual(record['RetMax'], '3')
        self.assertEqual(record['RetStart'], '0')
        self.assertEqual(len(record['IdList']), 3)
        self.assertEqual(record['IdList'][0], '16766766')
        self.assertEqual(record['IdList'][1], '16422035')
        self.assertEqual(record['IdList'][2], '4104812')
        self.assertEqual(len(record['TranslationSet']), 0)
        self.assertEqual(len(record['TranslationStack']), 2)
        self.assertEqual(record['TranslationStack'][0]['Term'], '000200020[molecular weight]')
        self.assertEqual(record['TranslationStack'][0]['Field'], 'molecular weight')
        self.assertEqual(record['TranslationStack'][0]['Count'], '3')
        self.assertEqual(record['TranslationStack'][0]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][1], 'GROUP')
        self.assertEqual(record['QueryTranslation'], '000200020[molecular weight]')

    def test_notfound(self):
        '''Test parsing XML returned by ESearch when no items were found
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.esearch(db="protein", term="abcXYZ")
        handle = open('Entrez/esearch8.xml')
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], '3')
        self.assertEqual(record['RetMax'], '3')
        self.assertEqual(record['RetStart'], '0')
        self.assertEqual(len(record['IdList']), 3)
        self.assertEqual(record['IdList'][0], '16766766')
        self.assertEqual(record['IdList'][1], '16422035')
        self.assertEqual(record['IdList'][2], '4104812')
        self.assertEqual(len(record['TranslationSet']), 0)
        self.assertEqual(len(record['TranslationStack']), 2)
        self.assertEqual(record['TranslationStack'][0]['Term'], '000200020[molecular weight]')
        self.assertEqual(record['TranslationStack'][0]['Field'], 'molecular weight')
        self.assertEqual(record['TranslationStack'][0]['Count'], '3')
        self.assertEqual(record['TranslationStack'][0]['Explode'], 'Y')
        self.assertEqual(record['TranslationStack'][1], 'GROUP')
        self.assertEqual(record['QueryTranslation'], '000200020[molecular weight]')

    def test_notfound(self):
        '''Test parsing XML returned by ESearch when no items were found
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.esearch(db="protein", term="abcXYZ")
        handle = open('Entrez/esearch8.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record['Count'], "0")
        self.assertEqual(record['RetMax'], "0")
        self.assertEqual(record['RetStart'], "0")
        self.assertEqual(len(record['IdList']), 0)
        self.assertEqual(len(record['TranslationSet']), 0)
        self.assertEqual(record['QueryTranslation'], '')
        self.assertEqual(len(record['ErrorList']), 2)
        self.assertTrue("PhraseNotFound" in record['ErrorList'])
        self.assertTrue("FieldNotFound" in record['ErrorList'])
        self.assertEqual(len(record['ErrorList']["PhraseNotFound"]), 1)
        self.assertEqual(len(record['ErrorList']["FieldNotFound"]), 0)
        self.assertEqual(record['ErrorList']["PhraseNotFound"][0], "abcXYZ")
        self.assertEqual(len(record['WarningList']), 3)
        self.assertTrue("PhraseIgnored" in record['WarningList'])
        self.assertTrue("QuotedPhraseNotFound" in record['WarningList'])
        self.assertTrue("OutputMessage" in record['WarningList'])
        self.assertEqual(len(record['WarningList']["PhraseIgnored"]), 0)
        self.assertEqual(len(record['WarningList']["QuotedPhraseNotFound"]), 0)
        self.assertEqual(len(record['WarningList']["OutputMessage"]), 1)
        self.assertEqual(record['WarningList']["OutputMessage"][0], "No items found.")


class EPostTest(unittest.TestCase):
    '''Tests for parsing XML output returned by EPost
    '''
    # Don't know how to get an InvalidIdList in the XML returned by EPost;
    # unable to test if we are parsing it correctly.
    def test_epost(self):
        '''Test parsing XML returned by EPost
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.epost(db="pubmed", id="11237011")
        handle = open('Entrez/epost1.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record["QueryKey"], '1')
        self.assertEqual(record["WebEnv"], '0zYsuLk3zG_lRMkblPBEqnT8nIENUGw4HAy8xXChTnoVm7GEnWY71jv3nz@1FC077F3806DE010_0042SID')

    def test_wrong(self):
        '''Test parsing XML returned by EPost with incorrect arguments
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.epost(db="nothing")
        handle = open('Entrez/epost2.xml', "rb")
        self.assertRaises(RuntimeError, Entrez.read, handle)
        handle.close()

    def test_invalid(self):
        '''Test parsing XML returned by EPost with an invalid id (overflow tag)
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.epost(db="pubmed", id=99999999999999999999999999999999)
        handle = open('Entrez/epost3.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record["InvalidIdList"], ["-1"])
        self.assertEqual(record["QueryKey"], "1")
        self.assertEqual(record["WebEnv"], "08AIUeBsfIk6BfdzKnd3GM2RtCudczC9jm5aeb4US0o7azCTQCeCsr-xg0@1EDE54E680D03C40_0011SID")


class ESummaryTest(unittest.TestCase):
    '''Tests for parsing XML output returned by ESummary
    '''
    # Items have a type, which can be
    # (Integer|Date|String|Structure|List|Flags|Qualifier|Enumerator|Unknown)
    # I don't have an XML file where the type "Flags", "Qualifier",
    # "Enumerator", or "Unknown" is used, so they are not tested here.
    def test_pubmed(self):
        '''Test parsing XML returned by ESummary from PubMed
        '''
        # In PubMed display records for PMIDs 11850928 and 11482001 in
        # xml retrieval mode
        # To create the XML file, use
        # >>> Bio.Entrez.esummary(db="pubmed", id=["11850928","11482001"],
        #                         retmode="xml")
        handle = open('Entrez/esummary1.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["Id"], "11850928")
        self.assertEqual(record[0]["PubDate"], "1965 Aug")
        self.assertEqual(record[0]["EPubDate"], "")
        self.assertEqual(record[0]["Source"], "Arch Dermatol")
        self.assertEqual(len(record[0]["AuthorList"]), 2)
        self.assertEqual(record[0]["AuthorList"][0], "LoPresti PJ")
        self.assertEqual(record[0]["AuthorList"][1], "Hambrick GW Jr")
        self.assertEqual(record[0]["LastAuthor"], "Hambrick GW Jr")
        self.assertEqual(record[0]["Title"], "Zirconium granuloma following treatment of rhus dermatitis.")
        self.assertEqual(record[0]["Volume"], "92")
        self.assertEqual(record[0]["Issue"], "2")
        self.assertEqual(record[0]["Pages"], "188-91")
        self.assertEqual(record[0]["LangList"], ["English"])
        self.assertEqual(record[0]["NlmUniqueID"], "0372433")
        self.assertEqual(record[0]["ISSN"], "0003-987X")
        self.assertEqual(record[0]["ESSN"], "1538-3652")
        self.assertEqual(len(record[0]["PubTypeList"]), 1)
        self.assertEqual(record[0]["PubTypeList"][0], "Journal Article")
        self.assertEqual(record[0]["RecordStatus"], "PubMed - indexed for MEDLINE")
        self.assertEqual(record[0]["PubStatus"], "ppublish")
        self.assertEqual(len(record[0]["ArticleIds"]), 2)
        self.assertEqual(record[0]["ArticleIds"]["pubmed"], ["11850928"])
        self.assertEqual(record[0]["ArticleIds"]["medline"], [])
        self.assertEqual(len(record[0]["History"]), 2)
        self.assertEqual(record[0]["History"]["pubmed"], ["1965/08/01 00:00"])
        self.assertEqual(record[0]["History"]["medline"], ["2002/03/09 10:01"])
        self.assertEqual(len(record[0]["References"]), 0)
        self.assertEqual(record[0]["HasAbstract"], 1)
        self.assertEqual(record[0]["PmcRefCount"], 0)
        self.assertEqual(record[0]["FullJournalName"], "Archives of dermatology")
        self.assertEqual(record[0]["ELocationID"], "")
        self.assertEqual(record[0]["SO"], "1965 Aug;92(2):188-91")

        self.assertEqual(record[1]["Id"], "11482001")
        self.assertEqual(record[1]["PubDate"], "2001 Jun")
        self.assertEqual(record[1]["EPubDate"], "")
        self.assertEqual(record[1]["Source"], "Adverse Drug React Toxicol Rev")
        self.assertEqual(len(record[1]["AuthorList"]), 3)
        self.assertEqual(record[1]["AuthorList"][0], "Mantle D")
        self.assertEqual(record[1]["AuthorList"][1], "Gok MA")
        self.assertEqual(record[1]["AuthorList"][2], "Lennard TW")
        self.assertEqual(record[1]["LastAuthor"], "Lennard TW")
        self.assertEqual(record[1]["Title"], "Adverse and beneficial effects of plant extracts on skin and skin disorders.")
        self.assertEqual(record[1]["Volume"], "20")
        self.assertEqual(record[1]["Issue"], "2")
        self.assertEqual(record[1]["Pages"], "89-103")
        self.assertEqual(len(record[1]["LangList"]), 1)
        self.assertEqual(record[1]["LangList"][0], "English")
        self.assertEqual(record[1]["NlmUniqueID"], "9109474")
        self.assertEqual(record[1]["ISSN"], "0964-198X")
        self.assertEqual(record[1]["ESSN"], "")
        self.assertEqual(len(record[1]["PubTypeList"]), 2)
        self.assertEqual(record[1]["PubTypeList"][0], "Journal Article")
        self.assertEqual(record[1]["PubTypeList"][1], "Review")
        self.assertEqual(record[1]["RecordStatus"], "PubMed - indexed for MEDLINE")
        self.assertEqual(record[1]["PubStatus"], "ppublish")
        self.assertEqual(len(record[1]["ArticleIds"]), 2)
        self.assertEqual(record[1]["ArticleIds"]["pubmed"], ["11482001"])
        self.assertEqual(record[1]["ArticleIds"]["medline"], [])
        self.assertEqual(len(record[1]["History"]), 2)
        self.assertEqual(record[1]["History"]["pubmed"], ["2001/08/03 10:00"])
        self.assertEqual(record[1]["History"]["medline"], ["2002/01/23 10:01"])
        self.assertEqual(len(record[1]["References"]), 0)
        self.assertEqual(record[1]["HasAbstract"], 1)
        self.assertEqual(record[1]["PmcRefCount"], 0)
        self.assertEqual(record[1]["FullJournalName"], "Adverse drug reactions and toxicological reviews")
        self.assertEqual(record[1]["ELocationID"], "")
        self.assertEqual(record[1]["SO"], "2001 Jun;20(2):89-103")

    def test_journals(self):
        '''Test parsing XML returned by ESummary from the Journals database
        '''
        # In Journals display records for journal IDs 27731,439,735,905
        # To create the XML file, use
        # >>> Bio.Entrez.esummary(db="journals", id="27731,439,735,905")
        handle = open('Entrez/esummary2.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["Id"], "27731")
        self.assertEqual(record[0]["Title"], "The American journal of obstetrics and diseases of women and children")
        self.assertEqual(record[0]["MedAbbr"], "Am J Obstet Dis Women Child")
        self.assertEqual(record[0]["IsoAbbr"], "")
        self.assertEqual(record[0]["NlmId"], "14820330R")
        self.assertEqual(record[0]["pISSN"], "0894-5543")
        self.assertEqual(record[0]["eISSN"], "")
        self.assertEqual(record[0]["PublicationStartYear"], "1868")
        self.assertEqual(record[0]["PublicationEndYear"], "1919")
        self.assertEqual(record[0]["Publisher"], "W.A. Townsend & Adams, $c [1868-1919]")
        self.assertEqual(record[0]["Language"], "eng")
        self.assertEqual(record[0]["Country"], "United States")
        self.assertEqual(len(record[0]["BroadHeading"]), 0)
        self.assertEqual(record[0]["ContinuationNotes"], "")

        self.assertEqual(record[1]["Id"], "439")
        self.assertEqual(record[1]["Title"], "American journal of obstetrics and gynecology")
        self.assertEqual(record[1]["MedAbbr"], "Am J Obstet Gynecol")
        self.assertEqual(record[1]["IsoAbbr"], "Am. J. Obstet. Gynecol.")
        self.assertEqual(record[1]["NlmId"], "0370476")
        self.assertEqual(record[1]["pISSN"], "0002-9378")
        self.assertEqual(record[1]["eISSN"], "1097-6868")
        self.assertEqual(record[1]["PublicationStartYear"], "1920")
        self.assertEqual(record[1]["PublicationEndYear"], "")
        self.assertEqual(record[1]["Publisher"], "Elsevier,")
        self.assertEqual(record[1]["Language"], "eng")
        self.assertEqual(record[1]["Country"], "United States")
        self.assertEqual(len(record[1]["BroadHeading"]), 2)
        self.assertEqual(record[1]["BroadHeading"][0], "Gynecology")
        self.assertEqual(record[1]["BroadHeading"][1], "Obstetrics")
        self.assertEqual(record[1]["ContinuationNotes"], "Continues: American journal of obstetrics and diseases of women and children. ")

        self.assertEqual(record[2]["Id"], "735")
        self.assertEqual(record[2]["Title"], "Archives of gynecology and obstetrics")
        self.assertEqual(record[2]["MedAbbr"], "Arch Gynecol Obstet")
        self.assertEqual(record[2]["IsoAbbr"], "Arch. Gynecol. Obstet.")
        self.assertEqual(record[2]["NlmId"], "8710213")
        self.assertEqual(record[2]["pISSN"], "0932-0067")
        self.assertEqual(record[2]["eISSN"], "1432-0711")
        self.assertEqual(record[2]["PublicationStartYear"], "1987")
        self.assertEqual(record[2]["PublicationEndYear"], "")
        self.assertEqual(record[2]["Publisher"], "Springer Verlag")
        self.assertEqual(record[2]["Language"], "eng")
        self.assertEqual(record[2]["Country"], "Germany")
        self.assertEqual(len(record[2]["BroadHeading"]), 2)
        self.assertEqual(record[2]["BroadHeading"][0], "Gynecology")
        self.assertEqual(record[2]["BroadHeading"][1], "Obstetrics")
        self.assertEqual(record[2]["ContinuationNotes"], "Continues: Archives of gynecology. ")

        self.assertEqual(record[3]["Id"], "905")
        self.assertEqual(record[3]["Title"], "Asia-Oceania journal of obstetrics and gynaecology / AOFOG")
        self.assertEqual(record[3]["MedAbbr"], "Asia Oceania J Obstet Gynaecol")
        self.assertEqual(record[3]["IsoAbbr"], "")
        self.assertEqual(record[3]["NlmId"], "8102781")
        self.assertEqual(record[3]["pISSN"], "0389-2328")
        self.assertEqual(record[3]["eISSN"], "")
        self.assertEqual(record[3]["PublicationStartYear"], "1980")
        self.assertEqual(record[3]["PublicationEndYear"], "1994")
        self.assertEqual(record[3]["Publisher"], "University Of Tokyo Press")
        self.assertEqual(record[3]["Language"], "eng")
        self.assertEqual(record[3]["Country"], "Japan")
        self.assertEqual(len(record[3]["BroadHeading"]), 2)
        self.assertEqual(record[3]["BroadHeading"][0], "Gynecology")
        self.assertEqual(record[3]["BroadHeading"][1], "Obstetrics")
        self.assertEqual(record[3]["ContinuationNotes"], "Continues: Journal of the Asian Federation of Obstetrics and Gynaecology. Continued by: Journal of obstetrics and gynaecology (Tokyo, Japan). ")

    def test_protein(self):
        '''Test parsing XML returned by ESummary from the Protein database
        '''
        # In Protein display records for GIs 28800982 and 28628843 in xml retrieval mode
        # To create the XML file, use
        # >>> Bio.Entrez.esummary(db="protein", id="28800982,28628843", retmode="xml")
        handle = open('Entrez/esummary3.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["Id"], "28800982")
        self.assertEqual(record[0]["Caption"], "AAO47091")
        self.assertEqual(record[0]["Title"], "hemochromatosis [Homo sapiens]")
        self.assertEqual(record[0]["Extra"], "gi|28800982|gb|AAO47091.1|[28800982]")
        self.assertEqual(record[0]["Gi"], 28800982)
        self.assertEqual(record[0]["CreateDate"], "2003/03/03")
        self.assertEqual(record[0]["UpdateDate"], "2003/03/03")
        self.assertEqual(record[0]["Flags"], 0)
        self.assertEqual(record[0]["TaxId"], 9606)
        self.assertEqual(record[0]["Length"], 268)
        self.assertEqual(record[0]["Status"], "live")
        self.assertEqual(record[0]["ReplacedBy"], "")
        self.assertEqual(record[0]["Comment"], "  ")

        self.assertEqual(record[1]["Id"], "28628843")
        self.assertEqual(record[1]["Caption"], "AAO49381")
        self.assertEqual(record[1]["Title"], "erythroid associated factor [Homo sapiens]")
        self.assertEqual(record[1]["Extra"], "gi|28628843|gb|AAO49381.1|AF485325_1[28628843]")
        self.assertEqual(record[1]["Gi"], 28628843)
        self.assertEqual(record[1]["CreateDate"], "2003/03/02")
        self.assertEqual(record[1]["UpdateDate"], "2003/03/02")
        self.assertEqual(record[1]["Flags"], 0)
        self.assertEqual(record[1]["TaxId"], 9606)
        self.assertEqual(record[1]["Length"], 102)
        self.assertEqual(record[1]["Status"], "live")
        self.assertEqual(record[1]["ReplacedBy"], "")
        self.assertEqual(record[1]["Comment"], "  ")

    def test_nucleotide(self):
        '''Test parsing XML returned by ESummary from the Nucleotide database
        '''
        # In Nucleotide display records for GIs 28864546 and 28800981
        # in xml retrieval mode
        # To create the XML file, use
        # >>> Bio.Entrez.esummary(db="nucleotide", id="28864546,28800981",
        #                         retmode="xml")
        handle = open('Entrez/esummary4.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["Id"], "28864546")
        self.assertEqual(record[0]["Caption"], "AY207443")
        self.assertEqual(record[0]["Title"], "Homo sapiens alpha hemoglobin (HBZP) pseudogene 3' UTR/AluJo repeat breakpoint junction")
        self.assertEqual(record[0]["Extra"], "gi|28864546|gb|AY207443.1|[28864546]")
        self.assertEqual(record[0]["Gi"], 28864546)
        self.assertEqual(record[0]["CreateDate"], "2003/03/05")
        self.assertEqual(record[0]["UpdateDate"], "2003/03/05")
        self.assertEqual(record[0]["Flags"], 0)
        self.assertEqual(record[0]["TaxId"], 9606)
        self.assertEqual(record[0]["Length"], 491)
        self.assertEqual(record[0]["Status"], "live")
        self.assertEqual(record[0]["ReplacedBy"], "")
        self.assertEqual(record[0]["Comment"], "  ")

        self.assertEqual(record[1]["Id"], "28800981")
        self.assertEqual(record[1]["Caption"], "AY205604")
        self.assertEqual(record[1]["Title"], "Homo sapiens hemochromatosis (HFE) mRNA, partial cds")
        self.assertEqual(record[1]["Extra"], "gi|28800981|gb|AY205604.1|[28800981]")
        self.assertEqual(record[1]["Gi"], 28800981)
        self.assertEqual(record[1]["CreateDate"], "2003/03/03")
        self.assertEqual(record[1]["UpdateDate"], "2003/03/03")
        self.assertEqual(record[1]["Flags"], 0)
        self.assertEqual(record[1]["TaxId"], 9606)
        self.assertEqual(record[1]["Length"], 860)
        self.assertEqual(record[1]["Status"], "live")
        self.assertEqual(record[1]["ReplacedBy"], "")
        self.assertEqual(record[1]["Comment"], "  ")

    def test_structure(self):
        '''Test parsing XML returned by ESummary from the Structure database
        '''
        # In Nucleotide display records for GIs 28864546 and 28800981
        # in xml retrieval mode
        # To create the XML file, use
        # >>> Bio.Entrez.esummary(db="structure", id=["19923","12120"],
        #                         retmode="xml")
        handle = open('Entrez/esummary5.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["Id"], "19923")
        self.assertEqual(record[0]["PdbAcc"], "1L5J")
        self.assertEqual(record[0]["PdbDescr"], "Crystal Structure Of E. Coli Aconitase B")
        self.assertEqual(record[0]["EC"], "4.2.1.3")
        self.assertEqual(record[0]["Resolution"], "2.4")
        self.assertEqual(record[0]["ExpMethod"], "X-Ray Diffraction")
        self.assertEqual(record[0]["PdbClass"], "Lyase")
        self.assertEqual(record[0]["PdbReleaseDate"], "2007/8/27")
        self.assertEqual(record[0]["PdbDepositDate"], "2002/3/7")
        self.assertEqual(record[0]["DepositDate"], "2007/10/25")
        self.assertEqual(record[0]["ModifyDate"], "2007/10/25")
        self.assertEqual(record[0]["LigCode"], "F3S|TRA")
        self.assertEqual(record[0]["LigCount"], "2")
        self.assertEqual(record[0]["ModProteinResCount"], "0")
        self.assertEqual(record[0]["ModDNAResCount"], "0")
        self.assertEqual(record[0]["ModRNAResCount"], "0")
        self.assertEqual(record[0]["ProteinChainCount"], "2")
        self.assertEqual(record[0]["DNAChainCount"], "0")
        self.assertEqual(record[0]["RNAChainCount"], "0")

        self.assertEqual(record[1]["Id"], "12120")
        self.assertEqual(record[1]["PdbAcc"], "1B0K")
        self.assertEqual(record[1]["PdbDescr"], "S642a:fluorocitrate Complex Of Aconitase")
        self.assertEqual(record[1]["EC"], "4.2.1.3")
        self.assertEqual(record[1]["Resolution"], "2.5")
        self.assertEqual(record[1]["ExpMethod"], "X-Ray Diffraction")
        self.assertEqual(record[1]["PdbClass"], "Lyase")
        self.assertEqual(record[1]["PdbReleaseDate"], "2007/8/27")
        self.assertEqual(record[1]["PdbDepositDate"], "1998/11/11")
        self.assertEqual(record[1]["DepositDate"], "2007/10/07")
        self.assertEqual(record[1]["ModifyDate"], "2007/10/07")
        self.assertEqual(record[1]["LigCode"], "FLC|O|SF4")
        self.assertEqual(record[1]["LigCount"], "3")
        self.assertEqual(record[1]["ModProteinResCount"], "0")
        self.assertEqual(record[1]["ModDNAResCount"], "0")
        self.assertEqual(record[1]["ModRNAResCount"], "0")
        self.assertEqual(record[1]["ProteinChainCount"], "1")
        self.assertEqual(record[1]["DNAChainCount"], "0")
        self.assertEqual(record[1]["RNAChainCount"], "0")

    def test_taxonomy(self):
        '''Test parsing XML returned by ESummary from the Taxonomy database
        '''
        # In Taxonomy display records for TAXIDs 9913 and 30521 in
        # xml retrieval mode
        # To create the XML file, use
        # >>> Bio.Entrez.esummary(db="taxonomy", id=["9913","30521"],
        #                         retmode="xml")
        handle = open('Entrez/esummary6.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["Id"], "9913")
        self.assertEqual(record[0]["Rank"], "species")
        self.assertEqual(record[0]["Division"], "even-toed ungulates")
        self.assertEqual(record[0]["ScientificName"], "Bos taurus")
        self.assertEqual(record[0]["CommonName"], "cattle")
        self.assertEqual(record[0]["TaxId"], 9913)
        self.assertEqual(record[0]["NucNumber"], 2264214)
        self.assertEqual(record[0]["ProtNumber"], 55850)
        self.assertEqual(record[0]["StructNumber"], 1517)
        self.assertEqual(record[0]["GenNumber"], 31)
        self.assertEqual(record[0]["GeneNumber"], 29651)
        self.assertEqual(record[0]["Genus"], "")
        self.assertEqual(record[0]["Species"], "")
        self.assertEqual(record[0]["Subsp"], "")

        self.assertEqual(record[1]["Id"], "30521")
        self.assertEqual(record[1]["Rank"], "species")
        self.assertEqual(record[1]["Division"], "even-toed ungulates")
        self.assertEqual(record[1]["ScientificName"], "Bos grunniens")
        self.assertEqual(record[1]["CommonName"], "domestic yak")
        self.assertEqual(record[1]["TaxId"], 30521)
        self.assertEqual(record[1]["NucNumber"], 560)
        self.assertEqual(record[1]["ProtNumber"], 254)
        self.assertEqual(record[1]["StructNumber"], 0)
        self.assertEqual(record[1]["GenNumber"], 1)
        self.assertEqual(record[1]["GeneNumber"], 13)
        self.assertEqual(record[1]["Genus"], "")
        self.assertEqual(record[1]["Species"], "")
        self.assertEqual(record[1]["Subsp"], "")

    def test_unists(self):
        '''Test parsing XML returned by ESummary from the UniSTS database
        '''
        # In UniSTS display records for IDs 254085 and 254086 in xml
        # retrieval mode
        # To create the XML file, use
        # >>> Bio.Entrez.esummary(db="unists", id=["254085","254086"],
        #                         retmode="xml")
        handle = open('Entrez/esummary7.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["Id"], "254085")
        self.assertEqual(record[0]["Marker_Name"], "SE234324")
        self.assertEqual(len(record[0]["Map_Gene_Summary_List"]), 1)
        self.assertEqual(record[0]["Map_Gene_Summary_List"][0]["Org"], "Sus scrofa")
        self.assertEqual(record[0]["Map_Gene_Summary_List"][0]["Chr"], " chromosome 7")
        self.assertEqual(record[0]["Map_Gene_Summary_List"][0]["Locus"], "")
        self.assertEqual(record[0]["EPCR_Summary"], "Found by e-PCR in sequences from Sus scrofa.")
        self.assertEqual(record[0]["LocusId"], "")

        self.assertEqual(record[1]["Id"], "254086")
        self.assertEqual(record[1]["Marker_Name"], "SE259162")
        self.assertEqual(len(record[1]["Map_Gene_Summary_List"]), 1)
        self.assertEqual(record[1]["Map_Gene_Summary_List"][0]["Org"], "Sus scrofa")
        self.assertEqual(record[1]["Map_Gene_Summary_List"][0]["Chr"], " chromosome 12")
        self.assertEqual(record[1]["Map_Gene_Summary_List"][0]["Locus"], "")
        self.assertEqual(record[1]["EPCR_Summary"], "Found by e-PCR in sequences from Sus scrofa.")
        self.assertEqual(record[1]["LocusId"], "")

    def test_wrong(self):
        '''Test parsing XML returned by ESummary with incorrect arguments
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.esummary()
        handle = open('Entrez/esummary8.xml', "rb")
        self.assertRaises(RuntimeError, Entrez.read, handle)
        handle.close()


class ELinkTest(unittest.TestCase):
    '''Tests for parsing XML output returned by ELink
    '''
    def test_pubmed1(self):
        '''Test parsing pubmed links returned by ELink (first test)
        '''
        # Retrieve IDs from PubMed for PMID 9298984 to the PubMed database
        # To create the XML file, use
        # >>> Bio.Entrez.elink(dbfrom="pubmed", id="9298984", cmd="neighbor")
        handle = open('Entrez/elink1.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(len(record), 1)
        self.assertEqual(len(record[0]), 5)
        self.assertEqual(record[0]["DbFrom"], "pubmed")
        self.assertEqual(record[0]["IdList"], ["9298984"])
        self.assertEqual(len(record[0]["LinkSetDb"]), 8)
        self.assertEqual(record[0]["LinkSetDb"][0]["DbTo"], "pubmed")
        self.assertEqual(record[0]["LinkSetDb"][0]["LinkName"], "pubmed_pubmed")
        self.assertEqual(len(record[0]["LinkSetDb"][0]["Link"]), 97)
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][0]["Id"], "9298984")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][1]["Id"], "8794856")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][2]["Id"], "9700164")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][3]["Id"], "7914521")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][4]["Id"], "9914369")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][5]["Id"], "1339459")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][6]["Id"], "11590237")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][7]["Id"], "12686595")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][8]["Id"], "20980244")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][9]["Id"], "11146659")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][10]["Id"], "8978614")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][11]["Id"], "9074495")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][12]["Id"], "10893249")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][13]["Id"], "2211822")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][14]["Id"], "15371539")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][15]["Id"], "10402457")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][16]["Id"], "10806105")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][17]["Id"], "10545493")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][18]["Id"], "15915585")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][19]["Id"], "10523511")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][20]["Id"], "12515822")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][21]["Id"], "9869638")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][22]["Id"], "11483958")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][23]["Id"], "11685532")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][24]["Id"], "9490715")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][25]["Id"], "1691829")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][26]["Id"], "9425896")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][27]["Id"], "12080088")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][28]["Id"], "12034769")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][29]["Id"], "9852156")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][30]["Id"], "8923204")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][31]["Id"], "7690762")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][32]["Id"], "17895365")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][33]["Id"], "9378750")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][34]["Id"], "11146661")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][35]["Id"], "18202360")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][36]["Id"], "10985388")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][37]["Id"], "11266459")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][38]["Id"], "2022189")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][39]["Id"], "8056842")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][40]["Id"], "11914278")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][41]["Id"], "15616189")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][42]["Id"], "18936247")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][43]["Id"], "17222555")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][44]["Id"], "7585942")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][45]["Id"], "9735366")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][46]["Id"], "11179694")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][47]["Id"], "21118145")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][48]["Id"], "16732327")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][49]["Id"], "14522947")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][50]["Id"], "11352945")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][51]["Id"], "16839185")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][52]["Id"], "11267866")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][53]["Id"], "10898791")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][54]["Id"], "12388768")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][55]["Id"], "16741559")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][56]["Id"], "11252055")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][57]["Id"], "7904902")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][58]["Id"], "17182852")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][59]["Id"], "9606208")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][60]["Id"], "15268859")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][61]["Id"], "18460473")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][62]["Id"], "11266451")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][63]["Id"], "10398680")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][64]["Id"], "16516834")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][65]["Id"], "12235289")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][66]["Id"], "16585270")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][67]["Id"], "1541637")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][68]["Id"], "18923084")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][69]["Id"], "16510521")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][70]["Id"], "8175879")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][71]["Id"], "11715021")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][72]["Id"], "8548823")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][73]["Id"], "15485811")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][74]["Id"], "11092768")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][75]["Id"], "7790358")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][76]["Id"], "11102811")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][77]["Id"], "15824131")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][78]["Id"], "16802858")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][79]["Id"], "17333235")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][80]["Id"], "9258677")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][81]["Id"], "17525528")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][82]["Id"], "9396743")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][83]["Id"], "12514103")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][84]["Id"], "16219694")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][85]["Id"], "10428958")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][86]["Id"], "14699129")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][87]["Id"], "2211824")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][88]["Id"], "11369198")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][89]["Id"], "15075237")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][90]["Id"], "14972679")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][91]["Id"], "7730407")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][92]["Id"], "9009204")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][93]["Id"], "11402064")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][94]["Id"], "22685323")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][95]["Id"], "24038651")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][96]["Id"], "23746972")
        self.assertEqual(record[0]["LinkSetDb"][1]["Link"][0]["Id"], "9298984")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][0]["Id"], "20439434")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][1]["Id"], "19273145")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][2]["Id"], "19177000")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][3]["Id"], "18936247")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][4]["Id"], "18268100")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][5]["Id"], "17699596")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][6]["Id"], "16563186")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][7]["Id"], "16505164")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][8]["Id"], "16107559")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][9]["Id"], "15824131")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][10]["Id"], "15029241")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][11]["Id"], "12686595")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][12]["Id"], "11756470")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][13]["Id"], "11553716")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][14]["Id"], "11500386")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][15]["Id"], "11402076")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][16]["Id"], "11331754")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][17]["Id"], "10545493")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][18]["Id"], "10402457")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][19]["Id"], "10402425")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][20]["Id"], "9914368")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][21]["Id"], "9763420")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][22]["Id"], "9700166")
        self.assertEqual(record[0]["LinkSetDb"][2]["Link"][23]["Id"], "9700164")
        self.assertEqual(record[0]["LinkSetDb"][3]["Link"][0]["Id"], "9298984")
        self.assertEqual(record[0]["LinkSetDb"][3]["Link"][1]["Id"], "8794856")
        self.assertEqual(record[0]["LinkSetDb"][3]["Link"][2]["Id"], "9700164")
        self.assertEqual(record[0]["LinkSetDb"][3]["Link"][3]["Id"], "7914521")
        self.assertEqual(record[0]["LinkSetDb"][3]["Link"][4]["Id"], "9914369")
        self.assertEqual(record[0]["LinkSetDb"][3]["Link"][5]["Id"], "1339459")
        self.assertEqual(record[0]["LinkSetDb"][4]["Link"][0]["Id"], "9298984")
        self.assertEqual(record[0]["LinkSetDb"][4]["Link"][1]["Id"], "8794856")
        self.assertEqual(record[0]["LinkSetDb"][4]["Link"][2]["Id"], "9700164")
        self.assertEqual(record[0]["LinkSetDb"][4]["Link"][3]["Id"], "7914521")
        self.assertEqual(record[0]["LinkSetDb"][4]["Link"][4]["Id"], "9914369")
        self.assertEqual(record[0]["LinkSetDb"][4]["Link"][5]["Id"], "1339459")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][0]["Id"], "14732139")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][1]["Id"], "8909532")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][2]["Id"], "8898221")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][3]["Id"], "8824189")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][4]["Id"], "8824188")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][5]["Id"], "8794856")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][6]["Id"], "8763498")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][7]["Id"], "8706132")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][8]["Id"], "8706131")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][9]["Id"], "8647893")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][10]["Id"], "8617505")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][11]["Id"], "8560259")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][12]["Id"], "8521491")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][13]["Id"], "8505381")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][14]["Id"], "8485583")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][15]["Id"], "8416984")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][16]["Id"], "8267981")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][17]["Id"], "8143084")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][18]["Id"], "8023161")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][19]["Id"], "8005447")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][20]["Id"], "7914521")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][21]["Id"], "7906398")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][22]["Id"], "7860624")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][23]["Id"], "7854443")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][24]["Id"], "7854422")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][25]["Id"], "7846151")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][26]["Id"], "7821090")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][27]["Id"], "7758115")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][28]["Id"], "7739381")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][29]["Id"], "7704412")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][30]["Id"], "7698647")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][31]["Id"], "7664339")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][32]["Id"], "7642709")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][33]["Id"], "7642708")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][34]["Id"], "7579695")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][35]["Id"], "7542657")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][36]["Id"], "7502067")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][37]["Id"], "7172865")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][38]["Id"], "6966403")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][39]["Id"], "6793236")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][40]["Id"], "6684600")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][41]["Id"], "3928429")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][42]["Id"], "3670292")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][43]["Id"], "2686123")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][44]["Id"], "2683077")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][45]["Id"], "2512302")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][46]["Id"], "2498337")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][47]["Id"], "2195725")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][48]["Id"], "2185478")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][49]["Id"], "2139718")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][50]["Id"], "2139717")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][51]["Id"], "2022189")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][52]["Id"], "1999466")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][53]["Id"], "1684022")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][54]["Id"], "1406971")
        self.assertEqual(record[0]["LinkSetDb"][5]["Link"][55]["Id"], "1339459")
        self.assertEqual(record[0]["LinkSetDb"][6]["Link"][0]["Id"], "9298984")
        self.assertEqual(record[0]["LinkSetDb"][7]["Link"][0]["Id"], "9298984")

    def test_nucleotide(self):
        '''Test parsing Nucleotide to Protein links returned by ELink
        '''
        # Retrieve IDs from Nucleotide for GI  48819, 7140345 to Protein
        # To create the XML file, use
        # >>> Bio.Entrez.elink(dbfrom="nucleotide", db="protein",
        #                      id="48819,7140345")
        handle = open('Entrez/elink2.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(len(record), 1)
        self.assertEqual(len(record[0]), 5)
        self.assertEqual(record[0]["DbFrom"], "nuccore")
        self.assertEqual(record[0]["IdList"], ["48819", "7140345"])
        self.assertEqual(len(record[0]["LinkSetDb"]), 2)
        self.assertEqual(len(record[0]["LinkSetDb"][0]), 3)
        self.assertEqual(record[0]["LinkSetDb"][0]['DbTo'], 'protein')
        self.assertEqual(record[0]["LinkSetDb"][0]['LinkName'], 'nuccore_protein')
        self.assertEqual(len(record[0]["LinkSetDb"][0]['Link']), 1)
        self.assertEqual(record[0]["LinkSetDb"][0]['Link'][0]['Id'], '48820')
        self.assertEqual(record[0]["LinkSetDb"][1]['DbTo'], 'protein')
        self.assertEqual(record[0]["LinkSetDb"][1]['LinkName'], 'nuccore_protein_cds')
        self.assertEqual(len(record[0]["LinkSetDb"][1]['Link']), 16)
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][0]['Id'], "16950486")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][1]['Id'], "16950485")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][2]['Id'], "15145457")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][3]['Id'], "15145456")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][4]['Id'], "15145455")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][5]['Id'], "7331953")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][6]['Id'], "7331951")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][7]['Id'], "7331950")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][8]['Id'], "7331949")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][9]['Id'], "7331948")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][10]['Id'], "7331947")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][11]['Id'], "7331946")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][12]['Id'], "7331945")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][13]['Id'], "7331944")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][14]['Id'], "7331943")
        self.assertEqual(record[0]["LinkSetDb"][1]['Link'][15]['Id'], "48820")

    def test_pubmed2(self):
        '''Test parsing pubmed links returned by ELink (second test)
        '''
        # Retrieve PubMed related articles for PMIDs 11812492 11774222
        # with a publication date from 1995 to the present
        # To create the XML file, use
        # >>> Bio.Entrez.elink(dbfrom="pubmed", id="11812492,11774222",
        #                      db="pubmed", mindate="1995", datetype="pdat")
        handle = open('Entrez/elink3.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(len(record), 1)
        self.assertEqual(record[0]["DbFrom"], "pubmed")
        self.assertEqual(len(record[0]['IdList']), 2)
        self.assertEqual(record[0]['IdList'][0], "11812492")
        self.assertEqual(record[0]['IdList'][1], "11774222")
        self.assertEqual(record[0]["LinkSetDb"][0]["DbTo"], "pubmed")
        self.assertEqual(record[0]["LinkSetDb"][0]["LinkName"], "pubmed_pubmed")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][0]["Id"], "24356117")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][1]["Id"], "24304891")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][2]["Id"], "24234437")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][3]["Id"], "24200819")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][4]["Id"], "24190075")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][5]["Id"], "24185697")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][6]["Id"], "24146634")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][7]["Id"], "24144118")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][8]["Id"], "24077701")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][9]["Id"], "24071059")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][10]["Id"], "24053607")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][11]["Id"], "24044755")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][12]["Id"], "24012123")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][13]["Id"], "23960254")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][14]["Id"], "23759724")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][15]["Id"], "23733469")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][16]["Id"], "23717556")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][17]["Id"], "23593519")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][18]["Id"], "23593012")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][19]["Id"], "23525074")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][20]["Id"], "23482460")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][21]["Id"], "23475938")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][22]["Id"], "23472225")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][23]["Id"], "23324387")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][24]["Id"], "23281896")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][25]["Id"], "23262214")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][26]["Id"], "23251587")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][27]["Id"], "23213446")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][28]["Id"], "23210448")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][29]["Id"], "23193291")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][30]["Id"], "23193260")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][31]["Id"], "23077805")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][32]["Id"], "23055615")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][33]["Id"], "23049857")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][34]["Id"], "23041355")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][35]["Id"], "23028321")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][36]["Id"], "22957693")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][37]["Id"], "22919073")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][38]["Id"], "22815933")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][39]["Id"], "22737589")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][40]["Id"], "22645363")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][41]["Id"], "22583769")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][42]["Id"], "22583543")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][43]["Id"], "22530989")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][44]["Id"], "22497736")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][45]["Id"], "22398250")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][46]["Id"], "22392278")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][47]["Id"], "22369494")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][48]["Id"], "22321609")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][49]["Id"], "22281013")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][50]["Id"], "22214329")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][51]["Id"], "22140592")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][52]["Id"], "22140107")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][53]["Id"], "22098559")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][54]["Id"], "22084196")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][55]["Id"], "22072969")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][56]["Id"], "22039151")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][57]["Id"], "22032328")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][58]["Id"], "21992066")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][59]["Id"], "21966105")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][60]["Id"], "21944995")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][61]["Id"], "21827871")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][62]["Id"], "21789233")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][63]["Id"], "21782817")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][64]["Id"], "21731626")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][65]["Id"], "23508470")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][66]["Id"], "21629728")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][67]["Id"], "21606368")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][68]["Id"], "21573076")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][69]["Id"], "21523552")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][70]["Id"], "21520341")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][71]["Id"], "21367872")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][72]["Id"], "21350051")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][73]["Id"], "21324604")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][74]["Id"], "21283610")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][75]["Id"], "21154707")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][76]["Id"], "21131495")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][77]["Id"], "21097891")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][78]["Id"], "21047535")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][79]["Id"], "21037260")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][80]["Id"], "20975904")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][81]["Id"], "20946650")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][82]["Id"], "20823861")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][83]["Id"], "20730111")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][84]["Id"], "20689574")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][85]["Id"], "20672376")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][86]["Id"], "20671203")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][87]["Id"], "20670087")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][88]["Id"], "20639550")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][89]["Id"], "20624716")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][90]["Id"], "20603211")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][91]["Id"], "20597434")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][92]["Id"], "20585501")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][93]["Id"], "20543958")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][94]["Id"], "20398331")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][95]["Id"], "20375450")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][96]["Id"], "20362581")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][97]["Id"], "20083406")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][98]["Id"], "19958475")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][99]["Id"], "20047494")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][100]["Id"], "20036185")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][101]["Id"], "20034492")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][102]["Id"], "20005876")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][103]["Id"], "19954456")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][104]["Id"], "19943957")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][105]["Id"], "19806204")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][106]["Id"], "19768586")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][107]["Id"], "19728865")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][108]["Id"], "19722191")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][109]["Id"], "19620973")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][110]["Id"], "19597542")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][111]["Id"], "19507503")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][112]["Id"], "19504759")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][113]["Id"], "19389774")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][114]["Id"], "19352421")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][115]["Id"], "19342283")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][116]["Id"], "19306393")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][117]["Id"], "19238236")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][118]["Id"], "19154594")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][119]["Id"], "19114486")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][120]["Id"], "19105187")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][121]["Id"], "19073702")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][122]["Id"], "19098027")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][123]["Id"], "19063745")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][124]["Id"], "19043737")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][125]["Id"], "19025664")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][126]["Id"], "19002498")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][127]["Id"], "18981050")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][128]["Id"], "18953038")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][129]["Id"], "18952001")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][130]["Id"], "18847484")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][131]["Id"], "18801163")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][132]["Id"], "18796476")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][133]["Id"], "18713719")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][134]["Id"], "18637161")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][135]["Id"], "18629076")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][136]["Id"], "18628874")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][137]["Id"], "18562339")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][138]["Id"], "18562031")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][139]["Id"], "18550617")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][140]["Id"], "18544553")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][141]["Id"], "18539347")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][142]["Id"], "18538871")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][143]["Id"], "18492133")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][144]["Id"], "18439691")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][145]["Id"], "18386064")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][146]["Id"], "18377816")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][147]["Id"], "18307806")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][148]["Id"], "18180957")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][149]["Id"], "18073380")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][150]["Id"], "18070518")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][151]["Id"], "18064491")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][152]["Id"], "18029361")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][153]["Id"], "18027007")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][154]["Id"], "18025705")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][155]["Id"], "18025704")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][156]["Id"], "18000556")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][157]["Id"], "17988782")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][158]["Id"], "17921498")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][159]["Id"], "17885136")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][160]["Id"], "17877839")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][161]["Id"], "17761848")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][162]["Id"], "17584494")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][163]["Id"], "17562224")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][164]["Id"], "17518759")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][165]["Id"], "17470297")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][166]["Id"], "17401150")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][167]["Id"], "17400791")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][168]["Id"], "17306254")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][169]["Id"], "17254505")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][170]["Id"], "17221864")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][171]["Id"], "17202370")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][172]["Id"], "17142236")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][173]["Id"], "17135206")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][174]["Id"], "17135198")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][175]["Id"], "17135185")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][176]["Id"], "17062145")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][177]["Id"], "17059604")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][178]["Id"], "17040125")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][179]["Id"], "17038195")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][180]["Id"], "16907992")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][181]["Id"], "16874317")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][182]["Id"], "16845079")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][183]["Id"], "16818783")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][184]["Id"], "16701248")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][185]["Id"], "16697384")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][186]["Id"], "16672453")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][187]["Id"], "16616613")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][188]["Id"], "16551372")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][189]["Id"], "16423288")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][190]["Id"], "16406333")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][191]["Id"], "22485434")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][192]["Id"], "16381974")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][193]["Id"], "16381973")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][194]["Id"], "16381840")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][195]["Id"], "16351753")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][196]["Id"], "16278157")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][197]["Id"], "16269725")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][198]["Id"], "16103603")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][199]["Id"], "16085497")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][200]["Id"], "16005284")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][201]["Id"], "16002116")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][202]["Id"], "15997407")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][203]["Id"], "15984913")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][204]["Id"], "15980532")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][205]["Id"], "15977173")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][206]["Id"], "15944077")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][207]["Id"], "15839745")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][208]["Id"], "15828434")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][209]["Id"], "15827081")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][210]["Id"], "15780005")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][211]["Id"], "15774024")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][212]["Id"], "15774022")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][213]["Id"], "15710433")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][214]["Id"], "15687015")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][215]["Id"], "15643605")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][216]["Id"], "15630619")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][217]["Id"], "22469090")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][218]["Id"], "19325849")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][219]["Id"], "15608286")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][220]["Id"], "15608284")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][221]["Id"], "15608257")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][222]["Id"], "15608233")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][223]["Id"], "15608226")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][224]["Id"], "15608212")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][225]["Id"], "15546336")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][226]["Id"], "15478601")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][227]["Id"], "15474306")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][228]["Id"], "15383308")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][229]["Id"], "15383292")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][230]["Id"], "15336912")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][231]["Id"], "15322925")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][232]["Id"], "15287587")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][233]["Id"], "15270538")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][234]["Id"], "15238684")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][235]["Id"], "15215374")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][236]["Id"], "15111095")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][237]["Id"], "15037105")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][238]["Id"], "15024419")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][239]["Id"], "14998511")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][240]["Id"], "14702162")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][241]["Id"], "14695526")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][242]["Id"], "14695451")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][243]["Id"], "14681478")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][244]["Id"], "14681474")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][245]["Id"], "14681471")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][246]["Id"], "14681353")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][247]["Id"], "14681351")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][248]["Id"], "14662922")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][249]["Id"], "12886019")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][250]["Id"], "12860672")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][251]["Id"], "12856318")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][252]["Id"], "12819149")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][253]["Id"], "12816546")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][254]["Id"], "12743802")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][255]["Id"], "12701381")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][256]["Id"], "12632152")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][257]["Id"], "12625936")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][258]["Id"], "12537121")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][259]["Id"], "12467974")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][260]["Id"], "12436197")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][261]["Id"], "12435493")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][262]["Id"], "12402526")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][263]["Id"], "12387845")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][264]["Id"], "12386340")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][265]["Id"], "12372145")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][266]["Id"], "12234534")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][267]["Id"], "12208043")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][268]["Id"], "12203989")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][269]["Id"], "12203988")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][270]["Id"], "12083398")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][271]["Id"], "11988510")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][272]["Id"], "11925998")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][273]["Id"], "11908756")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][274]["Id"], "11825250")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][275]["Id"], "11812492")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][276]["Id"], "11802378")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][277]["Id"], "11791238")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][278]["Id"], "11783003")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][279]["Id"], "11774222")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][280]["Id"], "11774221")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][281]["Id"], "11758285")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][282]["Id"], "11752345")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][283]["Id"], "11741630")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][284]["Id"], "11731507")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][285]["Id"], "11668631")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][286]["Id"], "11668619")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][287]["Id"], "11516587")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][288]["Id"], "11480780")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][289]["Id"], "11472559")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][290]["Id"], "11472553")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][291]["Id"], "11462837")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][292]["Id"], "11456466")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][293]["Id"], "11446511")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][294]["Id"], "11443570")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][295]["Id"], "11414208")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][296]["Id"], "11403387")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][297]["Id"], "11384164")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][298]["Id"], "11357826")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][299]["Id"], "11355885")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][300]["Id"], "11328780")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][301]["Id"], "11279516")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][302]["Id"], "11269648")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][303]["Id"], "11240843")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][304]["Id"], "11214099")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][305]["Id"], "11197770")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][306]["Id"], "11092731")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][307]["Id"], "11038309")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][308]["Id"], "11015564")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][309]["Id"], "10963611")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][310]["Id"], "10902212")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][311]["Id"], "10899154")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][312]["Id"], "10856373")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][313]["Id"], "10851186")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][314]["Id"], "10782070")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][315]["Id"], "10770808")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][316]["Id"], "10731564")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][317]["Id"], "10637631")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][318]["Id"], "11125122")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][319]["Id"], "11125071")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][320]["Id"], "11125059")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][321]["Id"], "10612825")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][322]["Id"], "10612824")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][323]["Id"], "10612821")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][324]["Id"], "10612820")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][325]["Id"], "10592273")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][326]["Id"], "10592272")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][327]["Id"], "10592263")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][328]["Id"], "10592200")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][329]["Id"], "10592169")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][330]["Id"], "10587943")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][331]["Id"], "10587942")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][332]["Id"], "10511685")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][333]["Id"], "10511682")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][334]["Id"], "10511680")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][335]["Id"], "10484179")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][336]["Id"], "10466136")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][337]["Id"], "10466135")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][338]["Id"], "10447503")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][339]["Id"], "10407783")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][340]["Id"], "10407677")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][341]["Id"], "10407668")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][342]["Id"], "10366827")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][343]["Id"], "10359795")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][344]["Id"], "10221636")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][345]["Id"], "10092480")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][346]["Id"], "10075567")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][347]["Id"], "10066467")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][348]["Id"], "9921679")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][349]["Id"], "9847220")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][350]["Id"], "9830540")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][351]["Id"], "9775388")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][352]["Id"], "9685316")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][353]["Id"], "9625791")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][354]["Id"], "9571806")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][355]["Id"], "9455480")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][356]["Id"], "9421619")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][357]["Id"], "9274032")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][358]["Id"], "9169870")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][359]["Id"], "9047337")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][360]["Id"], "8719164")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][361]["Id"], "7729881")

    def test_medline(self):
        '''Test parsing medline indexed articles returned by ELink
        '''
        # Retrieve MEDLINE indexed only related articles for PMID 12242737
        # To create the XML file, use
        # >>> Bio.Entrez.elink(dbfrom="pubmed", id="12242737", db="pubmed",
        #                      term="medline[sb]")
        handle = open('Entrez/elink4.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(len(record), 1)
        self.assertEqual(record[0]["DbFrom"], "pubmed")
        self.assertEqual(record[0]["IdList"], ["12242737"])
        self.assertEqual(record[0]["LinkSetDb"][0]["DbTo"], "pubmed")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][0]["Id"], "23255877")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][1]["Id"], "22688104")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][2]["Id"], "22661362")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][3]["Id"], "22648258")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][4]["Id"], "22521021")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][5]["Id"], "22424988")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][6]["Id"], "22369817")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][7]["Id"], "22368911")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][8]["Id"], "22194507")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][9]["Id"], "22156652")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][10]["Id"], "22109321")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][11]["Id"], "21991829")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][12]["Id"], "21984464")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][13]["Id"], "21944608")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][14]["Id"], "21908142")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][15]["Id"], "21715237")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][16]["Id"], "21694530")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][17]["Id"], "21531047")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][18]["Id"], "21153952")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][19]["Id"], "21102533")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][20]["Id"], "20860230")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][21]["Id"], "20718377")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][22]["Id"], "20674629")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][23]["Id"], "20542260")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][24]["Id"], "20533237")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][25]["Id"], "20457774")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][26]["Id"], "20016426")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][27]["Id"], "19843737")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][28]["Id"], "19777916")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][29]["Id"], "19616724")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][30]["Id"], "19524781")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][31]["Id"], "19318006")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][32]["Id"], "19306944")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][33]["Id"], "19253206")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][34]["Id"], "19132488")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][35]["Id"], "18853843")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][36]["Id"], "18774058")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][37]["Id"], "18706783")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][38]["Id"], "18625354")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][39]["Id"], "18582671")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][40]["Id"], "18554854")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][41]["Id"], "18299362")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][42]["Id"], "18279648")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][43]["Id"], "18247070")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][44]["Id"], "18021675")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][45]["Id"], "17875143")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][46]["Id"], "17875142")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][47]["Id"], "17879696")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][48]["Id"], "17674062")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][49]["Id"], "17658095")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][50]["Id"], "17602359")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][51]["Id"], "17601500")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][52]["Id"], "17543650")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][53]["Id"], "17466477")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][54]["Id"], "17464254")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][55]["Id"], "17453494")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][56]["Id"], "17429670")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][57]["Id"], "17376366")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][58]["Id"], "17354190")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][59]["Id"], "17325998")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][60]["Id"], "17320773")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][61]["Id"], "17268692")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][62]["Id"], "17259035")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][63]["Id"], "17243036")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][64]["Id"], "17193860")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][65]["Id"], "17174054")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][66]["Id"], "17157468")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][67]["Id"], "17040637")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][68]["Id"], "16999328")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][69]["Id"], "16988291")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][70]["Id"], "16580806")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][71]["Id"], "16566645")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][72]["Id"], "16552382")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][73]["Id"], "16362812")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][74]["Id"], "16357381")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][75]["Id"], "16338316")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][76]["Id"], "16133609")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][77]["Id"], "16096604")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][78]["Id"], "15788584")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][79]["Id"], "15642291")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][80]["Id"], "15635471")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][81]["Id"], "15529836")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][82]["Id"], "15505294")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][83]["Id"], "15300544")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][84]["Id"], "15279747")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][85]["Id"], "15278705")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][86]["Id"], "15236131")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][87]["Id"], "15143223")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][88]["Id"], "15141648")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][89]["Id"], "15136027")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][90]["Id"], "15094630")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][91]["Id"], "15022983")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][92]["Id"], "15008163")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][93]["Id"], "14872380")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][94]["Id"], "14702442")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][95]["Id"], "14661668")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][96]["Id"], "14661666")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][97]["Id"], "14661663")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][98]["Id"], "14661661")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][99]["Id"], "14661306")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][100]["Id"], "14650118")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][101]["Id"], "14528718")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][102]["Id"], "12949462")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][103]["Id"], "12878072")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][104]["Id"], "12876813")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][105]["Id"], "12822521")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][106]["Id"], "12744499")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][107]["Id"], "12744498")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][108]["Id"], "12733684")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][109]["Id"], "12719915")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][110]["Id"], "12592155")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][111]["Id"], "12563154")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][112]["Id"], "12361530")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][113]["Id"], "12352163")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][114]["Id"], "12242737")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][115]["Id"], "12226761")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][116]["Id"], "12164574")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][117]["Id"], "11973504")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][118]["Id"], "11973040")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][119]["Id"], "11907356")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][120]["Id"], "11868066")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][121]["Id"], "11789473")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][122]["Id"], "11781922")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][123]["Id"], "11775722")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][124]["Id"], "11762248")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][125]["Id"], "11740602")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][126]["Id"], "11702119")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][127]["Id"], "11669077")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][128]["Id"], "11578071")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][129]["Id"], "11443295")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][130]["Id"], "11409026")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][131]["Id"], "11368937")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][132]["Id"], "11329662")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][133]["Id"], "11329658")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][134]["Id"], "11329656")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][135]["Id"], "11329655")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][136]["Id"], "11329162")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][137]["Id"], "11274884")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][138]["Id"], "11218011")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][139]["Id"], "11125632")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][140]["Id"], "11027076")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][141]["Id"], "11016058")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][142]["Id"], "10803203")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][143]["Id"], "10761553")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][144]["Id"], "10749221")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][145]["Id"], "10688065")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][146]["Id"], "10688063")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][147]["Id"], "10665303")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][148]["Id"], "10575758")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][149]["Id"], "10499712")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][150]["Id"], "10499697")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][151]["Id"], "10499696")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][152]["Id"], "10475937")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][153]["Id"], "10222521")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][154]["Id"], "10222515")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][155]["Id"], "10222514")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][156]["Id"], "10051883")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][157]["Id"], "10024396")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][158]["Id"], "9847909")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][159]["Id"], "9793138")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][160]["Id"], "9757294")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][161]["Id"], "9725288")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][162]["Id"], "9658901")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][163]["Id"], "9575723")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][164]["Id"], "9510579")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][165]["Id"], "9456947")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][166]["Id"], "9391495")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][167]["Id"], "9317094")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][168]["Id"], "9314960")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][169]["Id"], "9314959")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][170]["Id"], "9269670")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][171]["Id"], "9193407")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][172]["Id"], "9125660")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][173]["Id"], "9016217")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][174]["Id"], "8976943")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][175]["Id"], "8819381")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][176]["Id"], "8855688")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][177]["Id"], "8903064")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][178]["Id"], "8903059")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][179]["Id"], "8903058")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][180]["Id"], "8599783")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][181]["Id"], "8794574")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][182]["Id"], "7892443")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][183]["Id"], "8153333")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][184]["Id"], "8290724")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][185]["Id"], "8338105")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][186]["Id"], "1481295")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][187]["Id"], "1539132")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][188]["Id"], "2047316")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][189]["Id"], "1943587")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][190]["Id"], "2222794")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][191]["Id"], "2584497")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][192]["Id"], "3288780")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][193]["Id"], "3213296")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][194]["Id"], "4058411")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][195]["Id"], "3905087")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][196]["Id"], "6482054")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][197]["Id"], "6473764")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][198]["Id"], "6217136")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][199]["Id"], "7068417")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][200]["Id"], "7326186")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][201]["Id"], "6940010")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][202]["Id"], "7330196")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][203]["Id"], "7423836")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][204]["Id"], "7415301")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][205]["Id"], "7408592")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][206]["Id"], "531835")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][207]["Id"], "663071")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][208]["Id"], "616459")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][209]["Id"], "4818442")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][210]["Id"], "4848922")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][211]["Id"], "4808999")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][212]["Id"], "5046513")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][213]["Id"], "5512349")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][214]["Id"], "6072516")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][215]["Id"], "5594242")
        self.assertEqual(record[0]["LinkSetDb"][0]["Link"][216]["Id"], "5998281")
        self.assertEqual(record[0]["LinkSetDb"][0]["LinkName"], "pubmed_pubmed")

    def test_pubmed3(self):
        '''Test parsing pubmed link returned by ELink (third test)
        '''
        # Create a hyperlink to the first link available for PMID 10611131
        # in PubMed
        # To create the XML file, use
        # >>> Bio.Entrez.elink(dbfrom="pubmed", id="10611131", cmd="prlinks")

        handle = open('Entrez/elink5.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(len(record), 1)
        self.assertEqual(len(record[0]), 5)
        self.assertEqual(record[0]["DbFrom"], "pubmed")
        self.assertEqual(len(record[0]["LinkSetDb"]), 0)
        self.assertEqual(len(record[0]["LinkSetDbHistory"]), 0)
        self.assertEqual(len(record[0]["ERROR"]), 0)
        self.assertEqual(len(record[0]["IdUrlList"]), 2)
        self.assertEqual(len(record[0]["IdUrlList"]['FirstChars']), 0)
        self.assertEqual(len(record[0]["IdUrlList"]['IdUrlSet']), 1)

        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["Id"], "10611131")
        self.assertEqual(len(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"]), 1)
        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["Url"], "http://brain.oxfordjournals.org/cgi/pmidlookup?view=long&pmid=10611131")
        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["IconUrl"], "//www.ncbi.nlm.nih.gov/corehtml/query/egifs/http:--highwire.stanford.edu-icons-externalservices-pubmed-custom-oxfordjournals_final_free.gif")
        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["SubjectType"], ["publishers/providers"])
        self.assertEqual(len(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["Attribute"]), 3)
        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["Attribute"][0], "free resource")
        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["Attribute"][1], "full-text online")
        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["Attribute"][2], "publisher of information in url")
        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["Provider"]["Name"], "HighWire")
        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["Provider"]["NameAbbr"], "HighWire")
        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["Provider"]["Id"], "3051")
        self.assertEqual(record[0]["IdUrlList"]['IdUrlSet'][0]["ObjUrl"][0]["Provider"]["Url"], "http://highwire.stanford.edu")

    def test_pubmed4(self):
        '''Test parsing pubmed links returned by ELink (fourth test)
        '''
        # List all available links in PubMed, except for libraries, for
        # PMIDs 12085856 and 12085853
        # To create the XML file, use
        # >>> Bio.Entrez.elink(dbfrom="pubmed", id="12085856,12085853", cmd="llinks")
        handle = open('Entrez/elink6.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["DbFrom"], "pubmed")
        self.assertEqual(len(record[0]["IdUrlList"]), 2)
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["Id"], "12085856")
        self.assertEqual(len(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"]), 2)
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["Category"], ["Medical"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["Url"], "http://www.nlm.nih.gov/medlineplus/coronaryarterybypasssurgery.html")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["Attribute"], ["free resource"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["SubjectType"], ["consumer health"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["IconUrl"], "//www.ncbi.nlm.nih.gov/corehtml/query/egifs/http:--www.nlm.nih.gov-medlineplus-images-linkout_sm.gif")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["Provider"]["Name"], "MedlinePlus Health Information")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["Provider"]["NameAbbr"], "MEDPLUS")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["Provider"]["Id"], "3162")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["Provider"]["Url"], "http://medlineplus.gov/")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["Provider"]["IconUrl"], "http://www.nlm.nih.gov/medlineplus/images/linkout_sm.gif")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][0]["LinkName"], "Coronary Artery Bypass Surgery")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][1]["Category"], ["Education"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][1]["Attribute"], ["free resource"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][1]["SubjectType"], ["online tutorials/courses"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][1]["Url"], "http://symptomresearch.nih.gov/chapter_1/index.htm")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][1]["Provider"]["Name"], "New England Research Institutes Inc.")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][1]["Provider"]["NameAbbr"], "NERI")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][1]["Provider"]["Id"], "3291")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][0]["ObjUrl"][1]["Provider"]["Url"], "http://www.symptomresearch.com")
        self.assertEqual(len(record[0]["IdUrlList"]["IdUrlSet"][1]), 2)
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["Id"], "12085853")
        self.assertEqual(len(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"]), 3)
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][0]["Category"], ["Medical"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][0]["Url"], "http://www.nlm.nih.gov/medlineplus/arrhythmia.html")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][0]["IconUrl"], "//www.ncbi.nlm.nih.gov/corehtml/query/egifs/http:--www.nlm.nih.gov-medlineplus-images-linkout_sm.gif")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]['ObjUrl'][0]['Attribute'], ['free resource'])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][0]["SubjectType"], ["consumer health"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][0]["LinkName"], "Arrhythmia")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][0]["Provider"]["Name"], "MedlinePlus Health Information")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][0]["Provider"]["NameAbbr"], "MEDPLUS")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][0]["Provider"]["Id"], "3162")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][0]["Provider"]["Url"], "http://medlineplus.gov/")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][1]["Category"], ["Medical"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][1]["Attribute"], ["free resource"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][1]["Url"], "http://www.nlm.nih.gov/medlineplus/exerciseandphysicalfitness.html")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][1]["IconUrl"], "//www.ncbi.nlm.nih.gov/corehtml/query/egifs/http:--www.nlm.nih.gov-medlineplus-images-linkout_sm.gif")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][1]["LinkName"], "Exercise and Physical Fitness")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][1]["SubjectType"], ["consumer health"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][1]["Provider"]["Name"], "MedlinePlus Health Information")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][1]["Provider"]["NameAbbr"], "MEDPLUS")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][1]["Provider"]["Id"], "3162")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][1]["Provider"]["Url"], "http://medlineplus.gov/")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][2]["Category"], ["Medical"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][2]["Attribute"], ["free resource"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][2]["Url"], "http://www.nlm.nih.gov/medlineplus/pacemakersandimplantabledefibrillators.html")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][2]["IconUrl"], "//www.ncbi.nlm.nih.gov/corehtml/query/egifs/http:--www.nlm.nih.gov-medlineplus-images-linkout_sm.gif")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][2]["LinkName"], "Pacemakers and Implantable Defibrillators")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][2]["SubjectType"], ["consumer health"])
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][2]["Provider"]["Name"], "MedlinePlus Health Information")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][2]["Provider"]["NameAbbr"], "MEDPLUS")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][2]["Provider"]["Id"], "3162")
        self.assertEqual(record[0]["IdUrlList"]["IdUrlSet"][1]["ObjUrl"][2]["Provider"]["Url"], "http://medlineplus.gov/")

    def test_pubmed5(self):
        '''Test parsing pubmed links returned by ELink (fifth test)
        '''
        # List Entrez database links for PubMed PMIDs 12169658 and 11748140
        # To create the XML file, use
        # >>> Bio.Entrez.elink(dbfrom="pubmed", id="12169658,11748140",
        #                      cmd="acheck")
        handle = open('Entrez/elink7.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(len(record), 1)
        self.assertEqual(record[0]["DbFrom"], "pubmed")
        self.assertEqual(len(record[0]["IdCheckList"]), 2)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["Id"], "12169658")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"]), 19)
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][0]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][0]["DbTo"], "biosystems")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][0]["LinkName"], "pubmed_biosystems")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][0]["MenuTag"], "BioSystem Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][0]["HtmlTag"], "BioSystems")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][0]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][1]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][1]["DbTo"], "books")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][1]["LinkName"], "pubmed_books_refs")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][1]["MenuTag"], "Cited in Books")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][1]["HtmlTag"], "Cited in Books")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][1]["Priority"], "185")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][2]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][2]["DbTo"], "cdd")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][2]["LinkName"], "pubmed_cdd")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][2]["MenuTag"], "Domain Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][2]["HtmlTag"], "Domains")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][2]["Priority"], "130")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][3]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][3]["DbTo"], "gene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][3]["LinkName"], "pubmed_gene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][3]["MenuTag"], "Gene Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][3]["HtmlTag"], "Gene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][3]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][4]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][4]["DbTo"], "geoprofiles")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][4]["LinkName"], "pubmed_geoprofiles")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][4]["MenuTag"], "GEO Profile Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][4]["HtmlTag"], "GEO Profiles")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][4]["Priority"], "170")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][5]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][5]["DbTo"], "homologene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][5]["LinkName"], "pubmed_homologene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][5]["MenuTag"], "HomoloGene Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][5]["HtmlTag"], "HomoloGene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][5]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][6]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][6]["DbTo"], "medgen")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][6]["LinkName"], "pubmed_medgen")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][6]["MenuTag"], "MedGen")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][6]["HtmlTag"], "MedGen")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][6]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][7]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][7]["DbTo"], "nuccore")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][7]["LinkName"], "pubmed_nuccore")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][7]["MenuTag"], "Nucleotide Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][7]["HtmlTag"], "Nucleotide")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][7]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][8]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][8]["DbTo"], "nuccore")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][8]["LinkName"], "pubmed_nuccore_refseq")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][8]["MenuTag"], "Nucleotide (RefSeq) Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][8]["HtmlTag"], "Nucleotide (RefSeq)")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][8]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][9]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][9]["DbTo"], "nuccore")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][9]["LinkName"], "pubmed_nuccore_weighted")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][9]["MenuTag"], "Nucleotide (Weighted) Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][9]["HtmlTag"], "Nucleotide (Weighted)")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][9]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][10]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][10]["DbTo"], "pcsubstance")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][10]["LinkName"], "pubmed_pcsubstance_mesh")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][10]["MenuTag"], "Substance (MeSH Keyword)")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][10]["HtmlTag"], "Substance (MeSH Keyword)")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][10]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][11]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][11]["DbTo"], "pmc")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][11]["LinkName"], "pubmed_pmc_refs")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][11]["MenuTag"], "Cited in PMC")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][11]["HtmlTag"], "Cited in PMC")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][11]["Priority"], "180")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][12]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][12]["DbTo"], "protein")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][12]["LinkName"], "pubmed_protein")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][12]["MenuTag"], "Protein Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][12]["HtmlTag"], "Protein")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][12]["Priority"], "140")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][13]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][13]["DbTo"], "protein")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][13]["LinkName"], "pubmed_protein_refseq")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][13]["MenuTag"], "Protein (RefSeq) Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][13]["HtmlTag"], "Protein (RefSeq)")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][13]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][14]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][14]["DbTo"], "protein")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][14]["LinkName"], "pubmed_protein_weighted")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][14]["MenuTag"], "Protein (Weighted) Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][14]["HtmlTag"], "Protein (Weighted)")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][14]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][15]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][15]["DbTo"], "pubmed")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][15]["LinkName"], "pubmed_pubmed")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][15]["MenuTag"], "Related Citations")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][15]["HtmlTag"], "Related Citations")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][15]["Priority"], "1")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][16]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][16]["DbTo"], "taxonomy")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][16]["LinkName"], "pubmed_taxonomy_entrez")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][16]["MenuTag"], "Taxonomy via GenBank")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][16]["HtmlTag"], "Taxonomy via GenBank")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][16]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][17]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][17]["DbTo"], "unigene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][17]["LinkName"], "pubmed_unigene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][17]["MenuTag"], "UniGene Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][17]["HtmlTag"], "UniGene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][17]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][18]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][18]["DbTo"], "LinkOut")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][18]["LinkName"], "ExternalLink")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][18]["MenuTag"], "LinkOut")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][18]["HtmlTag"], "LinkOut")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][0]["LinkInfo"][18]["Priority"], "255")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["Id"], "11748140")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"]), 15)
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][0]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][0]["DbTo"], "biosystems")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][0]["LinkName"], "pubmed_biosystems")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][0]["MenuTag"], "BioSystem Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][0]["HtmlTag"], "BioSystems")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][0]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][1]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][1]["DbTo"], "books")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][1]["LinkName"], "pubmed_books_refs")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][1]["MenuTag"], "Cited in Books")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][1]["HtmlTag"], "Cited in Books")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][1]["Priority"], "185")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][2]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][2]["DbTo"], "gene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][2]["LinkName"], "pubmed_gene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][2]["MenuTag"], "Gene Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][2]["HtmlTag"], "Gene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][2]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][3]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][3]["DbTo"], "geoprofiles")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][3]["LinkName"], "pubmed_geoprofiles")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][3]["MenuTag"], "GEO Profile Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][3]["HtmlTag"], "GEO Profiles")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][3]["Priority"], "170")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][4]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][4]["DbTo"], "nuccore")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][4]["LinkName"], "pubmed_nuccore")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][4]["MenuTag"], "Nucleotide Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][4]["HtmlTag"], "Nucleotide")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][4]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][5]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][5]["DbTo"], "nuccore")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][5]["LinkName"], "pubmed_nuccore_refseq")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][5]["MenuTag"], "Nucleotide (RefSeq) Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][5]["HtmlTag"], "Nucleotide (RefSeq)")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][5]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][6]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][6]["DbTo"], "nuccore")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][6]["LinkName"], "pubmed_nuccore_weighted")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][6]["MenuTag"], "Nucleotide (Weighted) Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][6]["HtmlTag"], "Nucleotide (Weighted)")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][6]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][7]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][7]["DbTo"], "pmc")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][7]["LinkName"], "pubmed_pmc_refs")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][7]["MenuTag"], "Cited in PMC")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][7]["HtmlTag"], "Cited in PMC")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][7]["Priority"], "180")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][8]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][8]["DbTo"], "protein")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][8]["LinkName"], "pubmed_protein")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][8]["MenuTag"], "Protein Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][8]["HtmlTag"], "Protein")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][8]["Priority"], "140")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][9]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][9]["DbTo"], "protein")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][9]["LinkName"], "pubmed_protein_refseq")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][9]["MenuTag"], "Protein (RefSeq) Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][9]["HtmlTag"], "Protein (RefSeq)")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][9]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][10]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][10]["DbTo"], "protein")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][10]["LinkName"], "pubmed_protein_weighted")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][10]["MenuTag"], "Protein (Weighted) Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][10]["HtmlTag"], "Protein (Weighted)")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][10]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][11]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][11]["DbTo"], "pubmed")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][11]["LinkName"], "pubmed_pubmed")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][11]["MenuTag"], "Related Citations")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][11]["HtmlTag"], "Related Citations")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][11]["Priority"], "1")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][12]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][12]["DbTo"], "taxonomy")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][12]["LinkName"], "pubmed_taxonomy_entrez")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][12]["MenuTag"], "Taxonomy via GenBank")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][12]["HtmlTag"], "Taxonomy via GenBank")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][12]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][13]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][13]["DbTo"], "unigene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][13]["LinkName"], "pubmed_unigene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][13]["MenuTag"], "UniGene Links")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][13]["HtmlTag"], "UniGene")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][13]["Priority"], "128")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][14]), 5)
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][14]["DbTo"], "LinkOut")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][14]["LinkName"], "ExternalLink")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][14]["MenuTag"], "LinkOut")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][14]["HtmlTag"], "LinkOut")
        self.assertEqual(record[0]["IdCheckList"]["IdLinkSet"][1]["LinkInfo"][14]["Priority"], "255")

    def test_pubmed6(self):
        '''Test parsing pubmed links returned by ELink (sixth test)
        '''
        # Check for the existence of a Related Articles link for PMID
        # 12068369.
        # To create the XML file, use
        # >>> Bio.Entrez.elink(dbfrom="pubmed", id="12068369", cmd="ncheck")

        handle = open('Entrez/elink8.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(len(record), 1)
        self.assertEqual(record[0]["DbFrom"], "pubmed")
        self.assertEqual(len(record[0]["IdCheckList"]), 2)
        self.assertEqual(len(record[0]["IdCheckList"]["Id"]), 1)
        self.assertEqual(record[0]["IdCheckList"]["Id"][0], "12068369")
        self.assertEqual(len(record[0]["IdCheckList"]["Id"][0].attributes), 1)
        self.assertEqual(record[0]["IdCheckList"]["Id"][0].attributes["HasNeighbor"], "Y")
        self.assertEqual(len(record[0]["IdCheckList"]["IdLinkSet"]), 0)


class EGQueryTest(unittest.TestCase):
    '''Tests for parsing XML output returned by EGQuery
    '''
    def test_egquery1(self):
        '''Test parsing XML output returned by EGQuery (first test)
        '''
        # Display counts in XML for stem cells in each Entrez database
        # To create the XML file, use
        # >>> Bio.Entrez.egquery(term="stem cells")
        handle = open('Entrez/egquery1.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record["Term"], "stem cells")

        self.assertEqual(record["eGQueryResult"][0]["DbName"], "pubmed")
        self.assertEqual(record["eGQueryResult"][0]["MenuName"], "PubMed")
        self.assertEqual(record["eGQueryResult"][0]["Count"], "392")
        self.assertEqual(record["eGQueryResult"][0]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][1]["DbName"], "pmc")
        self.assertEqual(record["eGQueryResult"][1]["MenuName"], "PMC")
        self.assertEqual(record["eGQueryResult"][1]["Count"], "173")
        self.assertEqual(record["eGQueryResult"][1]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][2]["DbName"], "journals")
        self.assertEqual(record["eGQueryResult"][2]["MenuName"], "Journals")
        self.assertEqual(record["eGQueryResult"][2]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][2]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][3]["DbName"], "mesh")
        self.assertEqual(record["eGQueryResult"][3]["MenuName"], "MeSH")
        self.assertEqual(record["eGQueryResult"][3]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][3]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][4]["DbName"], "books")
        self.assertEqual(record["eGQueryResult"][4]["MenuName"], "Books")
        self.assertEqual(record["eGQueryResult"][4]["Count"], "10")
        self.assertEqual(record["eGQueryResult"][4]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][5]["DbName"], "omim")
        self.assertEqual(record["eGQueryResult"][5]["MenuName"], "OMIM")
        self.assertEqual(record["eGQueryResult"][5]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][5]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][6]["DbName"], "omia")
        self.assertEqual(record["eGQueryResult"][6]["MenuName"], "OMIA")
        self.assertEqual(record["eGQueryResult"][6]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][6]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][7]["DbName"], "ncbisearch")
        self.assertEqual(record["eGQueryResult"][7]["MenuName"], "NCBI Web Site")
        self.assertEqual(record["eGQueryResult"][7]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][7]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][8]["DbName"], "nuccore")
        self.assertEqual(record["eGQueryResult"][8]["MenuName"], "CoreNucleotide")
        self.assertEqual(record["eGQueryResult"][8]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][8]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][9]["DbName"], "nucgss")
        self.assertEqual(record["eGQueryResult"][9]["MenuName"], "GSS")
        self.assertEqual(record["eGQueryResult"][9]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][9]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][10]["DbName"], "nucest")
        self.assertEqual(record["eGQueryResult"][10]["MenuName"], "EST")
        self.assertEqual(record["eGQueryResult"][10]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][10]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][11]["DbName"], "protein")
        self.assertEqual(record["eGQueryResult"][11]["MenuName"], "Protein")
        self.assertEqual(record["eGQueryResult"][11]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][11]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][12]["DbName"], "genome")
        self.assertEqual(record["eGQueryResult"][12]["MenuName"], "Genome")
        self.assertEqual(record["eGQueryResult"][12]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][12]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][13]["DbName"], "structure")
        self.assertEqual(record["eGQueryResult"][13]["MenuName"], "Structure")
        self.assertEqual(record["eGQueryResult"][13]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][13]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][14]["DbName"], "taxonomy")
        self.assertEqual(record["eGQueryResult"][14]["MenuName"], "Taxonomy")
        self.assertEqual(record["eGQueryResult"][14]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][14]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][15]["DbName"], "snp")
        self.assertEqual(record["eGQueryResult"][15]["MenuName"], "SNP")
        self.assertEqual(record["eGQueryResult"][15]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][15]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][16]["DbName"], "gene")
        self.assertEqual(record["eGQueryResult"][16]["MenuName"], "Gene")
        self.assertEqual(record["eGQueryResult"][16]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][16]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][17]["DbName"], "unigene")
        self.assertEqual(record["eGQueryResult"][17]["MenuName"], "UniGene")
        self.assertEqual(record["eGQueryResult"][17]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][17]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][18]["DbName"], "cdd")
        self.assertEqual(record["eGQueryResult"][18]["MenuName"], "Conserved Domains")
        self.assertEqual(record["eGQueryResult"][18]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][18]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][19]["DbName"], "domains")
        self.assertEqual(record["eGQueryResult"][19]["MenuName"], "3D Domains")
        self.assertEqual(record["eGQueryResult"][19]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][19]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][20]["DbName"], "unists")
        self.assertEqual(record["eGQueryResult"][20]["MenuName"], "UniSTS")
        self.assertEqual(record["eGQueryResult"][20]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][20]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][21]["DbName"], "popset")
        self.assertEqual(record["eGQueryResult"][21]["MenuName"], "PopSet")
        self.assertEqual(record["eGQueryResult"][21]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][21]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][22]["DbName"], "geo")
        self.assertEqual(record["eGQueryResult"][22]["MenuName"], "GEO Profiles")
        self.assertEqual(record["eGQueryResult"][22]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][22]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][23]["DbName"], "gds")
        self.assertEqual(record["eGQueryResult"][23]["MenuName"], "GEO DataSets")
        self.assertEqual(record["eGQueryResult"][23]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][23]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][24]["DbName"], "homologene")
        self.assertEqual(record["eGQueryResult"][24]["MenuName"], "HomoloGene")
        self.assertEqual(record["eGQueryResult"][24]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][24]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][25]["DbName"], "cancerchromosomes")
        self.assertEqual(record["eGQueryResult"][25]["MenuName"], "CancerChromosomes")
        self.assertEqual(record["eGQueryResult"][25]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][25]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][26]["DbName"], "pccompound")
        self.assertEqual(record["eGQueryResult"][26]["MenuName"], "PubChem Compound")
        self.assertEqual(record["eGQueryResult"][26]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][26]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][27]["DbName"], "pcsubstance")
        self.assertEqual(record["eGQueryResult"][27]["MenuName"], "PubChem Substance")
        self.assertEqual(record["eGQueryResult"][27]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][27]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][28]["DbName"], "pcassay")
        self.assertEqual(record["eGQueryResult"][28]["MenuName"], "PubChem BioAssay")
        self.assertEqual(record["eGQueryResult"][28]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][28]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][29]["DbName"], "nlmcatalog")
        self.assertEqual(record["eGQueryResult"][29]["MenuName"], "NLM Catalog")
        self.assertEqual(record["eGQueryResult"][29]["Count"], "2")
        self.assertEqual(record["eGQueryResult"][29]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][30]["DbName"], "gensat")
        self.assertEqual(record["eGQueryResult"][30]["MenuName"], "GENSAT")
        self.assertEqual(record["eGQueryResult"][30]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][30]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][31]["DbName"], "probe")
        self.assertEqual(record["eGQueryResult"][31]["MenuName"], "Probe")
        self.assertEqual(record["eGQueryResult"][31]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][31]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][32]["DbName"], "genomeprj")
        self.assertEqual(record["eGQueryResult"][32]["MenuName"], "Genome Project")
        self.assertEqual(record["eGQueryResult"][32]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][32]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][33]["DbName"], "gap")
        self.assertEqual(record["eGQueryResult"][33]["MenuName"], "dbGaP")
        self.assertEqual(record["eGQueryResult"][33]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][33]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][34]["DbName"], "proteinclusters")
        self.assertEqual(record["eGQueryResult"][34]["MenuName"], "Protein Clusters")
        self.assertEqual(record["eGQueryResult"][34]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][34]["Status"], "Term or Database is not found")

    def test_egquery2(self):
        '''Test parsing XML output returned by EGQuery (second test)
        '''
        # Display counts in XML for brca1 or brca2 for each Entrez database
        # To create the XML file, use
        # >>> Bio.Entrez.egquery(term="brca1 OR brca2")
        handle = open('Entrez/egquery2.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record["Term"], "brca1 OR brca2")

        self.assertEqual(record["eGQueryResult"][0]["DbName"], "pubmed")
        self.assertEqual(record["eGQueryResult"][0]["MenuName"], "PubMed")
        self.assertEqual(record["eGQueryResult"][0]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][0]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][1]["DbName"], "pmc")
        self.assertEqual(record["eGQueryResult"][1]["MenuName"], "PMC")
        self.assertEqual(record["eGQueryResult"][1]["Count"], "2739")
        self.assertEqual(record["eGQueryResult"][1]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][2]["DbName"], "journals")
        self.assertEqual(record["eGQueryResult"][2]["MenuName"], "Journals")
        self.assertEqual(record["eGQueryResult"][2]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][2]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][3]["DbName"], "mesh")
        self.assertEqual(record["eGQueryResult"][3]["MenuName"], "MeSH")
        self.assertEqual(record["eGQueryResult"][3]["Count"], "29")
        self.assertEqual(record["eGQueryResult"][3]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][4]["DbName"], "books")
        self.assertEqual(record["eGQueryResult"][4]["MenuName"], "Books")
        self.assertEqual(record["eGQueryResult"][4]["Count"], "392")
        self.assertEqual(record["eGQueryResult"][4]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][5]["DbName"], "omim")
        self.assertEqual(record["eGQueryResult"][5]["MenuName"], "OMIM")
        self.assertEqual(record["eGQueryResult"][5]["Count"], "149")
        self.assertEqual(record["eGQueryResult"][5]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][6]["DbName"], "omia")
        self.assertEqual(record["eGQueryResult"][6]["MenuName"], "OMIA")
        self.assertEqual(record["eGQueryResult"][6]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][6]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][7]["DbName"], "ncbisearch")
        self.assertEqual(record["eGQueryResult"][7]["MenuName"], "NCBI Web Site")
        self.assertEqual(record["eGQueryResult"][7]["Count"], "13")
        self.assertEqual(record["eGQueryResult"][7]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][8]["DbName"], "nuccore")
        self.assertEqual(record["eGQueryResult"][8]["MenuName"], "CoreNucleotide")
        self.assertEqual(record["eGQueryResult"][8]["Count"], "4917")
        self.assertEqual(record["eGQueryResult"][8]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][9]["DbName"], "nucgss")
        self.assertEqual(record["eGQueryResult"][9]["MenuName"], "GSS")
        self.assertEqual(record["eGQueryResult"][9]["Count"], "184")
        self.assertEqual(record["eGQueryResult"][9]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][10]["DbName"], "nucest")
        self.assertEqual(record["eGQueryResult"][10]["MenuName"], "EST")
        self.assertEqual(record["eGQueryResult"][10]["Count"], "600")
        self.assertEqual(record["eGQueryResult"][10]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][11]["DbName"], "protein")
        self.assertEqual(record["eGQueryResult"][11]["MenuName"], "Protein")
        self.assertEqual(record["eGQueryResult"][11]["Count"], "6779")
        self.assertEqual(record["eGQueryResult"][11]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][12]["DbName"], "genome")
        self.assertEqual(record["eGQueryResult"][12]["MenuName"], "Genome")
        self.assertEqual(record["eGQueryResult"][12]["Count"], "44")
        self.assertEqual(record["eGQueryResult"][12]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][13]["DbName"], "structure")
        self.assertEqual(record["eGQueryResult"][13]["MenuName"], "Structure")
        self.assertEqual(record["eGQueryResult"][13]["Count"], "29")
        self.assertEqual(record["eGQueryResult"][13]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][14]["DbName"], "taxonomy")
        self.assertEqual(record["eGQueryResult"][14]["MenuName"], "Taxonomy")
        self.assertEqual(record["eGQueryResult"][14]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][14]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][15]["DbName"], "snp")
        self.assertEqual(record["eGQueryResult"][15]["MenuName"], "SNP")
        self.assertEqual(record["eGQueryResult"][15]["Count"], "2013")
        self.assertEqual(record["eGQueryResult"][15]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][16]["DbName"], "gene")
        self.assertEqual(record["eGQueryResult"][16]["MenuName"], "Gene")
        self.assertEqual(record["eGQueryResult"][16]["Count"], "1775")
        self.assertEqual(record["eGQueryResult"][16]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][17]["DbName"], "unigene")
        self.assertEqual(record["eGQueryResult"][17]["MenuName"], "UniGene")
        self.assertEqual(record["eGQueryResult"][17]["Count"], "207")
        self.assertEqual(record["eGQueryResult"][17]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][18]["DbName"], "cdd")
        self.assertEqual(record["eGQueryResult"][18]["MenuName"], "Conserved Domains")
        self.assertEqual(record["eGQueryResult"][18]["Count"], "17")
        self.assertEqual(record["eGQueryResult"][18]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][19]["DbName"], "domains")
        self.assertEqual(record["eGQueryResult"][19]["MenuName"], "3D Domains")
        self.assertEqual(record["eGQueryResult"][19]["Count"], "131")
        self.assertEqual(record["eGQueryResult"][19]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][20]["DbName"], "unists")
        self.assertEqual(record["eGQueryResult"][20]["MenuName"], "UniSTS")
        self.assertEqual(record["eGQueryResult"][20]["Count"], "198")
        self.assertEqual(record["eGQueryResult"][20]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][21]["DbName"], "popset")
        self.assertEqual(record["eGQueryResult"][21]["MenuName"], "PopSet")
        self.assertEqual(record["eGQueryResult"][21]["Count"], "43")
        self.assertEqual(record["eGQueryResult"][21]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][22]["DbName"], "geo")
        self.assertEqual(record["eGQueryResult"][22]["MenuName"], "GEO Profiles")
        self.assertEqual(record["eGQueryResult"][22]["Count"], "128692")
        self.assertEqual(record["eGQueryResult"][22]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][23]["DbName"], "gds")
        self.assertEqual(record["eGQueryResult"][23]["MenuName"], "GEO DataSets")
        self.assertEqual(record["eGQueryResult"][23]["Count"], "21")
        self.assertEqual(record["eGQueryResult"][23]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][24]["DbName"], "homologene")
        self.assertEqual(record["eGQueryResult"][24]["MenuName"], "HomoloGene")
        self.assertEqual(record["eGQueryResult"][24]["Count"], "50")
        self.assertEqual(record["eGQueryResult"][24]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][25]["DbName"], "cancerchromosomes")
        self.assertEqual(record["eGQueryResult"][25]["MenuName"], "CancerChromosomes")
        self.assertEqual(record["eGQueryResult"][25]["Count"], "18")
        self.assertEqual(record["eGQueryResult"][25]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][26]["DbName"], "pccompound")
        self.assertEqual(record["eGQueryResult"][26]["MenuName"], "PubChem Compound")
        self.assertEqual(record["eGQueryResult"][26]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][26]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][27]["DbName"], "pcsubstance")
        self.assertEqual(record["eGQueryResult"][27]["MenuName"], "PubChem Substance")
        self.assertEqual(record["eGQueryResult"][27]["Count"], "26")
        self.assertEqual(record["eGQueryResult"][27]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][28]["DbName"], "pcassay")
        self.assertEqual(record["eGQueryResult"][28]["MenuName"], "PubChem BioAssay")
        self.assertEqual(record["eGQueryResult"][28]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][28]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][29]["DbName"], "nlmcatalog")
        self.assertEqual(record["eGQueryResult"][29]["MenuName"], "NLM Catalog")
        self.assertEqual(record["eGQueryResult"][29]["Count"], "31")
        self.assertEqual(record["eGQueryResult"][29]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][30]["DbName"], "gensat")
        self.assertEqual(record["eGQueryResult"][30]["MenuName"], "GENSAT")
        self.assertEqual(record["eGQueryResult"][30]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][30]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][31]["DbName"], "probe")
        self.assertEqual(record["eGQueryResult"][31]["MenuName"], "Probe")
        self.assertEqual(record["eGQueryResult"][31]["Count"], "1410")
        self.assertEqual(record["eGQueryResult"][31]["Status"], "Ok")
        self.assertEqual(record["eGQueryResult"][32]["DbName"], "genomeprj")
        self.assertEqual(record["eGQueryResult"][32]["MenuName"], "Genome Project")
        self.assertEqual(record["eGQueryResult"][32]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][32]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][33]["DbName"], "gap")
        self.assertEqual(record["eGQueryResult"][33]["MenuName"], "dbGaP")
        self.assertEqual(record["eGQueryResult"][33]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][33]["Status"], "Term or Database is not found")
        self.assertEqual(record["eGQueryResult"][34]["DbName"], "proteinclusters")
        self.assertEqual(record["eGQueryResult"][34]["MenuName"], "Protein Clusters")
        self.assertEqual(record["eGQueryResult"][34]["Count"], "0")
        self.assertEqual(record["eGQueryResult"][34]["Status"], "Term or Database is not found")


class ESpellTest(unittest.TestCase):
    '''Tests for parsing XML output returned by ESpell
    '''
    def test_espell(self):
        '''Test parsing XML output returned by ESpell
        '''
        # Request suggestions for the PubMed search biopythooon
        # To create the XML file, use
        # >>> Bio.Entrez.espell(db="pubmed", term="biopythooon")
        handle = open('Entrez/espell.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record["Database"], "pubmed")
        self.assertEqual(record["Query"], "biopythooon")
        self.assertEqual(record["CorrectedQuery"], "biopython")
        self.assertEqual(len(record["SpelledQuery"]), 1)
        self.assertEqual(record["SpelledQuery"][0], "biopython")
        self.assertEqual(record["SpelledQuery"][0].tag, "Replaced")


class EFetchTest(unittest.TestCase):
    '''Tests for parsing XML output returned by EFetch
    '''
    def test_pubmed1(self):
        '''Test parsing XML returned by EFetch, PubMed database (first test)
        '''
        # In PubMed display PMIDs 12091962 and 9997 in xml retrieval mode
        # and abstract retrieval type.
        # To create the XML file, use
        # >>> Bio.Entrez.efetch(db='pubmed', id='12091962,9997',
        #                       retmode='xml', rettype='abstract')
        handle = open('Entrez/pubmed1.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["MedlineCitation"].attributes["Owner"], "KIE")
        self.assertEqual(record[0]["MedlineCitation"].attributes["Status"], "MEDLINE")
        self.assertEqual(record[0]["MedlineCitation"]["PMID"], "12091962")
        self.assertEqual(record[0]["MedlineCitation"]["DateCreated"]["Year"], "1991")
        self.assertEqual(record[0]["MedlineCitation"]["DateCreated"]["Month"], "01")
        self.assertEqual(record[0]["MedlineCitation"]["DateCreated"]["Day"], "22")
        self.assertEqual(record[0]["MedlineCitation"]["DateCompleted"]["Year"], "1991")
        self.assertEqual(record[0]["MedlineCitation"]["DateCompleted"]["Month"], "01")
        self.assertEqual(record[0]["MedlineCitation"]["DateCompleted"]["Day"], "22")
        self.assertEqual(record[0]["MedlineCitation"]["DateRevised"]["Year"], "2007")
        self.assertEqual(record[0]["MedlineCitation"]["DateRevised"]["Month"], "11")
        self.assertEqual(record[0]["MedlineCitation"]["DateRevised"]["Day"], "15")
        self.assertEqual(record[0]["MedlineCitation"]["Article"].attributes["PubModel"], "Print")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["ISSN"], "1043-1578")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["ISSN"].attributes["IssnType"], "Print")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"].attributes["CitedMedium"], "Print")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["Volume"], "17")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["Issue"], "1")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["PubDate"]["Year"], "1990")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["PubDate"]["Season"], "Spring")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["Title"], "Social justice (San Francisco, Calif.)")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["ArticleTitle"], "The treatment of AIDS behind the walls of correctional facilities.")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Pagination"]["MedlinePgn"], "113-25")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"].attributes["CompleteYN"], 'Y')
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][0].attributes["ValidYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][0]["LastName"], "Olivero")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][0]["ForeName"], "J Michael")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][0]["Initials"], "JM")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Language"], ["eng"])
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["PublicationTypeList"], ["Journal Article", "Review"])
        self.assertEqual(record[0]["MedlineCitation"]["MedlineJournalInfo"]["Country"], "United States")
        self.assertEqual(record[0]["MedlineCitation"]["MedlineJournalInfo"]["MedlineTA"], "Soc Justice")
        self.assertEqual(record[0]["MedlineCitation"]["MedlineJournalInfo"]["NlmUniqueID"], "9891830")
        self.assertEqual(record[0]["MedlineCitation"]["CitationSubset"], ["E"])
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][0]["DescriptorName"], "AIDS Serodiagnosis")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][0]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][1]["DescriptorName"], "Acquired Immunodeficiency Syndrome")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][1]["DescriptorName"].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][2]["DescriptorName"], "Civil Rights")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][2]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][3]["DescriptorName"], "HIV Seropositivity")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][3]["DescriptorName"].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][4]["DescriptorName"], "Humans")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][4]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][5]["DescriptorName"], "Jurisprudence")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][5]["DescriptorName"].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][6]["DescriptorName"], "Law Enforcement")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][6]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][7]["DescriptorName"], "Mass Screening")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][7]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][8]["DescriptorName"], "Minority Groups")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][8]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][9]["DescriptorName"], "Organizational Policy")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][9]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][10]["DescriptorName"], "Patient Care")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][10]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][11]["DescriptorName"], "Prejudice")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][11]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][12]["DescriptorName"], "Prisoners")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][12]["DescriptorName"].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][13]["DescriptorName"], "Public Policy")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][13]["DescriptorName"].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][14]["DescriptorName"], "Quarantine")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][14]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][15]["DescriptorName"], "Social Control, Formal")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][15]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][16]["DescriptorName"], "Statistics as Topic")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][16]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][17]["DescriptorName"], "Stereotyping")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][17]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][18]["DescriptorName"], "United States")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][18]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["NumberOfReferences"], "63")
        self.assertEqual(record[0]["MedlineCitation"]["OtherID"][0], "31840")
        self.assertEqual(record[0]["MedlineCitation"]["OtherID"][0].attributes["Source"], "KIE")
        self.assertEqual(record[0]["MedlineCitation"]["KeywordList"][0].attributes["Owner"], "KIE")
        self.assertEqual(record[0]["MedlineCitation"]["KeywordList"][0][0], "Health Care and Public Health")
        self.assertEqual(record[0]["MedlineCitation"]["KeywordList"][0][0].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["KeywordList"][0][1], "Legal Approach")
        self.assertEqual(record[0]["MedlineCitation"]["KeywordList"][0][1].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["GeneralNote"][0], "14 fn.")
        self.assertEqual(record[0]["MedlineCitation"]["GeneralNote"][0].attributes["Owner"], "KIE")
        self.assertEqual(record[0]["MedlineCitation"]["GeneralNote"][1], "KIE BoB Subject Heading: AIDS")
        self.assertEqual(record[0]["MedlineCitation"]["GeneralNote"][1].attributes["Owner"], "KIE")
        self.assertEqual(record[0]["MedlineCitation"]["GeneralNote"][2], "63 refs.")
        self.assertEqual(record[0]["MedlineCitation"]["GeneralNote"][2].attributes["Owner"], "KIE")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0].attributes["PubStatus"], "pubmed")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0]["Year"], "1990")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0]["Month"], "4")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0]["Day"], "1")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0]["Hour"], "0")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0]["Minute"], "0")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1].attributes["PubStatus"], "medline")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1]["Year"], "2002")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1]["Month"], "7")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1]["Day"], "16")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1]["Hour"], "10")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1]["Minute"], "1")
        self.assertEqual(record[0]["PubmedData"]["PublicationStatus"], "ppublish")
        self.assertEqual(len(record[0]["PubmedData"]["ArticleIdList"]), 1)
        self.assertEqual(record[0]["PubmedData"]["ArticleIdList"][0], "12091962")
        self.assertEqual(record[0]["PubmedData"]["ArticleIdList"][0].attributes["IdType"], "pubmed")
        self.assertEqual(record[1]["MedlineCitation"].attributes["Owner"], "NLM")
        self.assertEqual(record[1]["MedlineCitation"].attributes["Status"], "MEDLINE")
        self.assertEqual(record[1]["MedlineCitation"]["PMID"], "9997")
        self.assertEqual(record[1]["MedlineCitation"]["DateCreated"]["Year"], "1976")
        self.assertEqual(record[1]["MedlineCitation"]["DateCreated"]["Month"], "12")
        self.assertEqual(record[1]["MedlineCitation"]["DateCreated"]["Day"], "30")
        self.assertEqual(record[1]["MedlineCitation"]["DateCompleted"]["Year"], "1976")
        self.assertEqual(record[1]["MedlineCitation"]["DateCompleted"]["Month"], "12")
        self.assertEqual(record[1]["MedlineCitation"]["DateCompleted"]["Day"], "30")
        self.assertEqual(record[1]["MedlineCitation"]["DateRevised"]["Year"], "2003")
        self.assertEqual(record[1]["MedlineCitation"]["DateRevised"]["Month"], "11")
        self.assertEqual(record[1]["MedlineCitation"]["DateRevised"]["Day"], "14")
        self.assertEqual(record[1]["MedlineCitation"]["Article"].attributes["PubModel"], "Print")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["ISSN"], "0006-3002")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["ISSN"].attributes["IssnType"], "Print")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"].attributes["CitedMedium"], "Print")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["Volume"], "446")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["Issue"], "1")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["PubDate"]["Year"], "1976")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["PubDate"]["Month"], "Sep")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["PubDate"]["Day"], "28")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["Title"], "Biochimica et biophysica acta")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["ISOAbbreviation"], "Biochim. Biophys. Acta")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["ArticleTitle"], "Magnetic studies of Chromatium flavocytochrome C552. A mechanism for heme-flavin interaction.")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Pagination"]["MedlinePgn"], "179-91")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Abstract"]["AbstractText"], "Electron paramagnetic resonance and magnetic susceptibility studies of Chromatium flavocytochrome C552 and its diheme flavin-free subunit at temperatures below 45 degrees K are reported. The results show that in the intact protein and the subunit the two low-spin (S = 1/2) heme irons are distinguishable, giving rise to separate EPR signals. In the intact protein only, one of the heme irons exists in two different low spin environments in the pH range 5.5 to 10.5, while the other remains in a constant environment. Factors influencing the variable heme iron environment also influence flavin reactivity, indicating the existence of a mechanism for heme-flavin interaction.")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"].attributes["CompleteYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][0].attributes["ValidYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][0]["LastName"], "Strekas")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][0]["ForeName"], "T C")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][0]["Initials"], "TC")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Language"], ["eng"])
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["PublicationTypeList"], ["Journal Article"])
        self.assertEqual(record[1]["MedlineCitation"]["MedlineJournalInfo"]["Country"], "NETHERLANDS")
        self.assertEqual(record[1]["MedlineCitation"]["MedlineJournalInfo"]["MedlineTA"], "Biochim Biophys Acta")
        self.assertEqual(record[1]["MedlineCitation"]["MedlineJournalInfo"]["NlmUniqueID"], "0217513")
        self.assertEqual(record[1]["MedlineCitation"]["ChemicalList"][0]["RegistryNumber"], "0")
        self.assertEqual(record[1]["MedlineCitation"]["ChemicalList"][0]["NameOfSubstance"], "Cytochrome c Group")
        self.assertEqual(record[1]["MedlineCitation"]["ChemicalList"][1]["RegistryNumber"], "0")
        self.assertEqual(record[1]["MedlineCitation"]["ChemicalList"][1]["NameOfSubstance"], "Flavins")
        self.assertEqual(record[1]["MedlineCitation"]["ChemicalList"][2]["RegistryNumber"], "14875-96-8")
        self.assertEqual(record[1]["MedlineCitation"]["ChemicalList"][2]["NameOfSubstance"], "Heme")
        self.assertEqual(record[1]["MedlineCitation"]["ChemicalList"][3]["RegistryNumber"], "7439-89-6")
        self.assertEqual(record[1]["MedlineCitation"]["ChemicalList"][3]["NameOfSubstance"], "Iron")
        self.assertEqual(record[1]["MedlineCitation"]["CitationSubset"], ["IM"])
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][0]["DescriptorName"], "Binding Sites")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][0]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][1]["DescriptorName"], "Chromatium")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][1]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][1]["QualifierName"][0], "enzymology")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][1]["QualifierName"][0].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][2]["DescriptorName"], "Cytochrome c Group")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][2]["DescriptorName"].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][3]["DescriptorName"], "Electron Spin Resonance Spectroscopy")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][3]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][4]["DescriptorName"], "Flavins")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][4]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][5]["DescriptorName"], "Heme")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][5]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][6]["DescriptorName"], "Hydrogen-Ion Concentration")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][6]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][7]["DescriptorName"], "Iron")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][7]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][7]["QualifierName"][0], "analysis")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][7]["QualifierName"][0].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][8]["DescriptorName"], "Magnetics")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][8]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][9]["DescriptorName"], "Oxidation-Reduction")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][9]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][10]["DescriptorName"], "Protein Binding")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][10]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][11]["DescriptorName"], "Protein Conformation")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][11]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][12]["DescriptorName"], "Temperature")
        self.assertEqual(record[1]["MedlineCitation"]["MeshHeadingList"][12]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[1]["PubmedData"]["History"][0][0].attributes["PubStatus"], "pubmed")
        self.assertEqual(record[1]["PubmedData"]["History"][0][0]["Year"], "1976")
        self.assertEqual(record[1]["PubmedData"]["History"][0][0]["Month"], "9")
        self.assertEqual(record[1]["PubmedData"]["History"][0][0]["Day"], "28")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1].attributes["PubStatus"], "medline")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1]["Year"], "1976")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1]["Month"], "9")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1]["Day"], "28")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1]["Hour"], "0")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1]["Minute"], "1")
        self.assertEqual(record[1]["PubmedData"]["PublicationStatus"], "ppublish")
        self.assertEqual(len(record[1]["PubmedData"]["ArticleIdList"]), 1)
        self.assertEqual(record[1]["PubmedData"]["ArticleIdList"][0], "9997")
        self.assertEqual(record[1]["PubmedData"]["ArticleIdList"][0].attributes["IdType"], "pubmed")

    def test_pubmed2(self):
        '''Test parsing XML returned by EFetch, PubMed database (second test)
        '''
        # In PubMed display PMIDs in xml retrieval mode.
        # To create the XML file, use
        # >>> Bio.Entrez.efetch(db='pubmed', id="11748933,11700088",
        #                       retmode="xml")
        handle = open('Entrez/pubmed2.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["MedlineCitation"].attributes["Owner"], "NLM")
        self.assertEqual(record[0]["MedlineCitation"].attributes["Status"], "MEDLINE")
        self.assertEqual(record[0]["MedlineCitation"]["PMID"], "11748933")
        self.assertEqual(record[0]["MedlineCitation"]["DateCreated"]["Year"], "2001")
        self.assertEqual(record[0]["MedlineCitation"]["DateCreated"]["Month"], "12")
        self.assertEqual(record[0]["MedlineCitation"]["DateCreated"]["Day"], "25")
        self.assertEqual(record[0]["MedlineCitation"]["DateCompleted"]["Year"], "2002")
        self.assertEqual(record[0]["MedlineCitation"]["DateCompleted"]["Month"], "03")
        self.assertEqual(record[0]["MedlineCitation"]["DateCompleted"]["Day"], "04")
        self.assertEqual(record[0]["MedlineCitation"]["DateRevised"]["Year"], "2006")
        self.assertEqual(record[0]["MedlineCitation"]["DateRevised"]["Month"], "11")
        self.assertEqual(record[0]["MedlineCitation"]["DateRevised"]["Day"], "15")
        self.assertEqual(record[0]["MedlineCitation"]["Article"].attributes["PubModel"], "Print")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["ISSN"], "0011-2240")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["ISSN"].attributes["IssnType"], "Print")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"].attributes["CitedMedium"], "Print")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["Volume"], "42")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["Issue"], "4")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["PubDate"]["Year"], "2001")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["PubDate"]["Month"], "Jun")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["Title"], "Cryobiology")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Journal"]["ISOAbbreviation"], "Cryobiology")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["ArticleTitle"], "Is cryopreservation a homogeneous process? Ultrastructure and motility of untreated, prefreezing, and postthawed spermatozoa of Diplodus puntazzo (Cetti).")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Pagination"]["MedlinePgn"], "244-55")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Abstract"]["AbstractText"], "This study subdivides the cryopreservation procedure for Diplodus puntazzo spermatozoa into three key phases, fresh, prefreezing (samples equilibrated in cryosolutions), and postthawed stages, and examines the ultrastructural anomalies and motility profiles of spermatozoa in each stage, with different cryodiluents. Two simple cryosolutions were evaluated: 0.17 M sodium chloride containing a final concentration of 15% dimethyl sulfoxide (Me(2)SO) (cryosolution A) and 0.1 M sodium citrate containing a final concentration of 10% Me(2)SO (cryosolution B). Ultrastructural anomalies of the plasmatic and nuclear membranes of the sperm head were common and the severity of the cryoinjury differed significantly between the pre- and the postfreezing phases and between the two cryosolutions. In spermatozoa diluted with cryosolution A, during the prefreezing phase, the plasmalemma of 61% of the cells was absent or damaged compared with 24% in the fresh sample (P < 0.001). In spermatozoa diluted with cryosolution B, there was a pronounced increase in the number of cells lacking the head plasmatic membrane from the prefreezing to the postthawed stages (from 32 to 52%, P < 0.01). In both cryosolutions, damages to nuclear membrane were significantly higher after freezing (cryosolution A: 8 to 23%, P < 0.01; cryosolution B: 5 to 38%, P < 0.001). With cryosolution A, the after-activation motility profile confirmed a consistent drop from fresh at the prefreezing stage, whereas freezing and thawing did not affect the motility much further and 50% of the cells were immotile by 60-90 s after activation. With cryosolution B, only the postthawing stage showed a sharp drop of motility profile. This study suggests that the different phases of the cryoprocess should be investigated to better understand the process of sperm damage.")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Abstract"]["CopyrightInformation"], "Copyright 2001 Elsevier Science.")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Affiliation"], u'Dipartimento di Scienze Ambientali, Universit\xe0 degli Studi della Tuscia, 01100 Viterbo, Italy.')
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"].attributes["CompleteYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][0].attributes["ValidYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][0]["LastName"], "Taddei")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][0]["ForeName"], "A R")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][0]["Initials"], "AR")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][1].attributes["ValidYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][1]["LastName"], "Barbato")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][1]["ForeName"], "F")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][1]["Initials"], "F")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][2].attributes["ValidYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][2]["LastName"], "Abelli")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][2]["ForeName"], "L")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][2]["Initials"], "L")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][3].attributes["ValidYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][3]["LastName"], "Canese")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][3]["ForeName"], "S")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][3]["Initials"], "S")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][4].attributes["ValidYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][4]["LastName"], "Moretti")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][4]["ForeName"], "F")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][4]["Initials"], "F")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][5].attributes["ValidYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][5]["LastName"], "Rana")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][5]["ForeName"], "K J")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][5]["Initials"], "KJ")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][6].attributes["ValidYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][6]["LastName"], "Fausto")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][6]["ForeName"], "A M")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][6]["Initials"], "AM")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][7].attributes["ValidYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][7]["LastName"], "Mazzini")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][7]["ForeName"], "M")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["AuthorList"][7]["Initials"], "M")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["Language"], ["eng"])
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["PublicationTypeList"][0], "Journal Article")
        self.assertEqual(record[0]["MedlineCitation"]["Article"]["PublicationTypeList"][1], "Research Support, Non-U.S. Gov't")
        self.assertEqual(record[0]["MedlineCitation"]["MedlineJournalInfo"]["Country"], "United States")
        self.assertEqual(record[0]["MedlineCitation"]["MedlineJournalInfo"]["MedlineTA"], "Cryobiology")
        self.assertEqual(record[0]["MedlineCitation"]["MedlineJournalInfo"]["NlmUniqueID"], "0006252")
        self.assertEqual(record[0]["MedlineCitation"]["CitationSubset"], ["IM"])
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][0]["DescriptorName"], "Animals")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][0]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][1]["DescriptorName"], "Cell Membrane")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][1]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][1]["QualifierName"][0], "ultrastructure")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][1]["QualifierName"][0].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][2]["DescriptorName"], "Cryopreservation")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][2]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][2]["QualifierName"][0], "methods")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][2]["QualifierName"][0].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][3]["DescriptorName"], "Male")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][3]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][4]["DescriptorName"], "Microscopy, Electron")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][4]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][5]["DescriptorName"], "Microscopy, Electron, Scanning")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][5]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][6]["DescriptorName"], "Nuclear Envelope")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][6]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][6]["QualifierName"][0], "ultrastructure")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][6]["QualifierName"][0].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][7]["DescriptorName"], "Sea Bream")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][7]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][7]["QualifierName"][0], "anatomy & histology")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][7]["QualifierName"][0].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][7]["QualifierName"][1], "physiology")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][7]["QualifierName"][1].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][8]["DescriptorName"], "Semen Preservation")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][8]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][8]["QualifierName"][0], "adverse effects")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][8]["QualifierName"][0].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][8]["QualifierName"][1], "methods")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][8]["QualifierName"][1].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][9]["DescriptorName"], "Sperm Motility")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][9]["DescriptorName"].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][10]["DescriptorName"], "Spermatozoa")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][10]["DescriptorName"].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][10]["QualifierName"][0], "physiology")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][10]["QualifierName"][0].attributes["MajorTopicYN"], "N")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][10]["QualifierName"][1], "ultrastructure")
        self.assertEqual(record[0]["MedlineCitation"]["MeshHeadingList"][10]["QualifierName"][1].attributes["MajorTopicYN"], "Y")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0].attributes["PubStatus"], "pubmed")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0]["Year"], "2001")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0]["Month"], "12")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0]["Day"], "26")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0]["Hour"], "10")
        self.assertEqual(record[0]["PubmedData"]["History"][0][0]["Minute"], "0")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1].attributes["PubStatus"], "medline")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1]["Year"], "2002")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1]["Month"], "3")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1]["Day"], "5")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1]["Hour"], "10")
        self.assertEqual(record[0]["PubmedData"]["History"][0][1]["Minute"], "1")
        self.assertEqual(record[0]["PubmedData"]["PublicationStatus"], "ppublish")
        self.assertEqual(record[0]["PubmedData"]["ArticleIdList"][0], "11748933")
        self.assertEqual(record[0]["PubmedData"]["ArticleIdList"][0].attributes["IdType"], "pubmed")
        self.assertEqual(record[0]["PubmedData"]["ArticleIdList"][1], "10.1006/cryo.2001.2328")
        self.assertEqual(record[0]["PubmedData"]["ArticleIdList"][1].attributes["IdType"], "doi")
        self.assertEqual(record[0]["PubmedData"]["ArticleIdList"][2], "S0011-2240(01)92328-4")
        self.assertEqual(record[0]["PubmedData"]["ArticleIdList"][2].attributes["IdType"], "pii")

        self.assertEqual(record[1]["MedlineCitation"].attributes["Owner"], "NLM")
        self.assertEqual(record[1]["MedlineCitation"].attributes["Status"], "PubMed-not-MEDLINE")
        self.assertEqual(record[1]["MedlineCitation"]["PMID"], "11700088")
        self.assertEqual(record[1]["MedlineCitation"]["DateCreated"]["Year"], "2001")
        self.assertEqual(record[1]["MedlineCitation"]["DateCreated"]["Month"], "11")
        self.assertEqual(record[1]["MedlineCitation"]["DateCreated"]["Day"], "08")
        self.assertEqual(record[1]["MedlineCitation"]["DateCompleted"]["Year"], "2001")
        self.assertEqual(record[1]["MedlineCitation"]["DateCompleted"]["Month"], "12")
        self.assertEqual(record[1]["MedlineCitation"]["DateCompleted"]["Day"], "20")
        self.assertEqual(record[1]["MedlineCitation"]["DateRevised"]["Year"], "2003")
        self.assertEqual(record[1]["MedlineCitation"]["DateRevised"]["Month"], "10")
        self.assertEqual(record[1]["MedlineCitation"]["DateRevised"]["Day"], "31")
        self.assertEqual(record[1]["MedlineCitation"]["Article"].attributes["PubModel"], "Print")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["ISSN"], "1090-7807")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["ISSN"].attributes["IssnType"], "Print")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"].attributes["CitedMedium"], "Print")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["Volume"], "153")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["Issue"], "1")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["PubDate"]["Year"], "2001")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["JournalIssue"]["PubDate"]["Month"], "Nov")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["Title"], "Journal of magnetic resonance (San Diego, Calif. : 1997)")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Journal"]["ISOAbbreviation"], "J. Magn. Reson.")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["ArticleTitle"], "Proton MRI of (13)C distribution by J and chemical shift editing.")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Pagination"]["MedlinePgn"], "117-23")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Abstract"]["AbstractText"], "The sensitivity of (13)C NMR imaging can be considerably favored by detecting the (1)H nuclei bound to (13)C nuclei via scalar J-interaction (X-filter). However, the J-editing approaches have difficulty in discriminating between compounds with similar J-constant as, for example, different glucose metabolites. In such cases, it is almost impossible to get J-edited images of a single-compound distribution, since the various molecules are distinguishable only via their chemical shift. In a recent application of J-editing to high-resolution spectroscopy, it has been shown that a more efficient chemical selectivity could be obtained by utilizing the larger chemical shift range of (13)C. This has been made by introducing frequency-selective (13)C pulses that allow a great capability of indirect chemical separation. Here a double-resonance imaging approach is proposed, based on both J-editing and (13)C chemical shift editing, which achieves a powerful chemical selectivity and is able to produce full maps of specific chemical compounds. Results are presented on a multicompartments sample containing solutions of glucose and lactic and glutamic acid in water.")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Abstract"]["CopyrightInformation"], "Copyright 2001 Academic Press.")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Affiliation"], "INFM and Department of Physics, University of L'Aquila, I-67100 L'Aquila, Italy.")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"].attributes["CompleteYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][0].attributes["ValidYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][0]["LastName"], "Casieri")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][0]["ForeName"], "C")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][0]["Initials"], "C")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][1].attributes["ValidYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][1]["LastName"], "Testa")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][1]["ForeName"], "C")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][1]["Initials"], "C")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][2].attributes["ValidYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][2]["LastName"], "Carpinelli")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][2]["ForeName"], "G")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][2]["Initials"], "G")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][3].attributes["ValidYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][3]["LastName"], "Canese")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][3]["ForeName"], "R")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][3]["Initials"], "R")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][4].attributes["ValidYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][4]["LastName"], "Podo")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][4]["ForeName"], "F")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][4]["Initials"], "F")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][5].attributes["ValidYN"], "Y")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][5]["LastName"], "De Luca")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][5]["ForeName"], "F")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["AuthorList"][5]["Initials"], "F")
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["Language"], ["eng"])
        self.assertEqual(record[1]["MedlineCitation"]["Article"]["PublicationTypeList"][0], "Journal Article")
        self.assertEqual(record[1]["MedlineCitation"]["MedlineJournalInfo"]["Country"], "United States")
        self.assertEqual(record[1]["MedlineCitation"]["MedlineJournalInfo"]["MedlineTA"], "J Magn Reson")
        self.assertEqual(record[1]["MedlineCitation"]["MedlineJournalInfo"]["NlmUniqueID"], "9707935")
        self.assertEqual(record[1]["PubmedData"]["History"][0][0].attributes["PubStatus"], "pubmed")
        self.assertEqual(record[1]["PubmedData"]["History"][0][0]["Year"], "2001")
        self.assertEqual(record[1]["PubmedData"]["History"][0][0]["Month"], "11")
        self.assertEqual(record[1]["PubmedData"]["History"][0][0]["Day"], "9")
        self.assertEqual(record[1]["PubmedData"]["History"][0][0]["Hour"], "10")
        self.assertEqual(record[1]["PubmedData"]["History"][0][0]["Minute"], "0")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1].attributes["PubStatus"], "medline")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1]["Year"], "2001")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1]["Month"], "11")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1]["Day"], "9")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1]["Hour"], "10")
        self.assertEqual(record[1]["PubmedData"]["History"][0][1]["Minute"], "1")
        self.assertEqual(record[1]["PubmedData"]["PublicationStatus"], "ppublish")
        self.assertEqual(record[1]["PubmedData"]["ArticleIdList"][0], "11700088")
        self.assertEqual(record[1]["PubmedData"]["ArticleIdList"][0].attributes["IdType"], "pubmed")
        self.assertEqual(record[1]["PubmedData"]["ArticleIdList"][1], "10.1006/jmre.2001.2429")
        self.assertEqual(record[1]["PubmedData"]["ArticleIdList"][1].attributes["IdType"], "doi")
        self.assertEqual(record[1]["PubmedData"]["ArticleIdList"][2], "S1090-7807(01)92429-2")
        self.assertEqual(record[1]["PubmedData"]["ArticleIdList"][2].attributes["IdType"], "pii")

    def test_omim(self):
        '''Test parsing XML returned by EFetch, OMIM database
        '''
        # In OMIM show the full record for MIM number 601100 as XML
        # To create the XML file, use
        # >>> Bio.Entrez.efetch(db="omim", id="601100", retmode='xml',
        #                       rettype='full')
        handle = open('Entrez/ncbi_mim.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(len(record), 1)
        self.assertEqual(record[0]["Mim-entry_mimNumber"], "601100")
        self.assertEqual(record[0]["Mim-entry_mimType"], "1")
        self.assertEqual(record[0]["Mim-entry_mimType"].attributes["value"], "star")
        self.assertEqual(record[0]["Mim-entry_title"], "STRESS 70 PROTEIN CHAPERONE, MICROSOME-ASSOCIATED, 60-KD; STCH")
        self.assertEqual(record[0]["Mim-entry_copyright"], "Copyright (c) 1966-2008 Johns Hopkins University")
        self.assertEqual(record[0]["Mim-entry_symbol"], "STCH")
        self.assertEqual(record[0]["Mim-entry_locus"], "21q11.1")
        self.assertEqual(len(record[0]["Mim-entry_text"]), 2)
        self.assertEqual(record[0]["Mim-entry_text"][0]["Mim-text_label"], "TEXT")
        self.assertEqual(record[0]["Mim-entry_text"][0]["Mim-text_text"], "The stress-70 chaperone family consists of proteins that bind to denatured or incorrectly folded polypeptides and play a major role in the processing of cytosolic and secretory proteins. {2:Otterson et al. (1994)} cloned a human cDNA encoding a predicted 471-amino acid protein (60 kD) which they designated STCH. {1:Brodsky et al. (1995)} stated that the protein sequence is very similar to that of HSP70 ({140550}) and BiP ({138120}). As with other members of the family, the STCH protein contains an ATPase domain at the amino terminus whose activity was shown to be independent of peptide stimulation. The protein was found to be microsome-associated and constitutively expressed in all cell types examined.")
        self.assertEqual(len(record[0]["Mim-entry_text"][0]["Mim-text_neighbors"]), 1)
        self.assertEqual(record[0]["Mim-entry_text"][0]["Mim-text_neighbors"]["Mim-link"]["Mim-link_num"], "30")
        self.assertEqual(record[0]["Mim-entry_text"][0]["Mim-text_neighbors"]["Mim-link"]["Mim-link_uids"], "8131751,9358068,10675567,9488737,8757872,11048651,2559088,10982831,2105497,16572726,9083109,17181539,14508011,15028727,10651811,9108392,11599566,2661019,11836248,7594475,12406544,8536694,12389629,10430932,9177027,9837933,8522346,2928112,12834280,8702658")
        self.assertEqual(record[0]["Mim-entry_text"][0]["Mim-text_neighbors"]["Mim-link"]["Mim-link_numRelevant"], "0")
        self.assertEqual(record[0]["Mim-entry_text"][1]["Mim-text_label"], "TEXT")
        self.assertEqual(record[0]["Mim-entry_text"][1]["Mim-text_text"], "{1:Brodsky et al. (1995)} mapped the STCH gene to chromosome 21q11.1 with a high-resolution somatic cell hybrid panel for chromosome 21 and by fluorescence in situ hybridization with a YAC containing the gene. By interspecific backcross analysis, {3:Reeves et al. (1998)} mapped the mouse Stch gene to chromosome 16.")
        self.assertEqual(len(record[0]["Mim-entry_text"][1]["Mim-text_neighbors"]), 1)
        self.assertEqual(record[0]["Mim-entry_text"][1]["Mim-text_neighbors"]["Mim-link"]["Mim-link_num"], "30")
        self.assertEqual(record[0]["Mim-entry_text"][1]["Mim-text_neighbors"]["Mim-link"]["Mim-link_uids"], "1354597,8244375,8597637,8838809,9143508,1427875,7806216,9852683,7835904,11060461,10083745,7789175,7806232,7513297,8020937,12014109,1769649,2045096,9747039,8034329,8088815,1783375,8275716,8020959,7956352,8020952,10198174,7655454,8750197,11272792")
        self.assertEqual(record[0]["Mim-entry_text"][1]["Mim-text_neighbors"]["Mim-link"]["Mim-link_numRelevant"], "0")
        self.assertEqual(record[0]["Mim-entry_hasSummary"], "")
        self.assertEqual(record[0]["Mim-entry_hasSummary"].attributes["value"], "false")
        self.assertEqual(record[0]["Mim-entry_hasSynopsis"], "")
        self.assertEqual(record[0]["Mim-entry_hasSynopsis"].attributes["value"], "false")
        self.assertEqual(len(record[0]["Mim-entry_editHistory"]), 6)
        self.assertEqual(record[0]["Mim-entry_editHistory"][0]["Mim-edit-item_author"], "terry")
        self.assertEqual(record[0]["Mim-entry_editHistory"][0]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_year"], "1999")
        self.assertEqual(record[0]["Mim-entry_editHistory"][0]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_month"], "3")
        self.assertEqual(record[0]["Mim-entry_editHistory"][0]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_day"], "9")
        self.assertEqual(record[0]["Mim-entry_editHistory"][1]["Mim-edit-item_author"], "carol")
        self.assertEqual(record[0]["Mim-entry_editHistory"][1]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_year"], "1999")
        self.assertEqual(record[0]["Mim-entry_editHistory"][1]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_month"], "3")
        self.assertEqual(record[0]["Mim-entry_editHistory"][1]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_day"], "7")
        self.assertEqual(record[0]["Mim-entry_editHistory"][2]["Mim-edit-item_author"], "carol")
        self.assertEqual(record[0]["Mim-entry_editHistory"][2]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_year"], "1998")
        self.assertEqual(record[0]["Mim-entry_editHistory"][2]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_month"], "7")
        self.assertEqual(record[0]["Mim-entry_editHistory"][2]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_day"], "8")
        self.assertEqual(record[0]["Mim-entry_editHistory"][3]["Mim-edit-item_author"], "terry")
        self.assertEqual(record[0]["Mim-entry_editHistory"][3]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_year"], "1996")
        self.assertEqual(record[0]["Mim-entry_editHistory"][3]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_month"], "5")
        self.assertEqual(record[0]["Mim-entry_editHistory"][3]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_day"], "24")
        self.assertEqual(record[0]["Mim-entry_editHistory"][4]["Mim-edit-item_author"], "mark")
        self.assertEqual(record[0]["Mim-entry_editHistory"][4]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_year"], "1996")
        self.assertEqual(record[0]["Mim-entry_editHistory"][4]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_month"], "3")
        self.assertEqual(record[0]["Mim-entry_editHistory"][4]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_day"], "1")
        self.assertEqual(record[0]["Mim-entry_editHistory"][5]["Mim-edit-item_author"], "mark")
        self.assertEqual(record[0]["Mim-entry_editHistory"][5]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_year"], "1996")
        self.assertEqual(record[0]["Mim-entry_editHistory"][5]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_month"], "3")
        self.assertEqual(record[0]["Mim-entry_editHistory"][5]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_day"], "1")
        self.assertEqual(record[0]["Mim-entry_creationDate"]["Mim-edit-item"]["Mim-edit-item_author"], "Alan F. Scott")
        self.assertEqual(record[0]["Mim-entry_creationDate"]["Mim-edit-item"]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_year"], "1996")
        self.assertEqual(record[0]["Mim-entry_creationDate"]["Mim-edit-item"]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_month"], "3")
        self.assertEqual(record[0]["Mim-entry_creationDate"]["Mim-edit-item"]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_day"], "1")
        self.assertEqual(len(record[0]["Mim-entry_references"]), 3)
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_number"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_origNumber"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_type"], "")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_type"].attributes["value"], "citation")
        self.assertEqual(len(record[0]["Mim-entry_references"][0]["Mim-reference_authors"]), 6)
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][0]["Mim-author_name"], "Brodsky, G.")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][0]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][1]["Mim-author_name"], "Otterson, G. A.")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][1]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][2]["Mim-author_name"], "Parry, B. B.")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][2]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][3]["Mim-author_name"], "Hart, I.")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][3]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][4]["Mim-author_name"], "Patterson, D.")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][4]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][5]["Mim-author_name"], "Kaye, F. J.")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_authors"][5]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_primaryAuthor"], "Brodsky")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_otherAuthors"], "et al.")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_citationTitle"], "Localization of STCH to human chromosome 21q11.1.")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_citationType"], "0")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_volume"], "30")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_journal"], "Genomics")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_pubDate"]["Mim-date"]["Mim-date_year"], "1995")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_pubDate"]["Mim-date"]["Mim-date_month"], "0")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_pubDate"]["Mim-date"]["Mim-date_day"], "0")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_pages"][0]["Mim-page_from"], "627")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_pages"][0]["Mim-page_to"], "628")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_pubmedUID"], "8825657")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_ambiguous"], "")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_ambiguous"].attributes["value"], "false")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_noLink"], "")
        self.assertEqual(record[0]["Mim-entry_references"][0]["Mim-reference_noLink"].attributes["value"], "false")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_number"], "2")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_origNumber"], "2")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_type"], "")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_type"].attributes["value"], "citation")
        self.assertEqual(len(record[0]["Mim-entry_references"][1]["Mim-reference_authors"]), 6)
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][0]["Mim-author_name"], "Otterson, G. A.")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][0]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][1]["Mim-author_name"], "Flynn, G. C.")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][1]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][2]["Mim-author_name"], "Kratzke, R. A.")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][2]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][3]["Mim-author_name"], "Coxon, A.")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][3]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][4]["Mim-author_name"], "Johnston, P. G.")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][4]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][5]["Mim-author_name"], "Kaye, F. J.")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_authors"][5]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_primaryAuthor"], "Otterson")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_otherAuthors"], "et al.")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_citationTitle"], "Stch encodes the 'ATPase core' of a microsomal stress70 protein.")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_citationType"], "0")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_volume"], "13")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_journal"], "EMBO J.")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_pubDate"]["Mim-date"]["Mim-date_year"], "1994")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_pubDate"]["Mim-date"]["Mim-date_month"], "0")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_pubDate"]["Mim-date"]["Mim-date_day"], "0")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_pages"][0]["Mim-page_from"], "1216")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_pages"][0]["Mim-page_to"], "1225")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_pubmedUID"], "8131751")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_ambiguous"], "")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_ambiguous"].attributes["value"], "false")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_noLink"], "")
        self.assertEqual(record[0]["Mim-entry_references"][1]["Mim-reference_noLink"].attributes["value"], "false")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_number"], "3")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_origNumber"], "3")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_type"], "")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_type"].attributes["value"], "citation")
        self.assertEqual(len(record[0]["Mim-entry_references"][2]["Mim-reference_authors"]), 4)
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_authors"][0]["Mim-author_name"], "Reeves, R. H.")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_authors"][0]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_authors"][1]["Mim-author_name"], "Rue, E.")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_authors"][1]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_authors"][2]["Mim-author_name"], "Yu, J.")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_authors"][2]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_authors"][3]["Mim-author_name"], "Kao, F.-T.")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_authors"][3]["Mim-author_index"], "1")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_primaryAuthor"], "Reeves")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_otherAuthors"], "et al.")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_citationTitle"], "Stch maps to mouse chromosome 16, extending the conserved synteny with human chromosome 21.")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_citationType"], "0")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_volume"], "49")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_journal"], "Genomics")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_pubDate"]["Mim-date"]["Mim-date_year"], "1998")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_pubDate"]["Mim-date"]["Mim-date_month"], "0")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_pubDate"]["Mim-date"]["Mim-date_day"], "0")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_pages"][0]["Mim-page_from"], "156")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_pages"][0]["Mim-page_to"], "157")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_pubmedUID"], "9570963")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_ambiguous"], "")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_ambiguous"].attributes["value"], "false")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_noLink"], "")
        self.assertEqual(record[0]["Mim-entry_references"][2]["Mim-reference_noLink"].attributes["value"], "false")
        self.assertEqual(record[0]["Mim-entry_attribution"][0]["Mim-edit-item_author"], "Carol A. Bocchini - updated")
        self.assertEqual(record[0]["Mim-entry_attribution"][0]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_year"], "1999")
        self.assertEqual(record[0]["Mim-entry_attribution"][0]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_month"], "3")
        self.assertEqual(record[0]["Mim-entry_attribution"][0]["Mim-edit-item_modDate"]["Mim-date"]["Mim-date_day"], "7")
        self.assertEqual(record[0]["Mim-entry_numGeneMaps"], "1")
        self.assertEqual(len(record[0]["Mim-entry_medlineLinks"]), 1)
        self.assertEqual(record[0]["Mim-entry_medlineLinks"]["Mim-link"]["Mim-link_num"], "3")
        self.assertEqual(record[0]["Mim-entry_medlineLinks"]["Mim-link"]["Mim-link_uids"], "8825657,8131751,9570963")
        self.assertEqual(record[0]["Mim-entry_medlineLinks"]["Mim-link"]["Mim-link_numRelevant"], "0")
        self.assertEqual(len(record[0]["Mim-entry_proteinLinks"]), 1)
        self.assertEqual(record[0]["Mim-entry_proteinLinks"]["Mim-link"]["Mim-link_num"], "7")
        self.assertEqual(record[0]["Mim-entry_proteinLinks"]["Mim-link"]["Mim-link_uids"], "148747550,67461586,48928056,30089677,2352621,1351125,460148")
        self.assertEqual(record[0]["Mim-entry_proteinLinks"]["Mim-link"]["Mim-link_numRelevant"], "0")
        self.assertEqual(len(record[0]["Mim-entry_nucleotideLinks"]), 1)
        self.assertEqual(record[0]["Mim-entry_nucleotideLinks"]["Mim-link"]["Mim-link_num"], "5")
        self.assertEqual(record[0]["Mim-entry_nucleotideLinks"]["Mim-link"]["Mim-link_uids"], "148747549,55741785,48928055,2352620,460147")
        self.assertEqual(record[0]["Mim-entry_nucleotideLinks"]["Mim-link"]["Mim-link_numRelevant"], "0")

    def test_taxonomy(self):
        '''Test parsing XML returned by EFetch, Taxonomy database
        '''
        # Access the Taxonomy database using efetch.
        # To create the XML file, use
        # >>> Bio.Entrez.efetch(db="taxonomy", id="9685", retmode="xml")
        handle = open('Entrez/taxonomy.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(len(record), 1)
        self.assertEqual(record[0]["TaxId"], "9685")
        self.assertEqual(record[0]["ScientificName"], "Felis catus")
        self.assertEqual(record[0]["OtherNames"]["GenbankCommonName"], "domestic cat")
        self.assertEqual(record[0]["OtherNames"]["Synonym"][0], "Felis silvestris catus")
        self.assertEqual(record[0]["OtherNames"]["Synonym"][1], "Felis domesticus")
        self.assertEqual(record[0]["OtherNames"]["CommonName"][0], "cat")
        self.assertEqual(record[0]["OtherNames"]["CommonName"][1], "cats")
        self.assertEqual(record[0]["OtherNames"]["Includes"][0], "Korat cats")
        self.assertEqual(record[0]["ParentTaxId"], "9682")
        self.assertEqual(record[0]["Rank"], "species")
        self.assertEqual(record[0]["Division"], "Mammals")
        self.assertEqual(record[0]["GeneticCode"]["GCId"], "1")
        self.assertEqual(record[0]["GeneticCode"]["GCName"], "Standard")
        self.assertEqual(record[0]["MitoGeneticCode"]["MGCId"], "2")
        self.assertEqual(record[0]["MitoGeneticCode"]["MGCName"], "Vertebrate Mitochondrial")
        self.assertEqual(record[0]["Lineage"], "cellular organisms; Eukaryota; Fungi/Metazoa group; Metazoa; Eumetazoa; Bilateria; Coelomata; Deuterostomia; Chordata; Craniata; Vertebrata; Gnathostomata; Teleostomi; Euteleostomi; Sarcopterygii; Tetrapoda; Amniota; Mammalia; Theria; Eutheria; Laurasiatheria; Carnivora; Feliformia; Felidae; Felinae; Felis")

        self.assertEqual(record[0]["LineageEx"][0]["TaxId"], "131567")
        self.assertEqual(record[0]["LineageEx"][0]["ScientificName"], "cellular organisms")
        self.assertEqual(record[0]["LineageEx"][0]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][1]["TaxId"], "2759")
        self.assertEqual(record[0]["LineageEx"][1]["ScientificName"], "Eukaryota")
        self.assertEqual(record[0]["LineageEx"][1]["Rank"], "superkingdom")
        self.assertEqual(record[0]["LineageEx"][2]["TaxId"], "33154")
        self.assertEqual(record[0]["LineageEx"][2]["ScientificName"], "Fungi/Metazoa group")
        self.assertEqual(record[0]["LineageEx"][2]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][3]["TaxId"], "33208")
        self.assertEqual(record[0]["LineageEx"][3]["ScientificName"], "Metazoa")
        self.assertEqual(record[0]["LineageEx"][3]["Rank"], "kingdom")
        self.assertEqual(record[0]["LineageEx"][4]["TaxId"], "6072")
        self.assertEqual(record[0]["LineageEx"][4]["ScientificName"], "Eumetazoa")
        self.assertEqual(record[0]["LineageEx"][4]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][5]["TaxId"], "33213")
        self.assertEqual(record[0]["LineageEx"][5]["ScientificName"], "Bilateria")
        self.assertEqual(record[0]["LineageEx"][5]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][6]["TaxId"], "33316")
        self.assertEqual(record[0]["LineageEx"][6]["ScientificName"], "Coelomata")
        self.assertEqual(record[0]["LineageEx"][6]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][7]["TaxId"], "33511")
        self.assertEqual(record[0]["LineageEx"][7]["ScientificName"], "Deuterostomia")
        self.assertEqual(record[0]["LineageEx"][7]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][8]["TaxId"], "7711")
        self.assertEqual(record[0]["LineageEx"][8]["ScientificName"], "Chordata")
        self.assertEqual(record[0]["LineageEx"][8]["Rank"], "phylum")
        self.assertEqual(record[0]["LineageEx"][9]["TaxId"], "89593")
        self.assertEqual(record[0]["LineageEx"][9]["ScientificName"], "Craniata")
        self.assertEqual(record[0]["LineageEx"][9]["Rank"], "subphylum")
        self.assertEqual(record[0]["LineageEx"][10]["TaxId"], "7742")
        self.assertEqual(record[0]["LineageEx"][10]["ScientificName"], "Vertebrata")
        self.assertEqual(record[0]["LineageEx"][10]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][11]["TaxId"], "7776")
        self.assertEqual(record[0]["LineageEx"][11]["ScientificName"], "Gnathostomata")
        self.assertEqual(record[0]["LineageEx"][11]["Rank"], "superclass")
        self.assertEqual(record[0]["LineageEx"][12]["TaxId"], "117570")
        self.assertEqual(record[0]["LineageEx"][12]["ScientificName"], "Teleostomi")
        self.assertEqual(record[0]["LineageEx"][12]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][13]["TaxId"], "117571")
        self.assertEqual(record[0]["LineageEx"][13]["ScientificName"], "Euteleostomi")
        self.assertEqual(record[0]["LineageEx"][13]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][14]["TaxId"], "8287")
        self.assertEqual(record[0]["LineageEx"][14]["ScientificName"], "Sarcopterygii")
        self.assertEqual(record[0]["LineageEx"][14]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][15]["TaxId"], "32523")
        self.assertEqual(record[0]["LineageEx"][15]["ScientificName"], "Tetrapoda")
        self.assertEqual(record[0]["LineageEx"][15]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][16]["TaxId"], "32524")
        self.assertEqual(record[0]["LineageEx"][16]["ScientificName"], "Amniota")
        self.assertEqual(record[0]["LineageEx"][16]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][17]["TaxId"], "40674")
        self.assertEqual(record[0]["LineageEx"][17]["ScientificName"], "Mammalia")
        self.assertEqual(record[0]["LineageEx"][17]["Rank"], "class")
        self.assertEqual(record[0]["LineageEx"][18]["TaxId"], "32525")
        self.assertEqual(record[0]["LineageEx"][18]["ScientificName"], "Theria")
        self.assertEqual(record[0]["LineageEx"][18]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][19]["TaxId"], "9347")
        self.assertEqual(record[0]["LineageEx"][19]["ScientificName"], "Eutheria")
        self.assertEqual(record[0]["LineageEx"][19]["Rank"], "no rank")
        self.assertEqual(record[0]["LineageEx"][20]["TaxId"], "314145")
        self.assertEqual(record[0]["LineageEx"][20]["ScientificName"], "Laurasiatheria")
        self.assertEqual(record[0]["LineageEx"][20]["Rank"], "superorder")
        self.assertEqual(record[0]["LineageEx"][21]["TaxId"], "33554")
        self.assertEqual(record[0]["LineageEx"][21]["ScientificName"], "Carnivora")
        self.assertEqual(record[0]["LineageEx"][21]["Rank"], "order")
        self.assertEqual(record[0]["LineageEx"][22]["TaxId"], "379583")
        self.assertEqual(record[0]["LineageEx"][22]["ScientificName"], "Feliformia")
        self.assertEqual(record[0]["LineageEx"][22]["Rank"], "suborder")
        self.assertEqual(record[0]["LineageEx"][23]["TaxId"], "9681")
        self.assertEqual(record[0]["LineageEx"][23]["ScientificName"], "Felidae")
        self.assertEqual(record[0]["LineageEx"][23]["Rank"], "family")
        self.assertEqual(record[0]["LineageEx"][24]["TaxId"], "338152")
        self.assertEqual(record[0]["LineageEx"][24]["ScientificName"], "Felinae")
        self.assertEqual(record[0]["LineageEx"][24]["Rank"], "subfamily")
        self.assertEqual(record[0]["LineageEx"][25]["TaxId"], "9682")
        self.assertEqual(record[0]["LineageEx"][25]["ScientificName"], "Felis")
        self.assertEqual(record[0]["LineageEx"][25]["Rank"], "genus")
        self.assertEqual(record[0]["CreateDate"], "1995/02/27")
        self.assertEqual(record[0]["UpdateDate"], "2007/09/04")
        self.assertEqual(record[0]["PubDate"], "1993/07/26")

    def test_nucleotide1(self):
        '''Test parsing XML returned by EFetch, Nucleotide database (first test)
        '''
        # Access the nucleotide database using efetch.
        # To create the XML file, use
        # >>> Bio.Entrez.efetch(db='nucleotide', id=5, retmode='xml')
        handle = open('Entrez/nucleotide1.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["GBSeq_locus"], "X60065")
        self.assertEqual(record[0]["GBSeq_length"], "1136")
        self.assertEqual(record[0]["GBSeq_strandedness"], "single")
        self.assertEqual(record[0]["GBSeq_moltype"], "mRNA")
        self.assertEqual(record[0]["GBSeq_topology"], "linear")
        self.assertEqual(record[0]["GBSeq_division"], "MAM")
        self.assertEqual(record[0]["GBSeq_update-date"], "14-NOV-2006")
        self.assertEqual(record[0]["GBSeq_create-date"], "05-MAY-1992")
        self.assertEqual(record[0]["GBSeq_definition"], "B.bovis beta-2-gpI mRNA for beta-2-glycoprotein I")
        self.assertEqual(record[0]["GBSeq_primary-accession"], "X60065")
        self.assertEqual(record[0]["GBSeq_accession-version"], "X60065.1")
        self.assertEqual(record[0]["GBSeq_other-seqids"][0], "emb|X60065.1|")
        self.assertEqual(record[0]["GBSeq_other-seqids"][1], "gi|5")
        self.assertEqual(record[0]["GBSeq_keywords"][0], "beta-2 glycoprotein I")
        self.assertEqual(record[0]["GBSeq_source"], "Bos taurus (cattle)")
        self.assertEqual(record[0]["GBSeq_organism"], "Bos taurus")
        self.assertEqual(record[0]["GBSeq_taxonomy"], "Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Laurasiatheria; Cetartiodactyla; Ruminantia; Pecora; Bovidae; Bovinae; Bos")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_reference"], "1")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_authors"][0], "Bendixen,E.")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_authors"][1], "Halkier,T.")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_authors"][2], "Magnusson,S.")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_authors"][3], "Sottrup-Jensen,L.")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_authors"][4], "Kristensen,T.")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_title"], "Complete primary structure of bovine beta 2-glycoprotein I: localization of the disulfide bridges")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_journal"], "Biochemistry 31 (14), 3611-3617 (1992)")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_pubmed"], "1567819")
        self.assertEqual(record[0]["GBSeq_references"][1]["GBReference_reference"], "2")
        self.assertEqual(record[0]["GBSeq_references"][1]["GBReference_position"], "1..1136")
        self.assertEqual(record[0]["GBSeq_references"][1]["GBReference_authors"][0], "Kristensen,T.")
        self.assertEqual(record[0]["GBSeq_references"][1]["GBReference_title"], "Direct Submission")
        self.assertEqual(record[0]["GBSeq_references"][1]["GBReference_journal"], "Submitted (11-JUN-1991) T. Kristensen, Dept of Mol Biology, University of Aarhus, C F Mollers Alle 130, DK-8000 Aarhus C, DENMARK")
        self.assertEqual(len(record[0]["GBSeq_feature-table"]), 7)
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_key"], "source")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_location"], "1..1136")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_intervals"][0]["GBInterval_from"], "1")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_intervals"][0]["GBInterval_to"], "1136")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_intervals"][0]["GBInterval_accession"], "X60065.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][0]["GBQualifier_name"], "organism")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][0]["GBQualifier_value"], "Bos taurus")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][1]["GBQualifier_name"], "mol_type")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][1]["GBQualifier_value"], "mRNA")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][2]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][2]["GBQualifier_value"], "taxon:9913")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][3]["GBQualifier_name"], "clone")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][3]["GBQualifier_value"], "pBB2I")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][4]["GBQualifier_name"], "tissue_type")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][4]["GBQualifier_value"], "liver")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_key"], "gene")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_location"], "<1..1136")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_intervals"][0]["GBInterval_from"], "1")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_intervals"][0]["GBInterval_to"], "1136")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_intervals"][0]["GBInterval_accession"], "X60065.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_partial5"], "")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_partial5"].attributes["value"], "true")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_quals"][0]["GBQualifier_name"], "gene")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_quals"][0]["GBQualifier_value"], "beta-2-gpI")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_key"], "CDS")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_location"], "<1..1029")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_intervals"][0]["GBInterval_from"], "1")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_intervals"][0]["GBInterval_to"], "1029")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_intervals"][0]["GBInterval_accession"], "X60065.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_partial5"], "")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_partial5"].attributes["value"], "true")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][0]["GBQualifier_name"], "gene")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][0]["GBQualifier_value"], "beta-2-gpI")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][1]["GBQualifier_name"], "codon_start")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][1]["GBQualifier_value"], "1")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][2]["GBQualifier_name"], "transl_table")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][2]["GBQualifier_value"], "1")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][3]["GBQualifier_name"], "product")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][3]["GBQualifier_value"], "beta-2-glycoprotein I")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][4]["GBQualifier_name"], "protein_id")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][4]["GBQualifier_value"], "CAA42669.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][5]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][5]["GBQualifier_value"], "GI:6")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][6]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][6]["GBQualifier_value"], "GOA:P17690")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][7]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][7]["GBQualifier_value"], "UniProtKB/Swiss-Prot:P17690")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][8]["GBQualifier_name"], "translation")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][8]["GBQualifier_value"], "PALVLLLGFLCHVAIAGRTCPKPDELPFSTVVPLKRTYEPGEQIVFSCQPGYVSRGGIRRFTCPLTGLWPINTLKCMPRVCPFAGILENGTVRYTTFEYPNTISFSCHTGFYLKGASSAKCTEEGKWSPDLPVCAPITCPPPPIPKFASLSVYKPLAGNNSFYGSKAVFKCLPHHAMFGNDTVTCTEHGNWTQLPECREVRCPFPSRPDNGFVNHPANPVLYYKDTATFGCHETYSLDGPEEVECSKFGNWSAQPSCKASCKLSIKRATVIYEGERVAIQNKFKNGMLHGQKVSFFCKHKEKKCSYTEDAQCIDGTIEIPKCFKEHSSLAFWKTDASDVKPC")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_key"], "sig_peptide")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_location"], "<1..48")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_intervals"][0]["GBInterval_from"], "1")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_intervals"][0]["GBInterval_to"], "48")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_intervals"][0]["GBInterval_accession"], "X60065.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_partial5"], "")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_partial5"].attributes["value"], "true")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][0]["GBQualifier_name"], "gene")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][0]["GBQualifier_value"], "beta-2-gpI")
        self.assertEqual(record[0]["GBSeq_feature-table"][4]["GBFeature_key"], "mat_peptide")
        self.assertEqual(record[0]["GBSeq_feature-table"][4]["GBFeature_location"], "49..1026")
        self.assertEqual(record[0]["GBSeq_feature-table"][4]["GBFeature_intervals"][0]["GBInterval_from"], "49")
        self.assertEqual(record[0]["GBSeq_feature-table"][4]["GBFeature_intervals"][0]["GBInterval_to"], "1026")
        self.assertEqual(record[0]["GBSeq_feature-table"][4]["GBFeature_intervals"][0]["GBInterval_accession"], "X60065.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][4]["GBFeature_quals"][0]["GBQualifier_name"], "gene")
        self.assertEqual(record[0]["GBSeq_feature-table"][4]["GBFeature_quals"][0]["GBQualifier_value"], "beta-2-gpI")
        self.assertEqual(record[0]["GBSeq_feature-table"][4]["GBFeature_quals"][1]["GBQualifier_name"], "product")
        self.assertEqual(record[0]["GBSeq_feature-table"][4]["GBFeature_quals"][1]["GBQualifier_value"], "beta-2-glycoprotein I")
        self.assertEqual(record[0]["GBSeq_feature-table"][5]["GBFeature_key"], "polyA_signal")
        self.assertEqual(record[0]["GBSeq_feature-table"][5]["GBFeature_location"], "1101..1106")
        self.assertEqual(record[0]["GBSeq_feature-table"][5]["GBFeature_intervals"][0]["GBInterval_from"], "1101")
        self.assertEqual(record[0]["GBSeq_feature-table"][5]["GBFeature_intervals"][0]["GBInterval_to"], "1106")
        self.assertEqual(record[0]["GBSeq_feature-table"][5]["GBFeature_intervals"][0]["GBInterval_accession"], "X60065.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][5]["GBFeature_quals"][0]["GBQualifier_name"], "gene")
        self.assertEqual(record[0]["GBSeq_feature-table"][5]["GBFeature_quals"][0]["GBQualifier_value"], "beta-2-gpI")
        self.assertEqual(record[0]["GBSeq_feature-table"][6]["GBFeature_key"], "polyA_site")
        self.assertEqual(record[0]["GBSeq_feature-table"][6]["GBFeature_location"], "1130")
        self.assertEqual(record[0]["GBSeq_feature-table"][6]["GBFeature_intervals"][0]["GBInterval_point"], "1130")
        self.assertEqual(record[0]["GBSeq_feature-table"][6]["GBFeature_intervals"][0]["GBInterval_accession"], "X60065.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][6]["GBFeature_quals"][0]["GBQualifier_name"], "gene")
        self.assertEqual(record[0]["GBSeq_feature-table"][6]["GBFeature_quals"][0]["GBQualifier_value"], "beta-2-gpI")
        self.assertEqual(record[0]["GBSeq_sequence"], "ccagcgctcgtcttgctgttggggtttctctgccacgttgctatcgcaggacgaacctgccccaagccagatgagctaccgttttccacggtggttccactgaaacggacctatgagcccggggagcagatagtcttctcctgccagccgggctacgtgtcccggggagggatccggcggtttacatgcccgctcacaggactctggcccatcaacacgctgaaatgcatgcccagagtatgtccttttgctgggatcttagaaaacggaacggtacgctatacaacgtttgagtatcccaacaccatcagcttttcttgccacacggggttttatctgaaaggagctagttctgcaaaatgcactgaggaagggaagtggagcccagaccttcctgtctgtgcccctataacctgccctccaccacccatacccaagtttgcaagtctcagcgtttacaagccgttggctgggaacaactccttctatggcagcaaggcagtctttaagtgcttgccacaccacgcgatgtttggaaatgacaccgttacctgcacggaacatgggaactggacgcagttgccagaatgcagggaagtaagatgcccattcccatcaagaccagacaatgggtttgtgaaccatcctgcaaatccagtgctctactataaggacaccgccacctttggctgccatgaaacgtattccttggatggaccggaagaagtagaatgcagcaaattcggaaactggtctgcacagccaagctgtaaagcatcttgtaagttatctattaaaagagctactgtgatatatgaaggagagagagtagctatccagaacaaatttaagaatggaatgctgcatggccaaaaggtttctttcttctgcaagcataaggaaaagaagtgcagctacacagaagatgctcagtgcatagacggcaccatcgagattcccaaatgcttcaaggagcacagttctttagctttctggaaaacggatgcatctgacgtaaaaccatgctaagctggttttcacactgaaaattaaatgtcatgcttatatgtgtctgtctgagaatctgatggaaacggaaaaataaagagactgaatttaccgtgtcaagaaaaaaa")

    def test_nucleotide2(self):
        '''Test parsing XML returned by EFetch, Nucleotide database (second test)
        '''
        # Access the nucleotide database using efetch.
        # To create the XML file, use
        # >>> Bio.Entrez.efetch(db='nucleotide', id=5,
        #                       rettype='fasta', complexity=0, retmode='xml')
        handle = open('Entrez/nucleotide2.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["TSeq_seqtype"], "")
        self.assertEqual(record[0]["TSeq_seqtype"].attributes["value"], "nucleotide")
        self.assertEqual(record[0]["TSeq_gi"], "5")
        self.assertEqual(record[0]["TSeq_accver"], "X60065.1")
        self.assertEqual(record[0]["TSeq_taxid"], "9913")
        self.assertEqual(record[0]["TSeq_orgname"], "Bos taurus")
        self.assertEqual(record[0]["TSeq_defline"], "B.bovis beta-2-gpI mRNA for beta-2-glycoprotein I")
        self.assertEqual(record[0]["TSeq_length"], "1136")
        self.assertEqual(record[0]["TSeq_sequence"], "CCAGCGCTCGTCTTGCTGTTGGGGTTTCTCTGCCACGTTGCTATCGCAGGACGAACCTGCCCCAAGCCAGATGAGCTACCGTTTTCCACGGTGGTTCCACTGAAACGGACCTATGAGCCCGGGGAGCAGATAGTCTTCTCCTGCCAGCCGGGCTACGTGTCCCGGGGAGGGATCCGGCGGTTTACATGCCCGCTCACAGGACTCTGGCCCATCAACACGCTGAAATGCATGCCCAGAGTATGTCCTTTTGCTGGGATCTTAGAAAACGGAACGGTACGCTATACAACGTTTGAGTATCCCAACACCATCAGCTTTTCTTGCCACACGGGGTTTTATCTGAAAGGAGCTAGTTCTGCAAAATGCACTGAGGAAGGGAAGTGGAGCCCAGACCTTCCTGTCTGTGCCCCTATAACCTGCCCTCCACCACCCATACCCAAGTTTGCAAGTCTCAGCGTTTACAAGCCGTTGGCTGGGAACAACTCCTTCTATGGCAGCAAGGCAGTCTTTAAGTGCTTGCCACACCACGCGATGTTTGGAAATGACACCGTTACCTGCACGGAACATGGGAACTGGACGCAGTTGCCAGAATGCAGGGAAGTAAGATGCCCATTCCCATCAAGACCAGACAATGGGTTTGTGAACCATCCTGCAAATCCAGTGCTCTACTATAAGGACACCGCCACCTTTGGCTGCCATGAAACGTATTCCTTGGATGGACCGGAAGAAGTAGAATGCAGCAAATTCGGAAACTGGTCTGCACAGCCAAGCTGTAAAGCATCTTGTAAGTTATCTATTAAAAGAGCTACTGTGATATATGAAGGAGAGAGAGTAGCTATCCAGAACAAATTTAAGAATGGAATGCTGCATGGCCAAAAGGTTTCTTTCTTCTGCAAGCATAAGGAAAAGAAGTGCAGCTACACAGAAGATGCTCAGTGCATAGACGGCACCATCGAGATTCCCAAATGCTTCAAGGAGCACAGTTCTTTAGCTTTCTGGAAAACGGATGCATCTGACGTAAAACCATGCTAAGCTGGTTTTCACACTGAAAATTAAATGTCATGCTTATATGTGTCTGTCTGAGAATCTGATGGAAACGGAAAAATAAAGAGACTGAATTTACCGTGTCAAGAAAAAAA")
        self.assertEqual(record[1]["TSeq_seqtype"], "")
        self.assertEqual(record[1]["TSeq_seqtype"].attributes["value"], "protein")
        self.assertEqual(record[1]["TSeq_gi"], "6")
        self.assertEqual(record[1]["TSeq_accver"], "CAA42669.1")
        self.assertEqual(record[1]["TSeq_taxid"], "9913")
        self.assertEqual(record[1]["TSeq_orgname"], "Bos taurus")
        self.assertEqual(record[1]["TSeq_defline"], "beta-2-glycoprotein I [Bos taurus]")
        self.assertEqual(record[1]["TSeq_length"], "342")
        self.assertEqual(record[1]["TSeq_sequence"], "PALVLLLGFLCHVAIAGRTCPKPDELPFSTVVPLKRTYEPGEQIVFSCQPGYVSRGGIRRFTCPLTGLWPINTLKCMPRVCPFAGILENGTVRYTTFEYPNTISFSCHTGFYLKGASSAKCTEEGKWSPDLPVCAPITCPPPPIPKFASLSVYKPLAGNNSFYGSKAVFKCLPHHAMFGNDTVTCTEHGNWTQLPECREVRCPFPSRPDNGFVNHPANPVLYYKDTATFGCHETYSLDGPEEVECSKFGNWSAQPSCKASCKLSIKRATVIYEGERVAIQNKFKNGMLHGQKVSFFCKHKEKKCSYTEDAQCIDGTIEIPKCFKEHSSLAFWKTDASDVKPC")

    def test_nucleotide2(self):
        '''Test parsing XML returned by EFetch, Protein database
        '''
        # Access the protein database using efetch.
        # To create the XML file, use
        # >>> Bio.Entrez.efetch(db='protein', id=8, rettype='gp', retmode='xml')
        handle = open('Entrez/protein.xml', "rb")
        record = Entrez.read(handle)
        handle.close()
        self.assertEqual(record[0]["GBSeq_locus"], "CAA35997")
        self.assertEqual(record[0]["GBSeq_length"], "100")
        self.assertEqual(record[0]["GBSeq_moltype"], "AA")
        self.assertEqual(record[0]["GBSeq_topology"], "linear")
        self.assertEqual(record[0]["GBSeq_division"], "MAM")
        self.assertEqual(record[0]["GBSeq_update-date"], "12-SEP-1993")
        self.assertEqual(record[0]["GBSeq_create-date"], "03-APR-1990")
        self.assertEqual(record[0]["GBSeq_definition"], "unnamed protein product [Bos taurus]")
        self.assertEqual(record[0]["GBSeq_primary-accession"], "CAA35997")
        self.assertEqual(record[0]["GBSeq_accession-version"], "CAA35997.1")
        self.assertEqual(record[0]["GBSeq_other-seqids"][0], "emb|CAA35997.1|")
        self.assertEqual(record[0]["GBSeq_other-seqids"][1], "gi|8")
        self.assertEqual(record[0]["GBSeq_source"], "Bos taurus (cattle)")
        self.assertEqual(record[0]["GBSeq_organism"], "Bos taurus")
        self.assertEqual(record[0]["GBSeq_taxonomy"], "Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Laurasiatheria; Cetartiodactyla; Ruminantia; Pecora; Bovidae; Bovinae; Bos")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_reference"], "1")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_position"], "1..100")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_authors"][0], "Kiefer,M.C.")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_authors"][1], "Saphire,A.C.S.")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_authors"][2], "Bauer,D.M.")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_authors"][3], "Barr,P.J.")
        self.assertEqual(record[0]["GBSeq_references"][0]["GBReference_journal"], "Unpublished")
        self.assertEqual(record[0]["GBSeq_references"][1]["GBReference_reference"], "2")
        self.assertEqual(record[0]["GBSeq_references"][1]["GBReference_position"], "1..100")
        self.assertEqual(record[0]["GBSeq_references"][1]["GBReference_authors"][0], "Kiefer,M.C.")
        self.assertEqual(record[0]["GBSeq_references"][1]["GBReference_title"], "Direct Submission")
        self.assertEqual(record[0]["GBSeq_references"][1]["GBReference_journal"], "Submitted (30-JAN-1990) Kiefer M.C., Chiron Corporation, 4560 Hortom St, Emeryville CA 94608-2916, U S A")
        self.assertEqual(record[0]["GBSeq_comment"], "See <X15699> for Human sequence.~Data kindly reviewed (08-MAY-1990) by Kiefer M.C.")
        self.assertEqual(record[0]["GBSeq_source-db"], "embl accession X51700.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_key"], "source")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_location"], "1..100")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_intervals"][0]["GBInterval_from"], "1")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_intervals"][0]["GBInterval_to"], "100")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_intervals"][0]["GBInterval_accession"], "CAA35997.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][0]["GBQualifier_name"], "organism")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][0]["GBQualifier_value"], "Bos taurus")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][1]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][1]["GBQualifier_value"], "taxon:9913")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][2]["GBQualifier_name"], "clone")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][2]["GBQualifier_value"], "bBGP-3")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][3]["GBQualifier_name"], "tissue_type")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][3]["GBQualifier_value"], "bone matrix")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][4]["GBQualifier_name"], "clone_lib")
        self.assertEqual(record[0]["GBSeq_feature-table"][0]["GBFeature_quals"][4]["GBQualifier_value"], "Zap-bb")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_key"], "Protein")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_location"], "1..100")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_intervals"][0]["GBInterval_from"], "1")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_intervals"][0]["GBInterval_to"], "100")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_intervals"][0]["GBInterval_accession"], "CAA35997.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_quals"][0]["GBQualifier_name"], "name")
        self.assertEqual(record[0]["GBSeq_feature-table"][1]["GBFeature_quals"][0]["GBQualifier_value"], "unnamed protein product")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_key"], "Region")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_location"], "33..97")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_intervals"][0]["GBInterval_from"], "33")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_intervals"][0]["GBInterval_to"], "97")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_intervals"][0]["GBInterval_accession"], "CAA35997.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][0]["GBQualifier_name"], "region_name")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][0]["GBQualifier_value"], "Gla")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][1]["GBQualifier_name"], "note")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][1]["GBQualifier_value"], "Vitamin K-dependent carboxylation/gamma-carboxyglutamic (GLA) domain. This domain is responsible for the high-affinity binding of calcium ions. This domain contains post-translational modifications of many glutamate residues by Vitamin K-dependent...; cl02449")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][2]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][2]["GBFeature_quals"][2]["GBQualifier_value"], "CDD:92835")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_key"], "CDS")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_location"], "1..100")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_intervals"][0]["GBInterval_from"], "1")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_intervals"][0]["GBInterval_to"], "100")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_intervals"][0]["GBInterval_accession"], "CAA35997.1")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][0]["GBQualifier_name"], "coded_by")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][0]["GBQualifier_value"], "X51700.1:28..330")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][1]["GBQualifier_name"], "note")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][1]["GBQualifier_value"], "bone Gla precursor (100 AA)")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][2]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][2]["GBQualifier_value"], "GOA:P02820")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][3]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][3]["GBQualifier_value"], "InterPro:IPR000294")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][4]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][4]["GBQualifier_value"], "InterPro:IPR002384")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][5]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][5]["GBQualifier_value"], "PDB:1Q3M")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][6]["GBQualifier_name"], "db_xref")
        self.assertEqual(record[0]["GBSeq_feature-table"][3]["GBFeature_quals"][6]["GBQualifier_value"], "UniProtKB/Swiss-Prot:P02820")
        self.assertEqual(record[0]["GBSeq_sequence"], "mrtpmllallalatlclagradakpgdaesgkgaafvskqegsevvkrlrryldhwlgapapypdplepkrevcelnpdcdeladhigfqeayrrfygpv")

    def test_genbank(self):
        '''Test error handling when presented with GenBank non-XML data
        '''
        # Access the nucleotide database using efetch, but return the data
        # in GenBank format.
        # To create the GenBank file, use
        # >>> Bio.Entrez.efetch(db='nucleotide', id='NT_019265', rettype='gb')
        from Bio.Entrez import Parser
        handle = open('GenBank/NT_019265.gb', "rb")
        self.assertRaises(Parser.NotXMLError, Entrez.read, handle)
        handle.close()
        handle = open('GenBank/NT_019265.gb', "rb")
        iterator = Entrez.parse(handle)
        self.assertRaises(Parser.NotXMLError, next, iterator)
        handle.close()

    def test_fasta(self):
        '''Test error handling when presented with Fasta non-XML data
        '''
        from Bio.Entrez import Parser
        handle = open('Fasta/wisteria.nu', "rb")
        self.assertRaises(Parser.NotXMLError, Entrez.read, handle)
        handle.close()
        handle = open('Fasta/wisteria.nu', "rb")
        iterator = Entrez.parse(handle)
        self.assertRaises(Parser.NotXMLError, next, iterator)
        handle.close()

    def test_pubmed_html(self):
        '''Test error handling when presented with HTML (so XML-like) data
        '''
        # To create the HTML file, use
        # >>> Bio.Entrez.efetch(db="pubmed", id="19304878")
        from Bio.Entrez import Parser
        handle = open('Entrez/pubmed3.html', "rb")
        self.assertRaises(Parser.NotXMLError, Entrez.read, handle)
        handle.close()
        # Test if the error is also raised with Entrez.parse
        handle = open('Entrez/pubmed3.html', "rb")
        records = Entrez.parse(handle)
        self.assertRaises(Parser.NotXMLError, next, records)
        handle.close()

    def test_xml_without_declaration(self):
        '''Test error handling for a missing XML declaration
        '''
        # To create the XML file, use
        # >>> Bio.Entrez.efetch(db="journals",id="2830,6011,7473",retmode='xml')
        from Bio.Entrez import Parser
        handle = open('Entrez/journals.xml', "rb")
        self.assertRaises(Parser.NotXMLError, Entrez.read, handle)
        handle.close()
        # Test if the error is also raised with Entrez.parse
        handle = open('Entrez/journals.xml', "rb")
        records = Entrez.parse(handle)
        self.assertRaises(Parser.NotXMLError, next, records)
        handle.close()

    def test_truncated_xml(self):
        """Test error handling for a truncated XML declaration"""
        from Bio.Entrez.Parser import CorruptedXMLError
        from Bio._py3k import StringIO
        truncated_xml = """<?xml version="1.0"?>
        <!DOCTYPE GBSet PUBLIC "-//NCBI//NCBI GBSeq/EN" "http://www.ncbi.nlm.nih.gov/dtd/NCBI_GBSeq.dtd">
        <GBSet><GBSeq><GBSeq_locus>
        """
        handle = StringIO()
        handle.write(truncated_xml)
        handle.seek(0)
        records = Entrez.parse(handle)
        self.assertRaises(CorruptedXMLError, next, records)

if __name__ == '__main__':
    runner = unittest.TextTestRunner(verbosity=2)
    unittest.main(testRunner=runner)
