Skip to content

Commit c334dea

Browse files
committed
✨ Feat: Allow to read project, section, and subsection descriptions from a md file when creating streamlit and quarto reports from a directory
1 parent b899159 commit c334dea

File tree

7 files changed

+55
-8
lines changed

7 files changed

+55
-8
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Optional description for section.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Optional description for subsection.

docs/example_data/MicW2Graph/MicW2Graph_config.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
report:
22
title: Micw2Graph
3-
description: ''
3+
description: 'Wastewater treatment (WWT) is the process of removing contaminants
4+
from used water before it is discharged back into the environment, which contributes
5+
to address water scarcity and to protect aquatic ecosystems. In this project,
6+
we investigated the microbiome of WWT to build MicW2Graph, an open-source knowledge
7+
graph (KG) that integrates metagenomic and metatranscriptomic information with
8+
their biological context, including biological processes, environmental and phenotypic
9+
features, chemical compounds, and additional metadata. We developed a workflow
10+
to collect meta-omics datasets from MGnify and infer potential interactions among
11+
microorganisms through microbial association networks (MANs). MicW2Graph enables
12+
the investigation of research questions related to WWT, focusing on aspects such
13+
as microbial connections, community memberships, and potential ecological functions.
14+
15+
'
416
graphical_abstract: ''
517
logo: ''
618
sections:
719
- title: Exploratory Data Analysis
820
description: ''
921
subsections:
1022
- title: Abundance Data
11-
description: ''
23+
description: 'Optional description for section.
24+
25+
'
1226
components:
1327
- component_type: plot
1428
plot_type: plotly
@@ -31,6 +45,10 @@ sections:
3145
title: Abundance Data Allbiomes
3246
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/docs/example_data/MicW2Graph/1_Exploratory_Data_Analysis/1_Abundance_data/4_abundance_data_allbiomes.xls
3347
description: ''
48+
- component_type: markdown
49+
title: Description
50+
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/docs/example_data/MicW2Graph/1_Exploratory_Data_Analysis/1_Abundance_data/description.md
51+
description: ''
3452
- title: Sample Data
3553
description: ''
3654
components:
@@ -75,13 +93,19 @@ sections:
7593
description: ''
7694
subsections:
7795
- title: Network Visualization1
78-
description: ''
96+
description: 'Optional description for subsection.
97+
98+
'
7999
components:
80100
- component_type: plot
81101
plot_type: interactive_network
82102
title: Man Example
83103
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/docs/example_data/MicW2Graph/2_Microbial_Association_Networks/1_Network_visualization1/1_man_example.graphml
84104
description: ''
105+
- component_type: markdown
106+
title: Description
107+
file_path: /Users/asaru/Documents/DTU/MoNA/vuegen/docs/example_data/MicW2Graph/2_Microbial_Association_Networks/1_Network_visualization1/description.md
108+
description: ''
85109
- title: Network Visualization2
86110
description: ''
87111
components:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Wastewater treatment (WWT) is the process of removing contaminants from used water before it is discharged back into the environment, which contributes to address water scarcity and to protect aquatic ecosystems. In this project, we investigated the microbiome of WWT to build MicW2Graph, an open-source knowledge graph (KG) that integrates metagenomic and metatranscriptomic information with their biological context, including biological processes, environmental and phenotypic features, chemical compounds, and additional metadata. We developed a workflow to collect meta-omics datasets from MGnify and infer potential interactions among microorganisms through microbial association networks (MANs). MicW2Graph enables the investigation of research questions related to WWT, focusing on aspects such as microbial connections, community memberships, and potential ecological functions.

vuegen/config_manager.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,25 @@ def get_sort_key(path: Path) -> tuple:
143143
return numeric_prefix, path.name.lower()
144144

145145
return sorted(paths, key=get_sort_key)
146+
147+
def _read_description_file(self, folder_path: Path) -> str:
148+
"""
149+
Reads the content of a description.md file if it exists in the given folder.
150+
151+
Parameters
152+
----------
153+
folder_path : Path
154+
Path to the folder where description.md might be located.
155+
156+
Returns
157+
-------
158+
str
159+
Content of the description.md file if found, otherwise an empty string.
160+
"""
161+
description_file = folder_path / "description.md"
162+
if description_file.exists():
163+
return f"{description_file.read_text().strip().replace('\n', '\n ')}\n"
164+
return ""
146165

147166
def _create_subsect_config_fromdir(self, subsection_dir_path: Path) -> Dict[str, Union[str, List[Dict]]]:
148167
"""
@@ -160,7 +179,7 @@ def _create_subsect_config_fromdir(self, subsection_dir_path: Path) -> Dict[str,
160179
"""
161180
subsection_config = {
162181
"title": self._create_title_fromdir(subsection_dir_path.name),
163-
"description": "",
182+
"description": self._read_description_file(subsection_dir_path),
164183
"components": [],
165184
}
166185

@@ -206,7 +225,7 @@ def _create_sect_config_fromdir(self, section_dir_path: Path) -> Dict[str, Union
206225
"""
207226
section_config = {
208227
"title": self._create_title_fromdir(section_dir_path.name),
209-
"description": "",
228+
"description": self._read_description_file(section_dir_path),
210229
"subsections": [],
211230
}
212231

@@ -240,7 +259,7 @@ def create_yamlconfig_fromdir(self, base_dir: str) -> Tuple[Dict[str, Union[str,
240259
yaml_config = {
241260
"report": {
242261
"title": self._create_title_fromdir(base_dir_path.name),
243-
"description": "",
262+
"description": self._read_description_file(base_dir_path),
244263
"graphical_abstract": "",
245264
"logo": "",
246265
},

vuegen/quarto_reportview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def _generate_subsection(self, subsection, is_report_static, is_report_revealjs)
239239
subsection_content.extend(self._generate_plot_content(component, is_report_static))
240240
elif component.component_type == r.ComponentType.DATAFRAME:
241241
subsection_content.extend(self._generate_dataframe_content(component, is_report_static))
242-
elif component.component_type == r.ComponentType.MARKDOWN:
242+
elif component.component_type == r.ComponentType.MARKDOWN and component.title.lower() != "description":
243243
subsection_content.extend(self._generate_markdown_content(component))
244244
elif component.component_type == r.ComponentType.HTML and not is_report_static:
245245
subsection_content.extend(self._generate_html_content(component))

vuegen/streamlit_reportview.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ def _generate_subsection(self, subsection) -> tuple[List[str], List[str]]:
296296
subsection_content.extend(self._generate_plot_content(component))
297297
elif component.component_type == r.ComponentType.DATAFRAME:
298298
subsection_content.extend(self._generate_dataframe_content(component))
299-
elif component.component_type == r.ComponentType.MARKDOWN:
299+
# If md files is called "description.md", do not include it in the report
300+
elif component.component_type == r.ComponentType.MARKDOWN and component.title.lower() != "description":
300301
subsection_content.extend(self._generate_markdown_content(component))
301302
elif component.component_type == r.ComponentType.HTML:
302303
subsection_content.extend(self._generate_html_content(component))

0 commit comments

Comments
 (0)