Skip to content

Commit

Permalink
feat: Try and fix paths again
Browse files Browse the repository at this point in the history
  • Loading branch information
lubianat committed Jul 25, 2024
1 parent b8ad0ce commit e697fbf
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions www/python/src/generate_gmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
from pathlib import Path

HERE = Path(__file__).parent.resolve()

STATIC = HERE.joinpath("static").resolve()


# Template SPARQL query for GO terms using Jinja2
go_query_template = """
SELECT DISTINCT
Expand Down Expand Up @@ -194,29 +192,33 @@ def main():
)
results = fetch_data(query)
df = process_data(results)
output_file = STATIC / f"gene_sets_{organism}_{category}.gmt"
output_file = STATIC.joinpath(f"gene_sets_{organism}_{category}.gmt")
generate_gmt(df, output_file)
save_processes(df, STATIC / f"processes_{organism}_{category}.json")
save_processes(df, STATIC.joinpath(f"processes_{organism}_{category}.json"))

# Human cell type markers
human_cell_type_results = fetch_data(human_cell_type_query)
human_cell_type_df = process_data(human_cell_type_results)
generate_gmt(
human_cell_type_df,
STATIC / "gene_sets_human_cell_type.gmt",
STATIC.joinpath("gene_sets_human_cell_type.gmt"),
use_item_label=True,
)
save_processes(human_cell_type_df, STATIC / "processes_human_cell_type.json")
save_processes(
human_cell_type_df, STATIC.joinpath("processes_human_cell_type.json")
)

# Mouse cell type markers
mouse_cell_type_results = fetch_data(mouse_cell_type_query)
mouse_cell_type_df = process_data(mouse_cell_type_results)
generate_gmt(
mouse_cell_type_df,
STATIC / "gene_sets_mouse_cell_type.gmt",
STATIC.joinpath("gene_sets_mouse_cell_type.gmt"),
use_item_label=True,
)
save_processes(mouse_cell_type_df, STATIC / "processes_mouse_cell_type.json")
save_processes(
mouse_cell_type_df, STATIC.joinpath("processes_mouse_cell_type.json")
)

# Custom handling for molecular functions
for organism, details in organisms.items():
Expand All @@ -237,10 +239,11 @@ def main():
combined_df["sitelink"] = combined_df["sitelink_wiki"]
combined_df = combined_df.drop(columns=["sitelink_wiki", "itemLabel_wiki"])

output_file = STATIC / f"gene_sets_{organism}_molecular_functions.gmt"
output_file = STATIC.joinpath(f"gene_sets_{organism}_molecular_functions.gmt")
generate_gmt(combined_df, output_file)
save_processes(
combined_df, STATIC / f"processes_{organism}_molecular_functions.json"
combined_df,
STATIC.joinpath(f"processes_{organism}_molecular_functions.json"),
)


Expand Down

0 comments on commit e697fbf

Please sign in to comment.