Skip to content

Commit 6d0d40b

Browse files
committed
🐛 Fix(config_generator): update infer_component_metadata to identify edgelist and adjlist nets stored as csv or txt
1 parent 6217635 commit 6d0d40b

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

example_data/MicW2Graph/MicW2Graph_config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ sections:
2626
component_type: dataframe
2727
file_format: csv
2828
delimiter: ','
29-
- title: Abundance Data Allbiomes xls
29+
- title: Abundance Data Allbiomes
3030
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/1_Exploratory_Data_Analysis/1_Abundance_data/4_abundance_data_allbiomes.xls
3131
description: ''
3232
component_type: dataframe
@@ -54,7 +54,7 @@ sections:
5454
description: ''
5555
component_type: dataframe
5656
file_format: parquet
57-
- title: Sample Info Allbiomes txt
57+
- title: Sample Info Allbiomes
5858
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/1_Exploratory_Data_Analysis/2_Sample_data/5_sample_info_allbiomes.txt
5959
description: ''
6060
component_type: dataframe
@@ -81,12 +81,12 @@ sections:
8181
- title: Network Visualization2
8282
description: ''
8383
components:
84-
- title: Man Example
85-
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/2_Microbial_Association_Networks/2_Network_visualization2/1_man_example.csv
84+
- title: Man Example Edgelist
85+
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/example_data/MicW2Graph/2_Microbial_Association_Networks/2_Network_visualization2/1_man_example_edgelist.csv
8686
description: ''
87-
component_type: dataframe
88-
file_format: csv
89-
delimiter: ','
87+
component_type: plot
88+
plot_type: interactive_network
89+
csv_network_format: edgelist
9090
- title: Network Visualization3
9191
description: ''
9292
components:

vuegen/config_generator.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,23 @@ def infer_component_metadata(file: Path) -> Dict[str, Union[str, None]]:
5757
metadata["plot_type"] = "altair"
5858
else:
5959
metadata["plot_type"] = "unknown"
60-
elif ext in [".csv", ".txt", ".xls", ".xlsx", ".parquet"]:
60+
elif ext in [".csv", ".txt"]:
61+
# Check for network-related keywords
62+
if "edgelist" in file.stem.lower():
63+
metadata["component_type"] = "plot"
64+
metadata["plot_type"] = "interactive_network"
65+
metadata["csv_network_format"] = "edgelist"
66+
elif "adjlist" in file.stem.lower():
67+
metadata["component_type"] = "plot"
68+
metadata["plot_type"] = "interactive_network"
69+
metadata["csv_network_format"] = "adjlist"
70+
else:
71+
metadata["component_type"] = "dataframe"
72+
metadata["file_format"] = ext.lstrip(".")
73+
metadata["delimiter"] = "," if ext == ".csv" else "\\t"
74+
elif ext in [".xls", ".xlsx", ".parquet"]:
6175
metadata["component_type"] = "dataframe"
6276
metadata["file_format"] = ext.lstrip(".")
63-
if ext == ".csv":
64-
metadata["delimiter"] = ","
65-
elif ext == ".txt":
66-
metadata["delimiter"] = "\\t"
6777
elif ext == ".md":
6878
metadata["component_type"] = "markdown"
6979
else:
@@ -90,8 +100,9 @@ def get_sort_key(item: Path) -> tuple:
90100
if parts[0].isdigit():
91101
numeric_prefix = int(parts[0])
92102
else:
93-
numeric_prefix = float('inf') # Non-numeric prefixes go to the end
94-
return numeric_prefix, item.name.lower() # Use `.lower()` for consistent sorting
103+
# Non-numeric prefixes go to the end
104+
numeric_prefix = float('inf')
105+
return numeric_prefix, item.name.lower()
95106

96107
return sorted(items, key=get_sort_key)
97108

0 commit comments

Comments
 (0)