本文整理汇总了Python中pbcommand.models.report.Table类的典型用法代码示例。如果您正苦于以下问题:Python Table类的具体用法?Python Table怎么用?Python Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_table
def to_table(motif_records):
columns = [Column('motif_id', header="Motif"),
Column('modified_position', header="Modified Position"),
Column('modification_type', header="Motification Type"),
Column('percent_motifs_detected',
header="% of Motifs Detected"),
Column('ndetected_motifs', header="# of Motifs Detected"),
Column('nmotifs_in_genome', header="# of Motifs in Genome"),
Column('mean_readscore', header='Mean QV'),
Column('mean_coverage', header="Mean Coverage"),
Column('partner_motif', header="Partner Motif"),
Column('mean_ipd_ration', header="Mean IPD ratio"),
Column('group_tag', header="Group Tag"),
Column('objective_score', header='Objective Score')]
# Record attr name ordered by index in columns
attr_names = ['motif_str', 'center_position',
'modification_type',
'fraction', 'ndetected',
'ngenome', 'mean_score',
'mean_coverage', 'partner_motif_str',
'mean_ipd_ratio',
'group_tag', 'objective_score']
table = Table(Constants.T_ID, title="Motifs", columns=columns)
for record in motif_records:
for attr_name, column in zip(attr_names, columns):
v = getattr(record, attr_name)
table.add_data_by_column_id(column.id, v)
return table
示例2: create_table
def create_table(d, barcode):
"""Long Amplicon Analysis results table"""
columns = []
if barcode:
columns.append(Column(Constants.C_BARCODE))
columns.append(Column(Constants.C_CLUSTER))
columns.append(Column(Constants.C_PHASE))
columns.append(Column(Constants.C_LENGTH))
columns.append(Column(Constants.C_ACCURACY))
columns.append(Column(Constants.C_COVERAGE))
t = Table(Constants.T_ID,
columns=columns)
for fastaname in sorted(d.fastaname):
row = d[d.fastaname == fastaname]
for column in columns:
# if column.id == "predictedaccuracy":
# accuracy = round(100 * row[column.id][0], 2)
# t.add_data_by_column_id(column.id, accuracy)
# else:
t.add_data_by_column_id(column.id, row[column.id][0])
log.info(str(t))
return t
示例3: test_to_dict
def test_to_dict(self):
"""
The id of report sub elements is prepended with the id of the parent
element when to_dict is called.
"""
r = Report('redfang')
a = Attribute('a', 'b')
a2 = Attribute('a2', 'b2')
r.add_attribute(a)
r.add_attribute(a2)
pg = PlotGroup('pgid')
pg.add_plot(Plot('pid', 'anImg'))
pg.add_plot(Plot('pid2', 'anImg2'))
r.add_plotgroup(pg)
t = Table('tabid')
t.add_column(Column('c1'))
r.add_table(t)
d = r.to_dict()
log.debug("\n" + pformat(d))
self.assertEqual('redfang', d['id'])
self.assertEqual('redfang.a', d['attributes'][0]['id'])
self.assertEqual('redfang.a2', d['attributes'][1]['id'])
self.assertEqual('redfang.pgid', d['plotGroups'][0]['id'])
self.assertEqual('redfang.pgid.pid', d['plotGroups'][0]['plots'][0]['id'])
self.assertEqual('redfang.pgid.pid2', d['plotGroups'][0]['plots'][1]['id'])
self.assertEqual('redfang.tabid', d['tables'][0]['id'])
self.assertEqual('redfang.tabid.c1', d['tables'][0]['columns'][0]['id'])
示例4: _to_table
def _to_table(self, movie_datum):
"""
Create a pbreports Table for each movie.
:param movie_datum: List of
[(
movie_name,
reads,
mean readlength,
polymerase readlength
number of subread bases
mean subread readlength
mean subread concordance), ...]
"""
table = Table(Constants.T_STATS, columns=(Column(c_id)
for c_id in self.COL_IDS))
for movie_data in movie_datum:
if len(movie_data) != len(self.COL_IDS):
log.error(movie_datum)
raise ValueError(
"Incompatible values. {n} values provided, expected {a}".format(n=len(movie_data), a=len(self.COL_IDS)))
for value, c_id in zip(movie_data, self.COL_IDS):
table.add_data_by_column_id(c_id, value)
log.debug(str(table))
return table
示例5: create_table
def create_table(d, barcode):
"""Long Amplicon Analysis results table"""
columns = []
if barcode:
columns.append(Column("barcodename", header="Barcode"))
columns.append(Column("coarsecluster", header="Sequence Cluster"))
columns.append(Column("phase", header="Sequence Phase"))
columns.append(Column("sequencelength", header="Length (bp)"))
columns.append(Column("predictedaccuracy", header="Estimated Accuracy"))
columns.append(Column("totalcoverage", header="Subreads coverage"))
t = Table("result_table", title="Amplicon Consensus Summary",
columns=columns)
for fastaname in sorted(d.fastaname):
row = d[d.fastaname == fastaname]
for column in columns:
#if column.id == "predictedaccuracy":
# accuracy = round(100 * row[column.id][0], 2)
# t.add_data_by_column_id(column.id, accuracy)
#else:
t.add_data_by_column_id(column.id, row[column.id][0])
log.info(str(t))
return t
示例6: run_to_report
def run_to_report(reads, barcodes, subreads=True, dataset_uuids=()):
""" Generate a Report instance from a SubreadSet and BarcodeSet.
:param subreads: If the ccs fofn is given this needs to be set to False
"""
class MyRow(object):
def __init__(self, label):
self.label = label
self.bases = 0
self.reads = 0
label2row = {}
for label, barcode, read in _labels_reads_iterator(reads, barcodes, subreads=subreads):
if not label in label2row:
label2row[label] = MyRow(label)
label2row[label].bases += len(read)
label2row[label].reads += 1
columns = [Column(Constants.C_BARCODE), Column(Constants.C_NREADS), Column(Constants.C_NBASES)]
table = Table("barcode_table", columns=columns)
labels = sorted(label2row.keys())
for label in labels:
row = label2row[label]
table.add_data_by_column_id(Constants.C_BARCODE, label)
table.add_data_by_column_id(Constants.C_NREADS, row.reads)
table.add_data_by_column_id(Constants.C_NBASES, row.bases)
report = Report(meta_rpt.id, tables=[table], dataset_uuids=dataset_uuids)
return meta_rpt.apply_view(report)
示例7: TestBasicTable
class TestBasicTable(unittest.TestCase):
"""Basic Smoke tests"""
def setUp(self):
self.columns = [Column('one', header="One"),
Column('two', header="Two"),
Column('three', header="Three")]
self.table = Table('my_table_with_values', columns=self.columns)
datum = {'one': list(xrange(3)), 'two': list('abc'),
'three': 'file1 file2 file3'.split()}
for k, values in datum.iteritems():
for value in values:
self.table.add_data_by_column_id(k, value)
def test_str(self):
"""Smoke test for conversion to str"""
log.info(str(self.table))
self.assertIsNotNone(str(self.table))
def test_columns(self):
"""Test Columns"""
self.assertEqual(len(self.table.columns), 3)
def test_column_values(self):
"""Basic check for column values"""
for column in self.table.columns:
self.assertEqual(len(column.values), 3)
def test_to_dict(self):
"""Conversion to dictionary"""
self.assertTrue(isinstance(self.table.to_dict(), dict))
log.info(self.table.to_dict())
示例8: to_table
def to_table(motif_records):
columns = [Column(Constants.C_ID),
Column(Constants.C_POS),
Column(Constants.C_TYPE),
Column(Constants.C_PCT_MOTIF),
Column(Constants.C_NMOTIF),
Column(Constants.C_NMOTIF_GEN),
Column(Constants.C_READSCORE),
Column(Constants.C_COV),
Column(Constants.C_PARTNER),
Column(Constants.C_IPD),
Column(Constants.C_GRP),
Column(Constants.C_OBJ_SCORE)]
# Record attr name ordered by index in columns
attr_names = ['motif_str', 'center_position',
'modification_type',
'fraction', 'ndetected',
'ngenome', 'mean_score',
'mean_coverage', 'partner_motif_str',
'mean_ipd_ratio',
'group_tag', 'objective_score']
table = Table(Constants.T_ID, columns=columns)
for record in motif_records:
for attr_name, column in zip(attr_names, columns):
v = getattr(record, attr_name)
table.add_data_by_column_id(column.id, v)
return table
示例9: TestEmptyTable
class TestEmptyTable(unittest.TestCase):
"""Basic Smoke tests"""
def setUp(self):
self.columns = [Column('one', header="One"),
Column('two', header="Two"),
Column('three', header="Three")]
self.table = Table('my_table', columns=self.columns)
def test_str(self):
"""Smoke test for conversion to str"""
log.info(str(self.table))
self.assertIsNotNone(str(self.table))
def test_columns(self):
"""Test Columns"""
self.assertEqual(len(self.table.columns), 3)
def test_column_values(self):
"""Basic check for column values"""
for column in self.table.columns:
self.assertEqual(len(column.values), 0)
def test_to_dict(self):
"""Conversion to dictionary"""
self.assertTrue(isinstance(self.table.to_dict(), dict))
log.info(self.table.to_dict())
示例10: _to_table
def _to_table(self, movie_datum):
"""
Create a pbreports Table for each movie.
:param movie_datum: List of
[(
movie_name,
reads,
mean readlength,
polymerase readlength
number of subread bases
mean subread readlength
mean subread accuracy), ...]
"""
columns = [Column(k, header=h) for k,h in self.COLUMNS]
table = Table(Constants.T_STATS,
title="Mapping Statistics Summary",
columns=columns)
for movie_data in movie_datum:
if len(movie_data) != len(columns):
log.error(movie_datum)
raise ValueError(
"Incompatible values. {n} values provided, expected {a}".format(n=len(movie_data), a=len(columns)))
for value, c in zip(movie_data, columns):
table.add_data_by_column_id(c.id, value)
log.debug(str(table))
print table
return table
示例11: test_get_table_by_id
def test_get_table_by_id(self):
r = Report('redfang')
t1 = Table('tabid1')
t1.add_column(Column('c1'))
r.add_table(t1)
t = r.get_table_by_id('tabid1')
self.assertEqual(t, t1)
示例12: test_get_table_by_id_with_bad_id
def test_get_table_by_id_with_bad_id(self):
r = Report('redfang')
t1 = Table('tabid1')
t1.add_column(Column('c1'))
r.add_table(t1)
bad_t = r.get_table_by_id('id_that_does_not_exist')
self.assertIsNone(bad_t)
示例13: test_get_column_by_id
def test_get_column_by_id(self):
r = Report('redfang')
t1 = Table('tabid1')
c1 = Column('c1')
t1.add_column(c1)
r.add_table(t1)
c = r.get_table_by_id('tabid1').get_column_by_id('c1')
self.assertEqual(c, c1)
示例14: create_table
def create_table(tabulated_data):
"""Long Amplicon Analysis results table"""
columns = []
columns.append(Column("barcode_col", header="Sample"))
columns.append(Column("good", header="Good"))
columns.append(Column("good_pct", header="Good (%)"))
columns.append(Column("chimera", header="Chimeric"))
columns.append(Column("chimera_pct", header="Chimeric (%)"))
columns.append(Column("noise", header="Noise"))
columns.append(Column("noise_pct", header="Noise (%)"))
t = Table("result_table",
title="Amplicon Input Molecule Summary", columns=columns)
for barcode, data in tabulated_data.iteritems():
if barcode != 'all':
t.add_data_by_column_id('barcode_col', barcode)
for column_id in ['good', 'good_pct', 'chimera', 'chimera_pct', 'noise', 'noise_pct']:
t.add_data_by_column_id(column_id, data[column_id])
t.add_data_by_column_id('barcode_col', 'All')
for column_id in ['good', 'good_pct', 'chimera', 'chimera_pct', 'noise', 'noise_pct']:
t.add_data_by_column_id(column_id, tabulated_data['all'][column_id])
log.info(str(t))
return t
示例15: create_table
def create_table(tabulated_data):
"""Long Amplicon Analysis results table"""
columns = []
columns.append(Column("barcode_col", header=""))
columns.append(Column("good", header=""))
columns.append(Column("good_pct", header=""))
columns.append(Column("chimera", header=""))
columns.append(Column("chimera_pct", header=""))
columns.append(Column("noise", header=""))
columns.append(Column("noise_pct", header=""))
t = Table(Constants.T_R, columns=columns)
for barcode, data in tabulated_data.iteritems():
if barcode != "all":
t.add_data_by_column_id("barcode_col", barcode)
for column_id in ["good", "good_pct", "chimera", "chimera_pct", "noise", "noise_pct"]:
t.add_data_by_column_id(column_id, data[column_id])
t.add_data_by_column_id("barcode_col", "All")
for column_id in ["good", "good_pct", "chimera", "chimera_pct", "noise", "noise_pct"]:
t.add_data_by_column_id(column_id, tabulated_data["all"][column_id])
log.info(str(t))
return t