本文整理汇总了Python中h5py.File.attrs['id']方法的典型用法代码示例。如果您正苦于以下问题:Python File.attrs['id']方法的具体用法?Python File.attrs['id']怎么用?Python File.attrs['id']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类h5py.File
的用法示例。
在下文中一共展示了File.attrs['id']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_nuc
# 需要导入模块: from h5py import File [as 别名]
# 或者: from h5py.File import attrs['id'] [as 别名]
def make_nuc(ncc_file_path, n3d_file_path, out_file_name):
if not out_file_name.lower().endswith('.nuc'):
out_file_name = out_file_name + '.nuc'
contact_dict = import_contacts(ncc_file_path)
contact_name = os.path.splitext(os.path.basename(ncc_file_path))[0]
pos_dict, coords_dict = import_coords(n3d_file_path)
root = File(out_file_name, mode='w')
hierarchy = (('contacts', ('original', 'working')),
('display', ()),
('chromosomes',()),
('dataTracks', ('derived', 'external', 'innate')),
('sample', ('protocol', 'organism', 'tissue')),
('structures', ('0')),
('images', ())
)
for parent, children in hierarchy:
group = root.create_group(parent)
for child in children:
group.create_group(child)
for child in ('particles', 'restraints', 'transforms', 'coords'):
root['structures']['0'].create_group(child)
now = int(time.time())
random.seed(now)
root.attrs['id'] = np.array([random.random(), now, now], np.float32)
root['sample'].attrs['name'] = np.string_('Unknown')
contact_group = root['contacts']['working'].create_group(contact_name)
for chromoPair in contact_dict:
chrA, chrB = chromoPair
if chrA not in contact_group:
contact_group.create_group(chrA)
contact_group[chrA].create_dataset(chrB, dtype=np.uint32, data=contact_dict[chromoPair].T)
coords_group = root['structures']['0']['coords']
particle_group = root['structures']['0']['particles']
for chromo in coords_dict:
coords_group.create_dataset(chromo, dtype=np.float64, data=coords_dict[chromo])
pos = np.array(pos_dict[chromo], np.uint32)
group = particle_group.create_group(chromo)
group.create_dataset('positions', dtype=np.uint32, data=pos)
chromo_group = root['chromosomes'].create_group(chromo)
chromo_group.attrs['limits'] = np.array([pos.min(), pos.max()])
root.flush()