def check_db():
global options
if options.reference_fa_base:
time0 = time.time()
ref_fasta = read_fasta(options.reference_fa_base)
if len(ref_fasta[0]) > 1:
options.reference_fa_base += '.1st.fasta'
write_fasta(out_dir=options.reference_fa_base, matrix=[[ref_fasta[0][0]], [ref_fasta[1][0]], ref_fasta[2]], overwrite=True)
sys.stdout.write('\nWarning: multi-seqs in reference file, only use the 1st sequence.')
elif len(ref_fasta[0]) == 0:
sys.stdout.write('\nError: illegal reference file!')
exit()
try:
# python2
makedb_result = subprocess.getstatusoutput('makeblastdb -dbtype nucl -in '+options.reference_fa_base+' -out '+options.reference_fa_base+'.index')
except AttributeError:
# python3
makedb_result = commands.getstatusoutput('makeblastdb -dbtype nucl -in ' + options.reference_fa_base + ' -out ' + options.reference_fa_base + '.index')
if 'Error' in str(makedb_result[1]) or 'error' in str(makedb_result[1]) or '?????????' in str(makedb_result[1]):
os.system('makeblastdb -dbtype nucl -in '+options.reference_fa_base+' -out '+options.reference_fa_base+'.index')
if not os.path.exists(options.reference_fa_base+'.index.nhr'):
sys.stdout.write('Blast terminated with following info:\n'+str(makedb_result[1]))
exit()
in_index = options.reference_fa_base+'.index'
sys.stdout.write('\nMaking BLAST db cost '+str(time.time()-time0))
else:
sys.stdout.write('\nError: No reference input!')
exit()
return in_index
join_spades_fastg_by_blast.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录