def find_n50(contig_lengths_dict, genome_length_dict):
<EOL>n50_dict = dict()<EOL>for file_name, contig_lengths in contig_lengths_dict.items():<EOL><INDENT>currentlength = <NUM_LIT:0><EOL>for contig_length in contig_lengths:<EOL><INDENT>currentlength += contig_length<EOL>if currentlength >= genome_length_dict[file_name] * <NUM_LIT:0.5>:<EOL><INDENT>n50_dict[file_name] = contig_length<EOL>break<EOL><DEDENT><DEDENT><DEDENT>return n50_dict<EOL>
Calculate the N50 for each strain. N50 is defined as the largest contig such that at least half of the total
genome size is contained in contigs equal to or larger than this contig
:param contig_lengths_dict: dictionary of strain name: reverse-sorted list of all contig lengths
:param genome_length_dict: dictionary of strain name: total genome length
:return: n50_dict: dictionary of strain name: N50