def test_write_counts_file(self): """BarcodeCounter: write counts to a file """ # Write a file self._make_working_dir() bc = BarcodeCounter() bc.count_barcode("TATGCGCGGTA", lane=1, incr=285302) bc.count_barcode("TATGCGCGGTG", lane=1, incr=532) bc.count_barcode("ACCTACCGGTA", lane=1, incr=315) bc.count_barcode("CCCTTATGCGA", lane=1, incr=22) bc.count_barcode("ACCTAGCGGTA", lane=2, incr=477) bc.count_barcode("ACCTCTATGCT", lane=2, incr=368) bc.count_barcode("ACCCTNCGGTA", lane=3, incr=312) bc.count_barcode("ACCTTATGCGC", lane=3, incr=248) counts_file = os.path.join(self.wd, "out.counts") bc.write(counts_file) expected_contents = """#Lane Rank Sequence Count 1 1 TATGCGCGGTA 285302 1 2 TATGCGCGGTG 532 1 3 ACCTACCGGTA 315 1 4 CCCTTATGCGA 22 2 1 ACCTAGCGGTA 477 2 2 ACCTCTATGCT 368 3 1 ACCCTNCGGTA 312 3 2 ACCTTATGCGC 248 """ self.assertTrue(os.path.exists(counts_file)) self.assertEqual(open(counts_file, 'r').read(), expected_contents)
if mismatches is None: # Set according to barcode lengths found in counts barcode_length = min(counts.barcode_lengths(lane=lane)) if barcode_length >= 6: mismatches = 1 else: mismatches = 0 # Report the analysis report_barcodes(counts, lane=lane, cutoff=cutoff, sample_sheet=sample_sheet, mismatches=mismatches, reporter=reporter) if opts.report_file is not None: print "Writing report to %s" % opts.report_file reporter.write(filen=opts.report_file, title=opts.title) else: reporter.write(title=opts.title) if opts.xls_file is not None: print "Writing XLS to %s" % opts.xls_file reporter.write_xls(opts.xls_file, title=opts.title) if opts.html_file is not None: print "Writing HTML to %s" % opts.html_file reporter.write_html(opts.html_file, title=opts.title) # Output counts if requested if opts.counts_file_out is not None: counts.write(opts.counts_file_out) # Finish sys.exit(retval)
# Set according to barcode lengths found in counts barcode_length = min(counts.barcode_lengths(lane=lane)) if barcode_length >= 6: mismatches = 1 else: mismatches = 0 # Report the analysis report_barcodes(counts, lane=lane, cutoff=cutoff, sample_sheet=use_sample_sheet, mismatches=mismatches, reporter=reporter, minimum_read_fraction=args.minimum_read_fraction) if args.report_file is not None: print("Writing report to %s" % args.report_file) reporter.write(filen=args.report_file, title=args.title) else: reporter.write(title=args.title) if args.xls_file is not None: print("Writing XLS to %s" % args.xls_file) reporter.write_xls(args.xls_file, title=args.title) if args.html_file is not None: print("Writing HTML to %s" % args.html_file) reporter.write_html(args.html_file, title=args.title) # Output counts if requested if args.counts_file_out is not None: counts.write(args.counts_file_out) # Finish sys.exit(retval)