def test_add(self):
        """Reporter: can add content
        """
        reporter = Reporter()
        self.assertEqual(len(reporter),0)
        self.assertFalse(reporter)
        self.assertEqual(str(reporter),"")
        reporter.add("Title text",title=True)
        reporter.add("Some words")
        self.assertEqual(len(reporter),2)
        self.assertTrue(reporter)
        self.assertEqual(str(reporter),
                         """Title text
==========
Some words""")
Esempio n. 2
0
 def test_write_xls(self):
     """Reporter: can write to an XLS file
     """
     self._make_working_dir()
     reporter = Reporter()
     reporter.add("Test Document",title=True)
     reporter.add("Lorem ipsum")
     report_xls = os.path.join(self.wd,"report.xls")
     reporter.write_xls(report_xls)
     self.assertTrue(os.path.isfile(report_xls))
 def test_write_xls(self):
     """Reporter: can write to an XLS file
     """
     self._make_working_dir()
     reporter = Reporter()
     reporter.add("Test Document",title=True)
     reporter.add("Lorem ipsum")
     report_xls = os.path.join(self.wd,"report.xls")
     reporter.write_xls(report_xls)
     self.assertTrue(os.path.isfile(report_xls))
Esempio n. 4
0
    def test_write(self):
        """Reporter: can write to a text file
        """
        self._make_working_dir()
        reporter = Reporter()
        reporter.add("Test Document",title=True)
        reporter.add("Lorem ipsum")
        report_file = os.path.join(self.wd,"report.txt")
        reporter.write(filen=report_file)
        self.assertTrue(os.path.isfile(report_file))
        expected_contents = """Test Document
=============
Lorem ipsum
"""
        self.assertTrue(os.path.exists(report_file))
        self.assertEqual(open(report_file,'r').read(),
                         expected_contents)
    def test_write(self):
        """Reporter: can write to a text file
        """
        self._make_working_dir()
        reporter = Reporter()
        reporter.add("Test Document",title=True)
        reporter.add("Lorem ipsum")
        report_file = os.path.join(self.wd,"report.txt")
        reporter.write(filen=report_file)
        self.assertTrue(os.path.isfile(report_file))
        expected_contents = """Test Document
=============
Lorem ipsum
"""
        self.assertTrue(os.path.exists(report_file))
        self.assertEqual(open(report_file,'r').read(),
                         expected_contents)
Esempio n. 6
0
    def test_add(self):
        """Reporter: can add content
        """
        reporter = Reporter()
        self.assertEqual(len(reporter),0)
        self.assertFalse(reporter)
        self.assertEqual(str(reporter),"")
        reporter.add("Title text",title=True)
        reporter.add("Some words")
        self.assertEqual(len(reporter),2)
        self.assertTrue(reporter)
        self.assertEqual(str(reporter),
                         """Title text
==========
Some words""")
Esempio n. 7
0
     # Read counts from counts file(s)
     counts = BarcodeCounter(*args)
 elif len(args) == 1 and os.path.isdir(args[0]):
     # Generate counts from bcl2fastq output
     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,
Esempio n. 8
0
    def test_write_html(self):
        """Reporter: can write to a HTML file
        """
        self._make_working_dir()
        reporter = Reporter()
        reporter.add("This is a Test",title=True)
        reporter.add("Lorem ipsum")
        reporter.add("Column1\tColumn2",heading=True)
        reporter.add("1\t2")
        reporter.add("3\t4")
        reporter.add("Lorem more ipsum")
        report_html = os.path.join(self.wd,"report.html")
        reporter.write_html(report_html,
                            title="Test Document",
                            no_styles=True)
        self.assertTrue(os.path.isfile(report_html))
        expected_contents = """<html>
<head>
<title>Test Document</title>
</head>
<body>
<h1>Test Document</h1>
<div id='toc'>
<h2>Contents</h2>
<ul><li><a href='#This_is_a_Test'>This is a Test</a></li></ul>
</div>
<div id='This_is_a_Test'>
<h2>This is a Test</h2>
<p>Lorem ipsum</p>
</div>
<div>
<table>
<tr><th>Column1</th><th>Column2</th></tr>
<tr><td>1</td><td>2</td></tr>
<tr><td>3</td><td>4</td></tr>
</table>
</div>
<div>
<p>Lorem more ipsum</p>
</div></body>
</html>
"""
        for expected,actual in zip(expected_contents.split('\n'),
                                   open(report_html,'r').read().split('\n')):
            self.assertEqual(expected,actual)
     # Read counts from counts file(s)
     counts = BarcodeCounter(*args)
 elif len(args) == 1 and os.path.isdir(args[0]):
     # Generate counts from bcl2fastq output
     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,