コード例 #1
0
 def test_basic_table_no_content(self):
     t = Table(('Key', 'Value'))
     self.assertEqual(t.nrows, 0)
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "</table>")
コード例 #2
0
 def test_basic_table(self):
     t = Table(('Key', 'Value'))
     idx = t.add_row(Key="Employee name", Value="John Doe")
     self.assertEqual(idx, 0)
     self.assertEqual(t.nrows, 1)
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "<tr><td>Employee name</td><td>John Doe</td></tr>\n"
         "</table>")
コード例 #3
0
 def test_table_with_column_aliases(self):
     t = Table(('name', 'date', 'result'),
               name="Experiment",
               date="Date run",
               result="Final result")
     idx = t.add_row(name="Test setup", date="10/10/2017", result="Ok")
     self.assertEqual(idx, 0)
     self.assertEqual(t.nrows, 1)
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Experiment</th><th>Date run</th><th>Final result</th></tr>\n"
         "<tr><td>Test setup</td><td>10/10/2017</td><td>Ok</td></tr>\n"
         "</table>")
コード例 #4
0
 def test_table_append_columns(self):
     t = Table(('Key', 'Person1'))
     t.add_row(Key="Name", Person1="John Doe")
     t.add_row(Key="D.O.B", Person1="12/06/1982")
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Person1</th></tr>\n"
         "<tr><td>Name</td><td>John Doe</td></tr>\n"
         "<tr><td>D.O.B</td><td>12/06/1982</td></tr>\n"
         "</table>")
     t.append_columns("Person2", "Person3")
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Person1</th><th>Person2</th><th>Person3</th></tr>\n"
         "<tr><td>Name</td><td>John Doe</td><td>&nbsp;</td><td>&nbsp;</td></tr>\n"
         "<tr><td>D.O.B</td><td>12/06/1982</td><td>&nbsp;</td><td>&nbsp;</td></tr>\n"
         "</table>")
コード例 #5
0
 def test_table_no_header(self):
     t = Table(('Key', 'Value'))
     t.add_row(Key="Employee name", Value="John Doe")
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "<tr><td>Employee name</td><td>John Doe</td></tr>\n"
         "</table>")
     t.no_header()
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><td>Employee name</td><td>John Doe</td></tr>\n"
         "</table>")
コード例 #6
0
 def test_table_append_columns_fails_with_multiple_names(self):
     t = Table(('Key','Person1'))
     t.add_row(Key="Name",Person1="John Doe")
     t.add_row(Key="D.O.B",Person1="12/06/1982")
     self.assertRaises(KeyError,
                       t.append_columns,
                       "Person1")
コード例 #7
0
 def test_table_render_with_css_id(self):
     t = Table(('Key', 'Value'))
     t.add_row(Key="Employee name", Value="John Doe")
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "<tr><td>Employee name</td><td>John Doe</td></tr>\n"
         "</table>")
     self.assertEqual(
         t.html(css_id="employee-tbl"), "<table id='employee-tbl'>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "<tr><td>Employee name</td><td>John Doe</td></tr>\n"
         "</table>")
コード例 #8
0
 def test_table_multiple_rows(self):
     t = Table(('Key', 'Value'))
     idx = t.add_row(Key="Name", Value="John Doe")
     self.assertEqual(idx, 0)
     self.assertEqual(t.nrows, 1)
     idx = t.add_row(Key="D.O.B", Value="12/06/1982")
     self.assertEqual(idx, 1)
     self.assertEqual(t.nrows, 2)
     idx = t.add_row(Key="Mobile", Value="+44 1726254")
     self.assertEqual(idx, 2)
     self.assertEqual(t.nrows, 3)
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "<tr><td>Name</td><td>John Doe</td></tr>\n"
         "<tr><td>D.O.B</td><td>12/06/1982</td></tr>\n"
         "<tr><td>Mobile</td><td>+44 1726254</td></tr>\n"
         "</table>")
コード例 #9
0
 def test_table_add_css_classes_to_column(self):
     t = Table(('Key', 'Value'))
     t.add_row(Key="Employee name", Value="John Doe")
     t.add_row(Key="D.O.B", Value="12/06/1982")
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "<tr><td>Employee name</td><td>John Doe</td></tr>\n"
         "<tr><td>D.O.B</td><td>12/06/1982</td></tr>\n"
         "</table>")
     t.add_css_classes("key-column", column="Key")
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th class='key-column'>Key</th><th>Value</th></tr>\n"
         "<tr><td class='key-column'>Employee name</td><td>John Doe</td></tr>\n"
         "<tr><td class='key-column'>D.O.B</td><td>12/06/1982</td></tr>\n"
         "</table>")
     t.add_css_classes("summary", "sunny", column="Key")
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th class='key-column summary sunny'>Key</th><th>Value</th></tr>\n"
         "<tr><td class='key-column summary sunny'>Employee name</td><td>John Doe</td></tr>\n"
         "<tr><td class='key-column summary sunny'>D.O.B</td><td>12/06/1982</td></tr>\n"
         "</table>")
     self.assertRaises(KeyError,
                       t.add_css_classes,
                       "blah",
                       column="doesntexist")
コード例 #10
0
 def test_table_add_css_classes(self):
     t = Table(('Key', 'Value'))
     t.add_row(Key="Employee name", Value="John Doe")
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "<tr><td>Employee name</td><td>John Doe</td></tr>\n"
         "</table>")
     t.add_css_classes("employee-data")
     self.assertEqual(
         t.html(), "<table class='employee-data'>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "<tr><td>Employee name</td><td>John Doe</td></tr>\n"
         "</table>")
     t.add_css_classes("summary", "sunny")
     self.assertEqual(
         t.html(), "<table class='employee-data summary sunny'>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "<tr><td>Employee name</td><td>John Doe</td></tr>\n"
         "</table>")
コード例 #11
0
 def test_table_set_value(self):
     t = Table(('Key', 'Value'))
     t.add_row(Key="Name", Value="John Doe")
     t.add_row(Key="D.O.B", Value="12/06/1982")
     t.add_row(Key="Mobile", Value="+44 1726254")
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Value</th></tr>\n"
         "<tr><td>Name</td><td>John Doe</td></tr>\n"
         "<tr><td>D.O.B</td><td>12/06/1982</td></tr>\n"
         "<tr><td>Mobile</td><td>+44 1726254</td></tr>\n"
         "</table>")
     t.append_columns("Value2")
     t.set_value(0, "Value2", "Jane Doe")
     t.set_value(1, "Value2", "19/04/1979")
     t.set_value(2, "Value2", "+44 1745262")
     self.assertEqual(
         t.html(), "<table>\n"
         "<tr><th>Key</th><th>Value</th><th>Value2</th></tr>\n"
         "<tr><td>Name</td><td>John Doe</td><td>Jane Doe</td></tr>\n"
         "<tr><td>D.O.B</td><td>12/06/1982</td><td>19/04/1979</td></tr>\n"
         "<tr><td>Mobile</td><td>+44 1726254</td><td>+44 1745262</td></tr>\n"
         "</table>")
コード例 #12
0
    toc_list = List()
    toc.add(toc_list)

    # Files
    files_info = report.add_section("Stats files")
    stats_files = "Statistics: %s" % Link(
        "[TSV]", os.path.relpath(stats_file, os.path.dirname(out_file)))
    if xlsx_file is not None:
        stats_files += " | %s" % Link(
            "[XLSX]", os.path.relpath(xlsx_file, os.path.dirname(out_file)))
    files_info.add(stats_files)
    toc_list.add_item(Link(files_info.title, files_info))

    # General info
    general_info = report.add_section("General info", name="general_info")
    tbl = Table(columns=('name', 'value'))
    tbl.no_header()
    data_items = (('Total #reads', 'total_reads'), ('Total assigned #reads',
                                                    'total_assigned_reads'),
                  ('Total #barcodes', 'total_barcodes'), ('Assigned #barcodes',
                                                          'assigned_barcodes'))
    for item in data_items:
        name, key = item
        tbl.add_row(name=name, value=data[key])
    general_info.add(tbl)

    # Reads at each stage
    cols = ['Nreads', 'Nreads_filtered', 'Nreads_trimmed']
    if contaminant_filtered:
        cols.append('Nreads_contaminant_filtered')
    plot_filen = os.path.join(out_dir, "reads_per_stage.png")