def test_report_barcodes_for_no_counts(self): """report_barcodes: check output when there are no counts """ bc = BarcodeCounter() analysis = bc.analyse() reporter = report_barcodes(bc) # Check content self.assertEqual(str(reporter), """Barcode analysis for all lanes ============================== No barcodes counted""")
def test_report_barcodes_for_no_counts(self): """report_barcodes: check output when there are no counts """ bc = BarcodeCounter() analysis = bc.analyse() reporter = report_barcodes(bc) # Check content self.assertEqual(str(reporter), """Barcode analysis for all lanes ============================== No barcodes counted""")
def test_report_barcodes(self): """report_barcodes: check output for mismatches and sample sheet """ # Create sample sheet sample_sheet_file = self._make_file("SampleSheet.csv", """[Data] Lane,Sample_ID,Sample_Name,Sample_Plate,Sample_Well,I7_Index_ID,index,Sample_Project,Description 1,SMPL1,,,,A006,CATGCGCGGTA,, 1,SMPL2,,,,A012,GCTGCGCGGTC,, """) # Set up barcode counts bc = BarcodeCounter() bc.count_barcode("TATGCGCGGTA",lane=1,incr=285302) bc.count_barcode("CATGCGCGGTA",lane=1,incr=8532) bc.count_barcode("GATGCGCGGTA",lane=1,incr=5321) bc.count_barcode("GCTGCGCGGTA",lane=1,incr=7853) bc.count_barcode("GCTGCGCGGTC",lane=1,incr=325394) analysis = bc.analyse(lane=1,mismatches=2, sample_sheet=sample_sheet_file) ##"CATGCGCGGTA","TATGCGCGGTA","GATGCGCGGTA","GCTGCGCGGTA" = 307008 ##"GCTGCGCGGTC" = 325394 self.assertEqual(analysis.cutoff,None) self.assertEqual(analysis.mismatches,2) self.assertEqual(analysis.total_reads,632402) self.assertEqual(analysis.coverage,632402) self.assertEqual(analysis.barcodes,["GCTGCGCGGTC", "CATGCGCGGTA"]) self.assertEqual(analysis.counts["GCTGCGCGGTC"].reads,325394) self.assertEqual(analysis.counts["CATGCGCGGTA"].reads,307008) self.assertEqual(analysis.counts["GCTGCGCGGTC"].sample,"SMPL2") self.assertEqual(analysis.counts["CATGCGCGGTA"].sample,"SMPL1") self.assertEqual(analysis.counts["GCTGCGCGGTC"].sequences,1) self.assertEqual(analysis.counts["CATGCGCGGTA"].sequences,4) # Create report reporter = report_barcodes(bc, lane=1, mismatches=2, sample_sheet=sample_sheet_file) # Check content self.assertEqual(str(reporter), """Barcode analysis for lane #1 ============================ Barcodes have been grouped by allowing 2 mismatches #Rank Index Sample N_seqs N_reads %reads (%Total_reads) 1 GCTGCGCGGTC SMPL2 1 325394 51.5% (51.5%) 2 CATGCGCGGTA SMPL1 4 307008 48.5% (100.0%)""")
def test_report_barcodes(self): """report_barcodes: check output for mismatches and sample sheet """ # Create sample sheet sample_sheet_file = self._make_file("SampleSheet.csv", """[Data] Lane,Sample_ID,Sample_Name,Sample_Plate,Sample_Well,I7_Index_ID,index,Sample_Project,Description 1,SMPL1,,,,A006,CATGCGCGGTA,, 1,SMPL2,,,,A012,GCTGCGCGGTC,, """) # Set up barcode counts bc = BarcodeCounter() bc.count_barcode("TATGCGCGGTA",lane=1,incr=285302) bc.count_barcode("CATGCGCGGTA",lane=1,incr=8532) bc.count_barcode("GATGCGCGGTA",lane=1,incr=5321) bc.count_barcode("GCTGCGCGGTA",lane=1,incr=7853) bc.count_barcode("GCTGCGCGGTC",lane=1,incr=325394) analysis = bc.analyse(lane=1,mismatches=2, sample_sheet=sample_sheet_file) ##"CATGCGCGGTA","TATGCGCGGTA","GATGCGCGGTA","GCTGCGCGGTA" = 307008 ##"GCTGCGCGGTC" = 325394 self.assertEqual(analysis.cutoff,None) self.assertEqual(analysis.mismatches,2) self.assertEqual(analysis.total_reads,632402) self.assertEqual(analysis.coverage,632402) self.assertEqual(analysis.barcodes,["GCTGCGCGGTC", "CATGCGCGGTA"]) self.assertEqual(analysis.counts["GCTGCGCGGTC"].reads,325394) self.assertEqual(analysis.counts["CATGCGCGGTA"].reads,307008) self.assertEqual(analysis.counts["GCTGCGCGGTC"].sample,"SMPL2") self.assertEqual(analysis.counts["CATGCGCGGTA"].sample,"SMPL1") self.assertEqual(analysis.counts["GCTGCGCGGTC"].sequences,1) self.assertEqual(analysis.counts["CATGCGCGGTA"].sequences,4) # Create report reporter = report_barcodes(bc, lane=1, mismatches=2, sample_sheet=sample_sheet_file) # Check content self.assertEqual(str(reporter), """Barcode analysis for lane #1 ============================ Barcodes have been grouped by allowing 2 mismatches #Rank Index Sample N_seqs N_reads %reads (%Total_reads) 1 GCTGCGCGGTC SMPL2 1 325394 51.5% (51.5%) 2 CATGCGCGGTA SMPL1 4 307008 48.5% (100.0%)""")
counts = count_barcodes_bcl2fastq(args[0]) else: # Generate counts from fastq files counts = count_barcodes(args) # Deal with cutoff if opts.cutoff == 0.0: cutoff = None else: cutoff = opts.cutoff # Report the counts if not opts.no_report: reporter = Reporter() if lanes is None: report_barcodes(counts, cutoff=cutoff, sample_sheet=opts.sample_sheet, mismatches=opts.mismatches, reporter=reporter) else: for lane in lanes: if lane not in counts.lanes: logging.error("Requested analysis for lane %d but " "only have counts for lanes %s" % (lane, ','.join([str(l) for l in counts.lanes]))) sys.exit(1) report_barcodes(counts, lane=lane, cutoff=cutoff, sample_sheet=opts.sample_sheet, mismatches=opts.mismatches,
counts = count_barcodes_bcl2fastq(args[0]) else: # Generate counts from fastq files counts = count_barcodes(args) # Deal with cutoff if opts.cutoff == 0.0: cutoff = None else: cutoff = opts.cutoff # Report the counts if not opts.no_report: reporter = Reporter() if lanes is None: report_barcodes(counts, cutoff=cutoff, sample_sheet=opts.sample_sheet, mismatches=opts.mismatches, reporter=reporter) else: for lane in lanes: if lane not in counts.lanes: logging.error("Requested analysis for lane %d but " "only have counts for lanes %s" % (lane, ','.join([str(l) for l in counts.lanes]))) sys.exit(1) report_barcodes(counts, lane=lane, cutoff=cutoff, sample_sheet=opts.sample_sheet, mismatches=opts.mismatches,