Skip to content

Commit

Permalink
Merge pull request #64 from Kelly-ST-HRI/master
Browse files Browse the repository at this point in the history
Allow hic2cool_updates.py to write output files
  • Loading branch information
alexander-veit authored Sep 12, 2023
2 parents 5a7d12e + 2e2e6d7 commit a43f15a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hic2cool/hic2cool_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ def update_invert_weight_for_resolution(h5_data, res=None):
else:
print('... Inverted following weights: %s' % found_weights)

with h5py.File(writefile) as h5_file:
with h5py.File(writefile, "r+") as h5_file:
if 'resolutions' in h5_file:
for res in h5_file['resolutions']:
update_invert_weight_for_resolution(h5_file['resolutions'][res]['bins'], res=res)
else:
update_invert_weight_for_resolution(h5_file['bins'])
h5_file.close()


def update_cooler_schema_v3(writefile):
Expand All @@ -111,19 +112,20 @@ def add_v3_attrs(h5_data, res=None):
else:
print('... Added format-version and storage-mode attributes')

with h5py.File(writefile) as h5_file:
with h5py.File(writefile, "r+") as h5_file:
if 'resolutions' in h5_file:
for res in h5_file['resolutions']:
add_v3_attrs(h5_file['resolutions'][res], res=res)
else:
add_v3_attrs(h5_file)
h5_file.close()


def update_mcool_schema_v2(writefile):
"""
Add format and format-version attributes to the base level of an mcool
"""
with h5py.File(writefile) as h5_file:
with h5py.File(writefile, "r+") as h5_file:
# only run if it's an mcool and 'resolutions' exist
if 'resolutions' in h5_file:
mcool_info = {
Expand All @@ -134,3 +136,4 @@ def update_mcool_schema_v2(writefile):
print('... Added format and format-version attributes for the mcool')
else:
print('... Not a multi-res file, so will not add mcool schema attributes')
h5_file.close()

0 comments on commit a43f15a

Please sign in to comment.