def variation(fastas, sams, s2b, annots, qual, min_cov, min_per, no_sub, bp_table, print_con):
genomes = {}<EOL>for sam in sams:<EOL><INDENT>genomes, s2b = save_refs(sam, fastas, genomes, s2b)<EOL><DEDENT>for sam in sams:<EOL><INDENT>genomes = get_bp_stats(sam, genomes, s2b, qual)<EOL><DEDENT>genomes = calc_frequencies(genomes, bp_table, min_cov, min_per)<EOL>if print_con is True:<EOL><INDENT>print('<STR_LIT>', file = sys.stderr)<EOL>genomes = print_consensus(genomes)<EOL><DEDENT>if no_sub is True:<EOL><INDENT>return genomes<EOL><DEDENT>for genome, contigs in list(genomes.items()):<EOL><INDENT>for contig, samples in list(contigs.items()):<EOL><INDENT>for sample in samples:<EOL><INDENT>print(genomes.keys())<EOL>print(genomes[genome].keys())<EOL>print(genomes[genome][contig].keys())<EOL>print(annots.keys())<EOL>
quantify genomic variation from mapping
genomes[genome][contig][sample] = \
        {'bp_stats':[], 'sub_rates'[locus] = {ref PnPs, consensus PnPs, ...}}