Python tables.IsDescription() Examples
The following are 3
code examples of tables.IsDescription().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tables
, or try the search function
.
Example #1
Source File: test_find_intersecting_snps.py From WASP with Apache License 2.0 | 5 votes |
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()
Example #2
Source File: test_find_intersecting_snps.py From WASP with Apache License 2.0 | 5 votes |
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()
Example #3
Source File: subject.py From autopilot with Mozilla Public License 2.0 | 5 votes |
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)