本文整理汇总了Python中tables.NoSuchNodeError方法的典型用法代码示例。如果您正苦于以下问题:Python tables.NoSuchNodeError方法的具体用法?Python tables.NoSuchNodeError怎么用?Python tables.NoSuchNodeError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tables
的用法示例。
在下文中一共展示了tables.NoSuchNodeError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_data
# 需要导入模块: import tables [as 别名]
# 或者: from tables import NoSuchNodeError [as 别名]
def load_data(self, where, name, dest_name=None, ich=None,
allow_missing=False, ondisk=False):
try:
node = self.h5file.get_node(where, name)
except tables.NoSuchNodeError:
if allow_missing:
node_value = np.array([])
else:
self.h5file.close()
raise IOError("Invalid file format: '%s' is missing." % name)
else:
node_value = node if ondisk else node.read()
if dest_name is None:
dest_name = hdf5_data_map.get(name, name)
if ich is None:
self.data.add(**{dest_name: node_value})
else:
if dest_name not in self.data:
self.data.add(**{dest_name: [node_value]})
else:
self.data[dest_name].append(node_value)
示例2: _load_alex_periods_donor_acceptor
# 需要导入模块: import tables [as 别名]
# 或者: from tables import NoSuchNodeError [as 别名]
def _load_alex_periods_donor_acceptor(data, meas_specs):
# Both us- and ns-ALEX
try:
# Try to load alex period definitions
D_ON = meas_specs.alex_excitation_period1.read()
A_ON = meas_specs.alex_excitation_period2.read()
except tables.NoSuchNodeError:
# But if it fails it's OK, those fields are optional
msg = """
The current file lacks the alternation period defintion.
You will need to manually add this info using:
d.add(D_ON=D_ON, A_ON=A_ON)
where `d` is a Data object and D_ON/A_ON is a tuple with start/stop
values defining the D/A excitation excitation period. Values are in
raw timestamps units.
"""
log.warning(msg)
else:
data.add(D_ON=D_ON, A_ON=A_ON)
示例3: load_h5
# 需要导入模块: import tables [as 别名]
# 或者: from tables import NoSuchNodeError [as 别名]
def load_h5(fname, genome='mm10'):
try:
import tables
except ImportError:
sys.stderr.write('Please install PyTables to read .h5 files: '
'https://www.pytables.org/usersguide/installation.html\n')
exit(1)
# Adapted from scanpy's read_10x_h5() method.
with tables.open_file(str(fname), 'r') as f:
try:
dsets = {}
for node in f.walk_nodes('/' + genome, 'Array'):
dsets[node.name] = node.read()
n_genes, n_cells = dsets['shape']
data = dsets['data']
if dsets['data'].dtype == np.dtype('int32'):
data = dsets['data'].view('float32')
data[:] = dsets['data']
X = csr_matrix((data, dsets['indices'], dsets['indptr']),
shape=(n_cells, n_genes))
genes = [ gene for gene in dsets['genes'].astype(str) ]
assert(len(genes) == n_genes)
assert(len(genes) == X.shape[1])
except tables.NoSuchNodeError:
raise Exception('Genome %s does not exist in this file.' % genome)
except KeyError:
raise Exception('File is missing one or more required datasets.')
return X, np.array(genes)
示例4: load_h5
# 需要导入模块: import tables [as 别名]
# 或者: from tables import NoSuchNodeError [as 别名]
def load_h5(fname, genome='mm10'):
# Adapted from scanpy's read_10x_h5() method.
with tables.open_file(str(fname), 'r') as f:
try:
dsets = {}
for node in f.walk_nodes('/' + genome, 'Array'):
dsets[node.name] = node.read()
n_genes, n_cells = dsets['shape']
data = dsets['data']
if dsets['data'].dtype == np.dtype('int32'):
data = dsets['data'].view('float32')
data[:] = dsets['data']
X = csr_matrix((data, dsets['indices'], dsets['indptr']),
shape=(n_cells, n_genes))
genes = [ gene for gene in dsets['gene_names'].astype(str) ]
assert(len(genes) == n_genes)
assert(len(genes) == X.shape[1])
except tables.NoSuchNodeError:
raise Exception('Genome %s does not exist in this file.' % genome)
except KeyError:
raise Exception('File is missing one or more required datasets.')
return X, np.array(genes)
示例5: remove_child
# 需要导入模块: import tables [as 别名]
# 或者: from tables import NoSuchNodeError [as 别名]
def remove_child(self):
"""
internal function to remove command that removes also child jobs.
Do never use this command, since it will destroy the integrity of your project.
"""
if "server" in self.project_hdf5.list_nodes():
server_hdf_dict = self.project_hdf5["server"]
if (
"qid" in server_hdf_dict.keys()
and str(self.status) in ["submitted", "running", "collect"]
and server_hdf_dict["qid"] is not None
):
self.project._queue_delete_job(server_hdf_dict["qid"])
with self.project_hdf5.open("..") as hdf_parent:
try:
del hdf_parent[self.job_name]
shutil.rmtree(str(self.working_directory))
except (NoSuchNodeError, KeyError, OSError):
print(
"This group does not exist in the HDF5 file {}".format(
self.job_name
)
)
if self.project_hdf5.is_empty:
if os.path.isfile(self.project_hdf5.file_name):
os.remove(self.project_hdf5.file_name)
dir_name = self.project_hdf5.file_name.split(".h5")[0] + "_hdf5"
if os.path.isdir(dir_name):
os.rmdir(dir_name)
if self.job_id:
self.project.db.delete_item(self.job_id)
示例6: _add_usALEX_specs
# 需要导入模块: import tables [as 别名]
# 或者: from tables import NoSuchNodeError [as 别名]
def _add_usALEX_specs(data, meas_specs):
try:
offset = meas_specs.alex_offset.read()
except tables.NoSuchNodeError:
log.warning(' No offset found, assuming offset = 0.')
offset = 0
data.add(offset=offset)
data.add(alex_period=meas_specs.alex_period.read())
_load_alex_periods_donor_acceptor(data, meas_specs)
示例7: load
# 需要导入模块: import tables [as 别名]
# 或者: from tables import NoSuchNodeError [as 别名]
def load(cls, archive_name):
"""load a ReadArray from an hdf5 archive, note that ma_pos and ma_genes are
discarded.
:param str archive_name: name of a .h5 archive containing a saved ReadArray object
:return ReadArray:
"""
f = tb.open_file(archive_name, mode='r')
data = f.root.data.read()
try:
f.get_node('/genes')
genes = f.root.genes.read()
positions = f.root.positions.read()
except tb.NoSuchNodeError:
indptr = f.root.indptr.read()
indices = f.root.indices.read()
genes = f.root.gene_data.read()
positions = f.root.positions_data.read()
genes = csr_matrix((genes, indices, indptr))
positions = csr_matrix((positions, indices, indptr))
return cls(data, genes, positions)
# todo document me