def copies(mapping, s2bins, rna, min_rna = <NUM_LIT>, mismatches = <NUM_LIT:0>):
cov = {} <EOL>s2bins, bins2s = parse_s2bins(s2bins)<EOL>rna_cov = parse_rna(rna, s2bins, min_rna)<EOL>s2bins, bins2s = filter_missing_rna(s2bins, bins2s, rna_cov)<EOL>for line in mapping:<EOL><INDENT>line = line.strip().split()<EOL>if line[<NUM_LIT:0>].startswith('<STR_LIT:@>'):<EOL><INDENT>if line[<NUM_LIT:0>].startswith('<STR_LIT>') is False:<EOL><INDENT>continue<EOL><DEDENT>s = line[<NUM_LIT:1>].split('<STR_LIT::>')[<NUM_LIT:1>]<EOL>l = int(line[<NUM_LIT:2>].split('<STR_LIT::>')[<NUM_LIT:1>])<EOL>if s not in s2bins:<EOL><INDENT>continue<EOL><DEDENT>if s not in cov:<EOL><INDENT>cov[s] = [<NUM_LIT:0>, l]<EOL><DEDENT><DEDENT>mm = count_mismatches(line)<EOL>if mm is False or mm > mismatches:<EOL><INDENT>continue<EOL><DEDENT>s, bases = line[<NUM_LIT:2>], len(line[<NUM_LIT:9>])<EOL>if s not in cov:<EOL><INDENT>continue<EOL><DEDENT>cov[s][<NUM_LIT:0>] += bases <EOL>rna_cov = rna_bases(rna_cov, s, bases, line) <EOL><DEDENT>print('<STR_LIT>' % (mismatches))<EOL>header = ['<STR_LIT>', '<STR_LIT>' % (min_rna),'<STR_LIT>','<STR_LIT>', '<STR_LIT>', '<STR_LIT>','<STR_LIT>' % (min_rna),'<STR_LIT>','<STR_LIT>']<EOL>print('<STR_LIT:\t>'.join(header))<EOL>for bin, scaffolds in list(bins2s.items()):<EOL><INDENT>rna_count = sum([len(rna_cov[s][<NUM_LIT:2>]) for s in scaffolds if s in rna_cov])<EOL>for s in scaffolds:<EOL><INDENT>if s not in rna_cov:<EOL><INDENT>continue<EOL><DEDENT>out = []<EOL>counts = rna_cov[s]<EOL>bin_cov = calc_bin_cov(bins2s[bin], cov)<EOL>num_genes = len(counts[<NUM_LIT:2>])<EOL>rna_coverage = float(float(counts[<NUM_LIT:0>])/float(counts[<NUM_LIT:1>]))<EOL>if bin_cov == <NUM_LIT:0>:<EOL><INDENT>rna_div_bin = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>rna_div_bin = float(rna_coverage/bin_cov)<EOL><DEDENT>est = int(max([rna_count, counts, rna_div_bin]))<EOL>out = [s, num_genes, rna_coverage, bin, bin_cov, rna_count, rna_div_bin, est]<EOL>print('<STR_LIT:\t>'.join([str(i) for i in out]))<EOL><DEDENT><DEDENT>
1. determine bin coverage
2. determine rRNA gene coverage
3. compare