Esempio n. 1
0
    def test_analyse_groups_with_sample_sheet(self):
        """BarcodeCounter: perform analysis with grouping and samplesheet
        """
        # 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,,
2,SMPL3,,,,A005,ACAGTGCGGTA,,
2,SMPL4,,,,A019,GTGAAACGGTC,,
""")
        # 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)
Esempio n. 2
0
 def test_analyse_with_cutoff(self):
     """BarcodeCounter: perform analysis with cutoff
     """
     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, cutoff=0.013)
     self.assertEqual(analysis.cutoff, 0.013)
     self.assertEqual(analysis.mismatches, 0)
     self.assertEqual(analysis.total_reads, 632402)
     self.assertEqual(analysis.coverage, 619228)
     self.assertEqual(analysis.barcodes,
                      ["GCTGCGCGGTC", "TATGCGCGGTA", "CATGCGCGGTA"])
     self.assertEqual(analysis.counts["GCTGCGCGGTC"].reads, 325394)
     self.assertEqual(analysis.counts["TATGCGCGGTA"].reads, 285302)
     self.assertEqual(analysis.counts["CATGCGCGGTA"].reads, 8532)
     self.assertEqual(analysis.counts["GCTGCGCGGTC"].sample, None)
     self.assertEqual(analysis.counts["TATGCGCGGTA"].sample, None)
     self.assertEqual(analysis.counts["CATGCGCGGTA"].sample, None)
     self.assertEqual(analysis.counts["GCTGCGCGGTC"].sequences, 1)
     self.assertEqual(analysis.counts["TATGCGCGGTA"].sequences, 1)
     self.assertEqual(analysis.counts["CATGCGCGGTA"].sequences, 1)
Esempio n. 3
0
 def test_analyse_with_no_counts(self):
     """BarcodeCounter: perform analysis for zero counts
     """
     bc = BarcodeCounter()
     analysis = bc.analyse()
     self.assertEqual(analysis.cutoff, None)
     self.assertEqual(analysis.mismatches, 0)
     self.assertEqual(analysis.total_reads, 0)
     self.assertEqual(analysis.coverage, 0)
     self.assertEqual(analysis.barcodes, [])
Esempio n. 4
0
    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 mismatches were allowed (exact matches only)
No barcodes counted""")
Esempio n. 5
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%)""")
Esempio n. 6
0
 def test_analyse_groups(self):
     """BarcodeCounter: perform analysis with grouping
     """
     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=1)
     ##"TATGCGCGGTA","CATGCGCGGTA","GATGCGCGGTA" = 299155
     ##"GCTGCGCGGTC","GCTGCGCGGTA" = 333247
     self.assertEqual(analysis.cutoff, None)
     self.assertEqual(analysis.mismatches, 1)
     self.assertEqual(analysis.total_reads, 632402)
     self.assertEqual(analysis.coverage, 632402)
     self.assertEqual(analysis.barcodes, ["GCTGCGCGGTC", "TATGCGCGGTA"])
     self.assertEqual(analysis.counts["GCTGCGCGGTC"].reads, 333247)
     self.assertEqual(analysis.counts["TATGCGCGGTA"].reads, 299155)
     self.assertEqual(analysis.counts["GCTGCGCGGTC"].sample, None)
     self.assertEqual(analysis.counts["TATGCGCGGTA"].sample, None)
     self.assertEqual(analysis.counts["GCTGCGCGGTC"].sequences, 2)
     self.assertEqual(analysis.counts["TATGCGCGGTA"].sequences, 3)