source/taxid-to-taxonomy.py
def SwapTaxidViaEntrez(taxid):
    """Fetch the record for taxid from NCBI Entrez and return the current taxid."""

    from Bio import Entrez
    Entrez.email = 'johannes.asplund.samuelsson@scilifelab.se'

    print("Contacting NCBI Entrez regarding taxid %s..." % (taxid))

    handle = Entrez.efetch(db='taxonomy', id=taxid)
    record = Entrez.read(handle)
    if len(record) == 0:
        print("Warning: Taxid %s is not available in the NCBI taxonomy database. Returning 32644 - Unknown." % taxid)
        return '32644' # "Unknown"
    current_taxid = record[0]['TaxId']

    print("Swapping taxid %s for taxid %s, via NCBI Entrez." % (taxid, current_taxid))

    return current_taxid
Fetch the record for taxid from NCBI Entrez and return the current taxid.
Fetch the record for taxid from NCBI Entrez and return the current taxid.
Fetch the record for taxid from NCBI Entrez and return the current taxid .
def SwapTaxidViaEntrez(taxid):
    from Bio import Entrez
    Entrez.email = 'johannes.asplund.samuelsson@scilifelab.se'
    print("Contacting NCBI Entrez regarding taxid %s..." % (taxid))
    handle = Entrez.efetch(db='taxonomy', id=taxid)
    record = Entrez.read(handle)
    if len(record) == 0:
        print("Warning: Taxid %s is not available in the NCBI taxonomy database. Returning 32644 - Unknown." % taxid)
        return '32644' 
    current_taxid = record[0]['TaxId']
    print("Swapping taxid %s for taxid %s, via NCBI Entrez." % (taxid, current_taxid))
    return current_taxid
def SwapTaxidViaEntrez ( taxid ) : from Bio import Entrez Entrez . email = 'johannes.asplund.samuelsson@scilifelab.se' print ( "Contacting NCBI Entrez regarding taxid %s..." % ( taxid ) ) handle = Entrez . efetch ( db = 'taxonomy' , id = taxid ) record = Entrez . read ( handle ) if len ( record ) == 0 : print ( "Warning: Taxid %s is not available in the NCBI taxonomy database. Returning 32644 - Unknown." % taxid ) return '32644' current_taxid = record [ 0 ] [ 'TaxId' ] print ( "Swapping taxid %s for taxid %s, via NCBI Entrez." % ( taxid , current_taxid ) ) return current_taxid
Fetch the record for taxid from NCBI Entrez and return the current taxid.
Fetch the record for taxid from NCBI Entrez and return the current taxid .
"""Fetch the record for taxid from NCBI Entrez and return the current taxid.""" # "Unknown"
taxid