Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions BioCompass/BioCompass.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def parse_antiSMASH(content):


QueryCluster = OrderedDict()
for k in re.search(
for k in list(re.search(
rule_query_cluster, parsed['QueryCluster'],
re.VERBOSE).groupdict().keys():
re.VERBOSE).groupdict().keys()):
QueryCluster[k] = []
for row in re.finditer(
rule_query_cluster, parsed['QueryCluster'], re.VERBOSE):
Expand Down Expand Up @@ -186,7 +186,7 @@ def __getitem__(self, item):
return self.data[item]

def keys(self):
return self.data.keys()
return list(self.data.keys())

def load(self, filename):
self.data = {}
Expand Down Expand Up @@ -221,8 +221,8 @@ def efetch_hit(term, seq_start, seq_stop):
downloaded = True
except:
nap = ntry*3
print "Fail to download (term). I'll take a nap of %s seconds ", \
" and try again."
print("Fail to download (term). I'll take a nap of %s seconds ", \
" and try again.")
time.sleep(ntry*3)

return content
Expand All @@ -233,7 +233,7 @@ def download_hits(filename, output_path):
"""
c = antiSMASH_file(filename)

for cs in c['SignificantHits'].keys():
for cs in list(c['SignificantHits'].keys()):
locus = c['SignificantHits'][cs]['locus']
table_genes = c['SignificantHits'][cs]['TableGenes']

Expand All @@ -244,25 +244,25 @@ def download_hits(filename, output_path):
max(table_genes['location_end'])))

if os.path.isfile(filename_out):
print "Already downloaded %s" % filename_out
print("Already downloaded %s" % filename_out)
else:
print "Requesting cluster_subject: %s, start: %s, end: %s" % (
print("Requesting cluster_subject: %s, start: %s, end: %s" % (
locus,
min(table_genes['location_start']),
max(table_genes['location_end']))
max(table_genes['location_end'])))

content = efetch_hit(
term=locus,
seq_start=min(table_genes['location_start']),
seq_stop=max(table_genes['location_end']))

print "Saving %s" % filename_out
print("Saving %s" % filename_out)
with open(filename_out, 'w') as f:
f.write(content)


import urlparse
import urllib2
import urllib.parse
import urllib.request, urllib.error, urllib.parse
import tempfile
import tarfile
import os
Expand All @@ -274,10 +274,10 @@ def download_mibig(outputdir, version='1.3'):

server = 'http://mibig.secondarymetabolites.org'
filename = "mibig_gbk_%s.tar.gz" % version
url = urlparse.urljoin(server, filename)
url = urllib.parse.urljoin(server, filename)

with tempfile.NamedTemporaryFile(delete=True) as f:
u = urllib2.urlopen(url)
u = urllib.request.urlopen(url)
f.write(u.read())
f.file.flush()
tar = tarfile.open(f.name)
Expand Down
Loading