How to get organism kingdom of an organism.
1
0
Entering edit mode
10.0 years ago
dobule ▴ 10

I want to get a Organism kingdom of an organism(esearch id) through ncbi taxonomy database, is there any method to do it.

EDIT:Sorry i want to search for the organism kingdom for that matter.

ncbi taxonomy • 2.3k views
ADD COMMENT
1
Entering edit mode
9.9 years ago

There are many different ways, here's one way using Biopython. First, I checked the database using a webbrowser for Brassica napus: http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=3708

If you hover over the name at the top, you'll see that the kingdom is Viridiplantae.

In BioPython:

from Bio import Entrez
Entrez.email = "some_email@somewhere.edu.au" # we're nice and tell our address
handle = Entrez.esearch(db='taxonomy', term='Brassica napus', retmax=2, usehistory='y') # return 2 entries at the most - I expect only 1
search_results = Entrez.read(handle)
handle.close()
count = int(search_results['Count'])
print('Got %s records' %count) # should be 1

# get the cookies from the search
webenv = search_results["WebEnv"]
query_key = search_results["QueryKey"]

# download results from the database using our cookies from above

fetch_handle = Entrez.efetch(db='taxonomy', retmode='xml', webenv=webenv, query_key=query_key)
records = Entrez.read(fetch_handle)
assert len(records) == 1 # die if we get more than one record, unlikely?
lineage = records[0]['LineageEx'] # get the entire lineage of the first record
for entry in lineage:
    if entry['Rank'] == 'kingdom':
        print(entry) # prints: {u'ScientificName': 'Viridiplantae', u'TaxId': '33090', u'Rank': 'kingdom '}
        print(entry['ScientificName']) # prints: 'Viridiplantae'
fetch_handle.close()
ADD COMMENT

Login before adding your answer.

Traffic: 3067 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6