code: def blast(query, db, type, out, threads = '4', maxtargets = '100', megablast = False):
      
      if os.path.exists(out) is False:
          db = blastdb(db) # make the database file, if necessary 
          print('# ... running blast with %s as query and %s as database' % (query, db))
          if type == 'nucl':
              blast = 'blastn'
              if megablast == True:
                  blast = 'blastn -task megablast'
          else:
              blast = 'blastp'
          os.system('%s \
                  -query %s -db %s -out %s -outfmt 6 \
                  -max_target_seqs %s -num_threads %s >> log.txt' \
                  % (blast, query, db, out, maxtargets, threads))
      else:
          print('# ... blast output found for %s as query and %s as database' % (query, db))
docs: run blast