#! /usr/bin/env python
import sys
import h5py

infiles = sys.argv[1:]

for infile in infiles:
    with h5py.File(infile, 'a') as h5:
        print(infile)
        if 'matrix' in h5:
            print('renaming matrix')
            h5['pixels'] = h5['matrix']
            #del h5['matrix']

        if 'scaffolds' in h5:
            print('renaming scaffolds')
            h5['chroms'] = h5['scaffolds']
            #del h5['scaffolds']



@@ -1,11 +1,10 @@
 #!
- 
 /usr/bin
@@ -166,16 +166,39 @@
 'matrix'
+ in h5 and not 'pixels'
  in h5:%0A
@@ -231,16 +231,27 @@
 g matrix
+ --%3E pixels
 ')%0A     
@@ -288,38 +288,8 @@
 ix'%5D
-%0A            #del h5%5B'matrix'%5D
 %0A%0A  
@@ -308,16 +308,39 @@
 affolds'
+ in h5 and not 'chroms'
  in h5:%0A
@@ -376,16 +376,27 @@
 caffolds
+ --%3E chroms
 ')%0A     
@@ -437,39 +437,5 @@
 s'%5D%0A
-            #del h5%5B'scaffolds'%5D%0A%0A
 %0A

Update v0to1 script