本文整理汇总了Python中tables.IsDescription方法的典型用法代码示例。如果您正苦于以下问题:Python tables.IsDescription方法的具体用法?Python tables.IsDescription怎么用?Python tables.IsDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tables
的用法示例。
在下文中一共展示了tables.IsDescription方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_hap_samples
# 需要导入模块: import tables [as 别名]
# 或者: from tables import IsDescription [as 别名]
def write_hap_samples(self, h5f):
"""Write tables containing sample names to HDF5 file"""
class SamplesTab(tables.IsDescription):
name = tables.StringCol(64)
for chrom_name in self.chrom_names:
table = h5f.create_table(h5f.root, "samples_%s" % chrom_name,
SamplesTab)
for samp in self.hap_samples:
row = table.row
row['name'] = samp
row.append()
table.flush()
示例2: write_snp_tab_h5
# 需要导入模块: import tables [as 别名]
# 或者: from tables import IsDescription [as 别名]
def write_snp_tab_h5(self):
snp_tab_h5 = tables.open_file(self.snp_tab_filename, "w")
class SNPTab(tables.IsDescription):
name = tables.StringCol(16)
pos = tables.Int64Col()
allele1 = tables.StringCol(100)
allele2 = tables.StringCol(100)
chrom_tables = {}
snp_num = 0
for snp in self.snp_list:
if snp[0] in chrom_tables:
table = chrom_tables[snp[0]]
else:
table = snp_tab_h5.create_table(snp_tab_h5.root, snp[0], SNPTab)
chrom_tables[snp[0]] = table
row = table.row
snp_num += 1
row['name'] = "snp%d" % snp_num
row['pos'] = snp[1]
row['allele1'] = snp[2]
row['allele2'] = snp[3]
row.append()
table.flush()
self.write_hap_samples(snp_tab_h5)
snp_tab_h5.close()
示例3: ensure_structure
# 需要导入模块: import tables [as 别名]
# 或者: from tables import IsDescription [as 别名]
def ensure_structure(self):
"""
Ensure that our h5f has the appropriate baseline structure as defined in `self.STRUCTURE`
Checks that all groups and tables are made, makes them if not
"""
h5f = self.open_hdf()
for node in self.STRUCTURE:
try:
node = h5f.get_node(node[0])
except tables.exceptions.NoSuchNodeError:
#pdb.set_trace()
# try to make it
# python 3 compatibility
if sys.version_info >= (3,0):
if isinstance(node[3], str):
if node[3] == 'group':
h5f.create_group(node[1], node[2])
elif issubclass(node[3], tables.IsDescription):
h5f.create_table(node[1], node[2], description=node[3])
# python 2
else:
if isinstance(node[3], basestring):
if node[3] == 'group':
h5f.create_group(node[1], node[2])
elif issubclass(node[3], tables.IsDescription):
h5f.create_table(node[1], node[2], description=node[3])
self.close_hdf(h5f)