Skip to content

Instantly share code, notes, and snippets.

@jeetsukumaran
Created May 24, 2011 01:52
Show Gist options
  • Save jeetsukumaran/988016 to your computer and use it in GitHub Desktop.
Save jeetsukumaran/988016 to your computer and use it in GitHub Desktop.
Using DendroPy to Download GenBank Data
#! /usr/bin/env python
from dendropy.interop import ncbi
entrez = ncbi.Entrez(generate_labels=True,
label_num_desc_components=2,
label_separator='_',
exclude_gbnum_from_label=True,
sort_taxa_by_label=True)
cr_ids = ["EU%d" % i for i in range(888892, 888900)] + \
["DQ885482", "DQ885485", "DQ885486"]
atpase_ids = ["EU%d" % i for i in range(910196, 910206)] + \
["DQ886665", "DQ886667", "DQ886668"]
s7_nums = range(379563, 379566) + range(910206, 910215)
s7_ids = ["EU%d" % i for i in s7_nums]
name_ids_map = { "cr" : cr_ids, "atpase" : atpase_ids, "s7" : s7_ids }
output_prefix = "wobbegong"
for name, ids in name_ids_map.items():
data = entrez.fetch_nucleotide_accessions(ids)
data.write_to_path(output_prefix + "_" + name + ".unaligned.fasta",
"fasta")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment