def compare_genomes(fastas, id2desc, algorithm):
hits = {}<EOL>for pair in itertools.permutations(fastas, <NUM_LIT:2>):<EOL><INDENT>if pair[<NUM_LIT:0>] not in hits:<EOL><INDENT>hits[pair[<NUM_LIT:0>]] = {}<EOL><DEDENT>hits[pair[<NUM_LIT:0>]][pair[<NUM_LIT:1>]] = {}<EOL><DEDENT>for pair in itertools.combinations(fastas, <NUM_LIT:2>):<EOL><INDENT>A, B = pair<EOL>blastF = open(search(A, B, method = algorithm, alignment = '<STR_LIT>'))<EOL>blastR = open(search(B, A, method = algorithm, alignment = '<STR_LIT>'))<EOL>for compare in [A, B, blastF], [B, A, blastR]:<EOL><INDENT>query, ref, blast = compare<EOL>for hit in best_blast(blast, <NUM_LIT:1>):<EOL><INDENT>a, b, pident, qstart, qend, e, bit =hit[<NUM_LIT:0>].split()[<NUM_LIT:0>], hit[<NUM_LIT:1>].split()[<NUM_LIT:0>], float(hit[<NUM_LIT:2>]), float(hit[<NUM_LIT:6>]), float(hit[<NUM_LIT:7>]), float(hit[-<NUM_LIT:2>]), float(hit[-<NUM_LIT:1>])<EOL>alignment_length = abs(qstart - qend + <NUM_LIT:1>)<EOL>norm_bit = normalize_bit(a, b, bit, id2desc)<EOL>length_fraction = float((alignment_length) / id2desc[a][<NUM_LIT:2>])<EOL>hits[query][ref][a] = ['<STR_LIT>', a, b, pident, length_fraction, e, bit, norm_bit]<EOL><DEDENT><DEDENT><DEDENT>return hits<EOL>
make all pairwise genome comparisons to get rbhs
rbh = {genome: {other_genome: {rbh_id: [rbh_match, pident, e, bit, norm_bit]]}}