docs: def calculate_bbh(blast_results_1, blast_results_2, r_name=None, g_name=None, outdir=''):
      """Calculate the best bidirectional BLAST hits (BBH) and save a dataframe of results.
  
      Args:
          blast_results_1 (str): BLAST results for reference vs. other genome
          blast_results_2 (str): BLAST results for other vs. reference genome
          r_name: Name of reference genome
          g_name: Name of other genome
          outdir: Directory where BLAST results are stored.
  
      Returns:
          Path to Pandas DataFrame of the BBH results.
  
      """
      # TODO: add force_rerun option
  
      cols = ['gene', 'subject', 'PID', 'alnLength', 'mismatchCount', 'gapOpenCount', 'queryStart', 'queryEnd',
              'subjectStart', 'subjectEnd', 'eVal', 'bitScore']
  
      if not r_name and not g_name:
          r_name = op.basename(blast_results_1).split('_vs_')[0]
          g_name = op.basename(blast_results_1).split('_vs_')[1].replace('_blast.out', '')
  
          r_name2 = op.basename(blast_results_2).split('_vs_')[1].replace('_blast.out', '')
          if r_name != r_name2:
              log.warning('{} != {}'.format(r_name, r_name2))
  
      outfile = op.join(outdir, '{}_vs_{}_bbh.csv'.format(r_name, g_name))
      if op.exists(outfile) and os.stat(outfile).st_size != 0:
          log.debug('{} vs {} BLAST BBHs already found at {}'.format(r_name, g_name, outfile))
          return outfile
  
      bbh1 = pd.read_csv(blast_results_1, sep='\t', names=cols)
      bbh2 = pd.read_csv(blast_results_2, sep='\t', names=cols)
  
      out = pd.DataFrame()
      log.debug('Finding BBHs for {} vs. {}'.format(r_name, g_name))
  
      for g in bbh1[pd.notnull(bbh1.gene)].gene.unique():
          res = bbh1[bbh1.gene == g]
          if len(res) == 0:
              continue
          best_hit = res.ix[res.PID.idxmax()].copy()
          best_gene = best_hit.subject
          res2 = bbh2[bbh2.gene == best_gene]
          if len(res2) == 0:
              continue
          best_hit2 = res2.ix[res2.PID.idxmax()]
          best_gene2 = best_hit2.subject
          if g == best_gene2:
              best_hit['BBH'] = '<=>'
          else:
              best_hit['BBH'] = '->'
          out = pd.concat([out, pd.DataFrame(best_hit).transpose()])
  
      out.to_csv(outfile)
      log.debug('{} vs {} BLAST BBHs saved at {}'.format(r_name, g_name, outfile))
      return outfile