diff --git a/src/hdf5_lib.py b/src/hdf5_lib.py index 8154874..cbab913 100644 --- a/src/hdf5_lib.py +++ b/src/hdf5_lib.py @@ -5,10 +5,7 @@ import os #from itertools import product import numpy as np -import matplotlib.pyplot as plt -import plotly.express as px -import plotly.graph_objects as go -from plotly.subplots import make_subplots + #import g5505_file_reader import g5505_utils as utils @@ -196,43 +193,6 @@ def format_group_names(names: list): -def display_group_hierarchy_on_a_treemap(filename: str): - - with h5py.File(filename,'r') as file: - nodes, parents, values = get_parent_child_relationships(file) - - metadata_list = [] - metadata_dict={} - for key in file.attrs.keys(): - if 'metadata' in key: - metadata_dict[key[key.find('_')+1::]]= file.attrs[key] - metadata_list.append(key[key.find('_')+1::]+':'+file.attrs[key]) - metadata = '
'.join(['
'] + metadata_list) - - customdata_series = pd.Series(nodes) - customdata_series[0] = metadata - - fig = make_subplots(1, 1, specs=[[{"type": "domain"}]],) - fig.add_trace(go.Treemap( - labels=nodes, #formating_df['formated_names'][nodes], - parents=parents,#formating_df['formated_names'][parents], - values=values, - branchvalues='remainder', - customdata= customdata_series, - #marker=dict( - # colors=df_all_trees['color'], - # colorscale='RdBu', - # cmid=average_score), - #hovertemplate='%{label}
Number of files: %{value}
Success rate: %{color:.2f}', - hovertemplate='%{label}
Count: %{value}
Path: %{customdata}', - name='', - root_color="lightgrey" - )) - fig.update_layout(width = 800, height= 600, margin = dict(t=50, l=25, r=25, b=25)) - fig.show() - file_name, file_ext = os.path.splitext(filename) - fig.write_html(file_name + ".html") - def annotate_root_dir(filename,annotation_dict: dict): with h5py.File(filename,'r+') as file: for key in annotation_dict: @@ -241,8 +201,9 @@ def annotate_root_dir(filename,annotation_dict: dict): import shutil -def create_hdf5_file_from_filesystem_path(ofilename : str, input_file_system_path : - str, select_dir_keywords = [], +def create_hdf5_file_from_filesystem_path(ofilename : str, + input_file_system_path : str, + select_dir_keywords = [], select_file_keywords =[], top_sub_dir_mask : bool = True): @@ -282,9 +243,7 @@ def create_hdf5_file_from_filesystem_path(ofilename : str, input_file_system_pat select_dir_keywords[i] = keyword.replace('/',os.sep) - with h5py.File(ofilename, 'w') as h5file: - - + with h5py.File(ofilename, 'w') as h5file: # Visit each subdirectory from top to bottom, root directory defined by input_file_sytem_path to the lower # level directories. @@ -488,7 +447,7 @@ def main(): output_filename_path = os.path.join(config_file.outputfile_dir,config_file.output_filename) create_hdf5_file_from_filesystem_path(output_filename_path,inputfile_dir,select_dir_keywords,select_file_keywords) - display_group_hierarchy_on_a_treemap(output_filename_path) + #display_group_hierarchy_on_a_treemap(output_filename_path) def main_mtable_h5_from_dataframe(): @@ -530,7 +489,7 @@ def main_mtable_h5_from_dataframe(): } annotate_root_dir(output_filename_path, annotation_dict) - display_group_hierarchy_on_a_treemap(output_filename_path) + #display_group_hierarchy_on_a_treemap(output_filename_path) print(':)')