Legacy code from Centrifuge
Closed this issue · 1 comments
syncrotron commented
MICAS/server/app/main/utils/tasks.py
Lines 79 to 142 in 57338a1
if bacteria or archaea or virus: | |
# Construct db_string first | |
db_list = [] | |
if bacteria: | |
db_list.append('bacteria') | |
if archaea: | |
db_list.append('archaea') | |
if virus: | |
db_list.append('viral') | |
db_string = ",".join([str(x) for x in db_list]) | |
logger.debug("DOWNLOAD_DATABASE: Downloading " + db_string + " database(s) from NCBI") | |
self.update_state( | |
state="PROGRESS", | |
meta={ | |
'percent-done': 55, | |
'message' : "Downloading " + db_string + " database(s) from NCBI", | |
'project_id' : project_id | |
} | |
) | |
cmd = ['centrifuge-download -o ' + app_location_database + 'library -m -d ' + db_string + ' refseq'] | |
logger.debug(f"CMD:\n {cmd}") | |
outfile = open(app_location_database + 'seqid2taxid.map', 'a+') | |
err_file = open(app_location_database + 'download_err.txt', 'w+') | |
try: | |
# Download the database. | |
download_db_cmd_output = subprocess.Popen( | |
cmd, | |
shell=True, | |
stdout=outfile, | |
stderr=err_file | |
) | |
download_db_cmd_output.communicate() | |
download_db_cmd_output.wait() | |
except (OSError, subprocess.CalledProcessError) as exception: | |
logger.error(str(exception)) | |
return "ER1" | |
else: | |
logger.debug("DOWNLOAD_DATABASE: Successfully downloaded " + db_string + " database(s) from NCBI") | |
self.update_state( | |
state="PROGRESS", | |
meta={ | |
'percent-done': 90, | |
'message' : "Successfully downloaded " + db_string + "database(s) from NCBI", | |
'project_id' : project_id | |
} | |
) | |
import glob | |
# Putting all the query sequences in one, input_sequences file. | |
logger.debug("DOWNLOAD_DATABASE: Concatenating all the sequence files.") | |
self.update_state(state="PROGRESS", | |
meta={'percent-done': 95, 'message': "Concatenating all the sequence files.", | |
'project_id' : project_id} | |
) | |
with open(app_location_database + 'input_sequences.fa', 'wb') as outfile: | |
for filename in glob.glob(app_location_database + 'library/*/*.fna'): | |
with open(filename, 'rb') as readfile: | |
shutil.copyfileobj(readfile, outfile) |
The above code chunk is left over from our old use of centrifuge. This now does nothing but produce errors, and should be removed or updated.
syncrotron commented
This was resolved in the merge of "Centrifuge Cleanup"