Commit d4590097 authored by carlosribas's avatar carlosribas
Browse files

Download RNAcentral ids as plain text

parent 57ce7726
......@@ -133,15 +133,15 @@ def export_search_results(query, _format, hits):
JSON requires special treatment in order to concatenate
multiple batches
"""
filename = os.path.join(EXPORT_RESULTS_DIR,
'%s.%s.gz' % (job.id, _format))
filename = os.path.join(EXPORT_RESULTS_DIR, '%s.%s.gz' % (job.id, _format))
start = 0
page_size = 100 # max EBI search page size
if _format in ['json', 'list']:
archive = gzip.open(filename, 'wb')
if _format == 'list':
archive = open(filename, 'wb')
if _format == 'json':
archive.write('[')
archive = gzip.open(filename, 'wb')
archive.write(b'[')
if _format == 'fasta':
f = tempfile.NamedTemporaryFile(delete=True, dir=EXPORT_RESULTS_DIR)
......@@ -154,7 +154,6 @@ def export_search_results(query, _format, hits):
for _id in rnacentral_ids:
f.write('{0}\n'.format(_id))
if _format == 'list':
archive.write('RNAcentral Ids: \n')
text = '\n'.join(rnacentral_ids) + '\n'
archive.write(text)
if _format == 'json':
......@@ -229,8 +228,11 @@ def download_search_result_file(request):
name = query[:max_length] + '_etc'
else:
name = query
filename = name + '.' + job.meta['format'] + extension
return get_valid_filename(filename)
if job.meta['format'] == 'list':
return get_valid_filename(name + '.' + job.meta['format'])
else:
return get_valid_filename(name + '.' + job.meta['format'] + extension)
def get_content_type():
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment