def print_genome_matrix(hits, fastas, id2desc, file_name):
out = open(file_name, '<STR_LIT:w>')<EOL>fastas = sorted(fastas)<EOL>print('<STR_LIT>', file=out)<EOL>print('<STR_LIT>' % ('<STR_LIT:\t>'.join(fastas)), file=out)<EOL>for fasta in fastas:<EOL><INDENT>line = [fasta]<EOL>for other in fastas:<EOL><INDENT>if other == fasta:<EOL><INDENT>average = '<STR_LIT:->'<EOL><DEDENT>else:<EOL><INDENT>average = numpy.average([hits[fasta][other][i][<NUM_LIT:3>] for i in hits[fasta][other]])<EOL><DEDENT>line.append(str(average))<EOL><DEDENT>print('<STR_LIT:\t>'.join(line), file=out)<EOL><DEDENT>print('<STR_LIT>', file=out)<EOL>print('<STR_LIT>', file=out)<EOL>print('<STR_LIT>' % ('<STR_LIT:\t>'.join(fastas)), file=out)<EOL>for fasta in fastas:<EOL><INDENT>line = [fasta]<EOL>for other in fastas:<EOL><INDENT>if other == fasta:<EOL><INDENT>percent = '<STR_LIT:->'<EOL><DEDENT>else:<EOL><INDENT>orthologs = float(len(hits[fasta][other]))<EOL>orfs = float(len([i for i in id2desc if id2desc[i][<NUM_LIT:0>] == fasta]))<EOL>percent = float(orthologs / orfs) * <NUM_LIT:100><EOL><DEDENT>line.append(str(percent))<EOL><DEDENT>print('<STR_LIT:\t>'.join(line), file=out)<EOL><DEDENT>
optimize later? slow ...
should combine with calculate_threshold module