Skip to content

Commit a5f3c73

Browse files
committed
Add dialog box to Taxonomy download, check if user wants to download
1 parent eddb77e commit a5f3c73

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

BioPythonUtils.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def run(self, edit):
6464
print("Entrez count: {}".format(ids['Count']))
6565
dialog_result = sublime.ok_cancel_dialog(
6666
"Download {0} sequences? 'retmax': {1}".format(ids['Count'],
67-
entrez_retmax), 'Download')
67+
entrez_retmax), 'Download')
6868

6969
if dialog_result is True:
7070
try:
@@ -216,24 +216,33 @@ def run(self, edit):
216216

217217
if len(links[0]["LinkSetDb"]) == 0:
218218
sublime.error_message(
219-
"No sequences retrieved with id " + taxid)
219+
"No sequences found with id " + taxid)
220220
return
221221

222+
nt_ids = list()
222223
for link in links[0]["LinkSetDb"][0]["Link"]:
224+
nt_ids.append(link["Id"])
225+
226+
print("Entrez count: {}".format(len(nt_ids)))
227+
dialog_result = sublime.ok_cancel_dialog(
228+
"Download {} sequences?".format(len(nt_ids)), 'Download')
229+
230+
if dialog_result is True:
223231
try:
224232
handle = Entrez.efetch(db="nucleotide",
225-
id=link['Id'],
233+
id=nt_ids,
226234
rettype="gb",
227235
retmode="text")
228236
except (IOError) as exception:
229237
print(str(exception))
230-
sublime.error_message("Error retrieving sequence using id \
231-
'" + link['Id'] + "':" + str(exception))
238+
sublime.error_message("Error retrieving sequences using id \
239+
'" + taxid + "':" + str(exception))
232240

233-
seq_txt = seq_txt + handle.read()
241+
seq_txt = handle.read()
234242

235-
# Write the fasta string to a new window at position 0
236-
self.view.window().new_file().insert(edit, 0, seq_txt)
243+
# Write the fasta string to a new window at position 0
244+
if seq_txt:
245+
self.view.window().new_file().insert(edit, 0, seq_txt)
237246

238247

239248
# "Translate"

test/test.gbk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ FEATURES Location/Qualifiers
5959
mat_peptide 1033..1698
6060
/gene="HA"
6161
/product="HA2"
62-
ORIGIN
62+
ORIGIN
6363
1 atgaaggcaa tactagtagt tctgctatat acatttgcaa ccgcaaatgc agacacatta
6464
61 tgtataggtt atcatgcgaa caattcaaca gacactgtag acacagtact agaaaagaat
6565
121 gtaacagtaa cacactctgt taaccttcta gaagacaagc ataacgggaa actatgcaaa
@@ -164,7 +164,7 @@ FEATURES Location/Qualifiers
164164
TNGTSKIKMKWGMEMRRCLLQSLQQIESMIEAESSVKEKDMTKEFFENKSETWPIGES
165165
PRGVEEGSIGKVCRTLLAKSVFNSLYASPQLEGFSAESRKLLLIVQALRDNLEPGTFD
166166
LGGLYEAIEECLINDPWVLLNASWFNSFLTHALK"
167-
ORIGIN
167+
ORIGIN
168168
1 atggaagact ttgtgcgaca atgcttcaat ccaatgatcg tcgagcttgc ggaaaaggca
169169
61 atgaaagaat atggggaaga tccgaaaatc gaaactaaca agtttgctgc aatatgcaca
170170
121 catttggaag tttgtttcat gtattcggat ttccatttca tcgacgaacg gggtgaatca

0 commit comments

Comments
 (0)