if intron_counts[i] == 0 ] alignments_and_scores = [(alignment, [ int(tokens[5:]) for tokens in alignment if tokens[:5] == 'AS:i:' ][0]) for alignment in clipped_alignments] alignments_and_scores.sort(key=lambda alignment: alignment[1], reverse=True) max_score = alignments_and_scores[0][1] alignments_to_report = [ alignment for alignment, score in alignments_and_scores if score == max_score ] output_line_count += alignment_printer.print_alignment_data( multiread_to_report( alignments_to_report, alignment_count_to_report=alignment_count_to_report, seed=seed, non_deterministic=non_deterministic, weights=[1] * len(alignments_to_report))) else: # All alignments overlap introns intron_alignments = [ alignments[i] for i in xrange(len(intron_counts)) if intron_counts[i] == min_intron_count ] # Compute min coverage for alignments that are the same alignment_dict = defaultdict(int) for alignment in intron_alignments: if alignment[:-1] not in alignment_dict: alignment_dict[alignment[:-1]] = int(alignment[-1][5:]) else: alignment_dict[alignment[:-1]] \
) if junction_counts[i] == 0] alignments_and_scores = [(alignment, [int(tokens[5:]) for tokens in alignment if tokens[:5] == 'AS:i:'][0]) for alignment in clipped_alignments] alignments_and_scores.sort(key=lambda alignment: alignment[1], reverse=True) max_score = alignments_and_scores[0][1] alignments_to_report = [alignment for alignment, score in alignments_and_scores if score == max_score] output_line_count += alignment_printer.print_alignment_data( multiread_to_report( alignments_to_report, alignment_count_to_report=alignment_count_to_report, seed=seed, non_deterministic=non_deterministic, weights=[1]*len(alignments_to_report) ) ) else: # All alignments overlap junctions junction_alignments = [alignments[i] for i in xrange(len(junction_counts)) if junction_counts[i] == min_junction_count] # Compute min coverage for alignments that are the same alignment_dict = defaultdict(int) for alignment in junction_alignments: if alignment[:-1] not in alignment_dict: alignment_dict[alignment[:-1]] = int(alignment[-1][5:]) else:
if not corrected_multiread: '''This is effectively an unmapped read; write corresponding SAM output.''' if flag & 16: seq_to_write = initial_multiread[0][9][::-1].translate( reversed_complement_translation_table) qual_to_write = initial_multiread[0][10][::-1] else: seq_to_write = initial_multiread[0][9] qual_to_write = initial_multiread[0][10] output_line_count \ += alignment_printer.print_unmapped_read( qname, seq_to_write, qual_to_write ) continue count = alignment_printer.print_alignment_data( multiread_to_report( corrected_multiread, alignment_count_to_report=alignment_count_to_report, seed=seed, non_deterministic=non_deterministic, tie_margin=args.tie_margin)) counter.add('output_lines', count) output_line_count += count print >>sys.stderr, 'DONE with compare_alignments.py; in/out=%d/%d; ' \ 'time=%0.3f s' % (input_line_count, output_line_count, time.time() - start_time)
if flag & 16: seq_to_write = initial_multiread[0][9][::-1].translate( reversed_complement_translation_table ) qual_to_write = initial_multiread[0][10][::-1] else: seq_to_write = initial_multiread[0][9] qual_to_write = initial_multiread[0][10] output_line_count \ += alignment_printer.print_unmapped_read( qname, seq_to_write, qual_to_write ) continue count = alignment_printer.print_alignment_data( multiread_to_report( corrected_multiread, alignment_count_to_report=alignment_count_to_report, seed=seed, non_deterministic=non_deterministic, tie_margin=args.tie_margin ) ) counter.add('output_lines', count) output_line_count += count print >>sys.stderr, 'DONE with compare_alignments.py; in/out=%d/%d; ' \ 'time=%0.3f s' % (input_line_count, output_line_count, time.time() - start_time)