Last active
August 29, 2015 14:10
-
-
Save fomightez/e9f82ce5106dd0be6ea6 to your computer and use it in GitHub Desktop.
ELink use keeping order of output uids same as input order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print "\n\n\n\n\nSetting up .... \n" | |
| from Bio import Entrez | |
| Entrez.email = "[email protected]" # Always tell NCBI who you are | |
| protein_gi_numbers = ["148908191", "297793721", "48525513", "507118461"] | |
| print "protein_gi_numbers to get are" + str(protein_gi_numbers) | |
| taxonomy_uids = [] | |
| #ELink step | |
| print "performing ELink step....\n" | |
| handle = Entrez.elink(dbfrom="protein", db="taxonomy", id=protein_gi_numbers) | |
| result = Entrez.read(handle) | |
| handle.close() | |
| #Mine the results | |
| print "Mining results....\n" | |
| for each_record in result: | |
| taxonomy_id = each_record["LinkSetDb"][0]["Link"][0]["Id"] | |
| taxonomy_uids.append(taxonomy_id) | |
| #Report | |
| #print result | |
| print "Resulting taxonomy record ids are:" | |
| print taxonomy_uids |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment