TSUMUGI 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. TSUMUGI/annotator.py +103 -0
  2. TSUMUGI/argparser.py +599 -0
  3. TSUMUGI/core.py +185 -0
  4. TSUMUGI/data/impc_phenodigm.csv +3406 -0
  5. TSUMUGI/data/mp.obo +143993 -0
  6. TSUMUGI/filterer.py +36 -0
  7. TSUMUGI/formatter.py +122 -0
  8. TSUMUGI/genewise_annotation_builder.py +94 -0
  9. TSUMUGI/io_handler.py +189 -0
  10. TSUMUGI/main.py +300 -0
  11. TSUMUGI/network_constructor.py +603 -0
  12. TSUMUGI/ontology_handler.py +62 -0
  13. TSUMUGI/pairwise_similarity_builder.py +66 -0
  14. TSUMUGI/report_generator.py +122 -0
  15. TSUMUGI/similarity_calculator.py +498 -0
  16. TSUMUGI/subcommands/count_filterer.py +47 -0
  17. TSUMUGI/subcommands/genes_filterer.py +89 -0
  18. TSUMUGI/subcommands/graphml_builder.py +158 -0
  19. TSUMUGI/subcommands/life_stage_filterer.py +48 -0
  20. TSUMUGI/subcommands/mp_filterer.py +142 -0
  21. TSUMUGI/subcommands/score_filterer.py +22 -0
  22. TSUMUGI/subcommands/sex_filterer.py +48 -0
  23. TSUMUGI/subcommands/webapp_builder.py +358 -0
  24. TSUMUGI/subcommands/zygosity_filterer.py +48 -0
  25. TSUMUGI/validator.py +65 -0
  26. TSUMUGI/web/app/css/app.css +1129 -0
  27. TSUMUGI/web/app/genelist/network_genelist.html +339 -0
  28. TSUMUGI/web/app/genelist/network_genelist.js +421 -0
  29. TSUMUGI/web/app/js/data/dataLoader.js +41 -0
  30. TSUMUGI/web/app/js/export/graphExporter.js +214 -0
  31. TSUMUGI/web/app/js/graph/centrality.js +495 -0
  32. TSUMUGI/web/app/js/graph/components.js +30 -0
  33. TSUMUGI/web/app/js/graph/filters.js +158 -0
  34. TSUMUGI/web/app/js/graph/highlighter.js +52 -0
  35. TSUMUGI/web/app/js/graph/layoutController.js +454 -0
  36. TSUMUGI/web/app/js/graph/valueScaler.js +43 -0
  37. TSUMUGI/web/app/js/search/geneSearcher.js +93 -0
  38. TSUMUGI/web/app/js/search/phenotypeSearcher.js +292 -0
  39. TSUMUGI/web/app/js/ui/dynamicFontSize.js +30 -0
  40. TSUMUGI/web/app/js/ui/mobilePanel.js +77 -0
  41. TSUMUGI/web/app/js/ui/slider.js +22 -0
  42. TSUMUGI/web/app/js/ui/tooltips.js +514 -0
  43. TSUMUGI/web/app/js/viewer/pageSetup.js +217 -0
  44. TSUMUGI/web/app/viewer.html +515 -0
  45. TSUMUGI/web/app/viewer.js +1593 -0
  46. TSUMUGI/web/css/sanitize.css +363 -0
  47. TSUMUGI/web/css/top.css +391 -0
  48. TSUMUGI/web/image/tsumugi-favicon.ico +0 -0
  49. TSUMUGI/web/image/tsumugi-icon.png +0 -0
  50. TSUMUGI/web/image/tsumugi-logo.png +0 -0
  51. TSUMUGI/web/image/tsumugi-logo.svg +69 -0
  52. TSUMUGI/web/js/genelist_formatter.js +123 -0
  53. TSUMUGI/web/js/top.js +338 -0
  54. TSUMUGI/web/open_webapp_linux.sh +25 -0
  55. TSUMUGI/web/open_webapp_mac.command +25 -0
  56. TSUMUGI/web/open_webapp_windows.bat +37 -0
  57. TSUMUGI/web/serve_index.py +110 -0
  58. TSUMUGI/web/template/template_index.html +197 -0
  59. TSUMUGI/web_deployer.py +150 -0
  60. tsumugi-1.0.1.dist-info/METADATA +504 -0
  61. tsumugi-1.0.1.dist-info/RECORD +64 -0
  62. tsumugi-1.0.1.dist-info/WHEEL +4 -0
  63. tsumugi-1.0.1.dist-info/entry_points.txt +3 -0
  64. tsumugi-1.0.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,197 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <!-- ======================================== -->
6
+ <!-- Google tag (gtag.js) -->
7
+ <!-- ======================================== -->
8
+ <script async src="https://www.googletagmanager.com/gtag/js?id=G-KHH6HGQTPM"></script>
9
+ <script>
10
+ window.dataLayer = window.dataLayer || [];
11
+ function gtag() {
12
+ dataLayer.push(arguments);
13
+ }
14
+ gtag("js", new Date());
15
+
16
+ gtag("config", "G-KHH6HGQTPM");
17
+ </script>
18
+
19
+ <!-- ======================================== -->
20
+ <!-- OGP -->
21
+ <!-- ======================================== -->
22
+ <meta property="og:title" content="TSUMUGI" />
23
+ <meta property="og:site_name" content="TSUMUGI" />
24
+ <meta property="og:type" content="website" />
25
+ <meta property="og:url" content="https://larc-tsukuba.github.io/tsumugi/" />
26
+ <meta property="og:image"
27
+ content="https://raw.githubusercontent.com/akikuno/TSUMUGI/refs/heads/main/image/tsumugi-icon.png" />
28
+ <meta property="og:description"
29
+ content="Tool for Identifying Gene Modules Based on KO Mouse Phenotype Similarity" />
30
+ <meta property="og:locale" content="en_US" />
31
+
32
+ <!-- ======================================== -->
33
+ <!-- Meta data -->
34
+ <!-- ======================================== -->
35
+ <meta charset="UTF-8" />
36
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
37
+ <meta name="description"
38
+ content="TSUMUGI is a gene module detection tool from the University of Tsukuba, specializing in phenotype-driven analysis using knockout mouse data. Visualize gene modules linked to phenotypic traits with ease.">
39
+ <meta name="keywords"
40
+ content="TSUMUGI, International Mouse Phenotyping Consortium (IMPC), Knockout mice, Gene module detection, Phenotype analysis">
41
+
42
+ <title>TSUMUGI</title>
43
+ <link rel="icon" href="https://raw.githubusercontent.com/akikuno/TSUMUGI/refs/heads/main/image/tsumugi-icon.png" />
44
+
45
+ <!-- ======================================== -->
46
+ <!-- JavaScript -->
47
+ <!-- ======================================== -->
48
+
49
+ <!-- pako for reading gzip JSON -->
50
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.1.0/pako.min.js" defer></script>
51
+
52
+ <!-- Custom JS -->
53
+ <script defer src="./js/top.js"></script>
54
+ <script type="module" src="./js/genelist_formatter.js"></script>
55
+
56
+ <!-- ======================================== -->
57
+ <!-- CSS -->
58
+ <!-- ======================================== -->
59
+
60
+ <!-- Sanitize -->
61
+ <link href="./css/sanitize.css" rel="stylesheet" />
62
+
63
+ <!-- Google font -->
64
+ <link href="https://fonts.googleapis.com/css?family=Lora" rel="stylesheet" />
65
+ <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" />
66
+
67
+ <!-- Fontawesome -->
68
+ <link href="https://use.fontawesome.com/releases/v6.6.0/css/all.css" rel="stylesheet" />
69
+
70
+ <!-- Custom CSS -->
71
+ <link rel="stylesheet" href="./css/top.css" />
72
+ </head>
73
+
74
+ <body>
75
+ <!-- ======================================== -->
76
+ <!-- Main -->
77
+ <!-- ======================================== -->
78
+
79
+ <form class="searchForm" id="searchForm">
80
+ <h1><img src="image/tsumugi-logo.png" alt="TSUMUGI" width="0" height="0" /></h1>
81
+ <p class="subtitle">
82
+ Trait-driven Surveillance for <br />
83
+ Mutation-based Gene module Identification
84
+ </p>
85
+
86
+ <!-- Tabs for Phenotype and Gene -->
87
+ <div class="Tab-container">
88
+ <button class="Tab" type="button" data-tab="phenotype" onclick="setSearchMode('phenotype')">
89
+ Phenotype
90
+ </button>
91
+ <button class="Tab" type="button" data-tab="gene" onclick="setSearchMode('gene')">Gene</button>
92
+ <button class="Tab" type="button" data-tab="geneList" onclick="setSearchMode('geneList')">
93
+ Gene List
94
+ </button>
95
+ </div>
96
+
97
+ <br />
98
+
99
+ <!-- Phenotype Input Section -->
100
+ <div class="tab-content" id="phenotypeSection">
101
+ <label for="phenotype">Select a phenotype of interest
102
+ <div class="info-tooltip-container">
103
+ <div class="info-tooltip-icon">i</div>
104
+ <div class="info-tooltip-content">Searchable phenotype list here: <a
105
+ href="https://github.com/larc-tsukuba/TSUMUGI/blob/main/data/available_mp_terms.txt"
106
+ target="_blank">Phenotype List</a></div>
107
+ </div>
108
+ </label>
109
+ <input type="text" id="phenotype" name="phenotype"
110
+ placeholder="e.g: increased fasting circulating glucose level" />
111
+ <ul id="phenotypeSuggestions" class="suggestions" aria-busy="true"></ul>
112
+ </div>
113
+
114
+ <!-- Gene Input Section (Hidden Initially) -->
115
+ <div class="tab-content" id="geneSection" style="display: none">
116
+ <label for="gene">Enter a gene symbol
117
+ <div class="info-tooltip-container">
118
+ <div class="info-tooltip-icon">i</div>
119
+ <div class="info-tooltip-content">Searchable gene list here: <a
120
+ href="https://github.com/larc-tsukuba/TSUMUGI/blob/main/data/available_gene_symbols.txt"
121
+ target="_blank">Gene List</a></div>
122
+ </div>
123
+ </label>
124
+ <input type="text" id="gene" name="gene" placeholder="e.g: Maf" />
125
+ <ul id="geneSuggestions" class="suggestions" aria-busy="true"></ul>
126
+ </div>
127
+
128
+ <!-- Gene List Input Section (Hidden Initially) -->
129
+ <div class="tab-content" id="geneListSection" style="display: none">
130
+ <label for="geneList">Enter gene symbols (one per line)</label>
131
+ <textarea class="geneList" id="geneList" rows="5"></textarea>
132
+ <ul id="geneListSuggestions" class="suggestions" aria-busy="true"></ul>
133
+ </div>
134
+
135
+ <button class="submitBtn" type="submit" id="submitBtn" disabled>Submit</button>
136
+ <button class="submitBtn" type="submit" id="submitBtn_List" style="display: none">Submit</button>
137
+ </form>
138
+
139
+ <!-- ======================================== -->
140
+ <!-- Resources Section -->
141
+ <!-- ======================================== -->
142
+ <div class="resources-container">
143
+ <div class="resource-section">
144
+ <h3>Documentation & Contact</h3>
145
+ <div class="resource-buttons">
146
+ <a class="resource-btn" href="https://github.com/akikuno/TSUMUGI-dev/blob/main/README.md"
147
+ target="_blank">
148
+ <i class="fa-regular fa-file-lines"></i> Documentation
149
+ </a>
150
+ <a class="resource-btn" href="https://forms.gle/TpLeatthUBLN57PU6" target="_blank">
151
+ <i class="fa-regular fa-comment-dots"></i> Contact
152
+ </a>
153
+ </div>
154
+ </div>
155
+
156
+ <div class="resource-section">
157
+ <h3>Download Data
158
+ <span class="info-tooltip-container">
159
+ <span class="info-tooltip-icon">i</span>
160
+ <span class="info-tooltip-content">For details about each format, please refer to the following
161
+ link:
162
+ <a href="https://github.com/akikuno/TSUMUGI-dev/blob/main/README.md#-download-data"
163
+ target="_blank"
164
+ rel="noopener">https://github.com/akikuno/TSUMUGI-dev/blob/main/README.md#-download-data</a>
165
+ </span>
166
+ </span>
167
+ </h3>
168
+ <div class="resource-buttons">
169
+ <a class="resource-btn"
170
+ href="https://github.com/larc-tsukuba/tsumugi/raw/refs/heads/main/data/genewise_phenotype_annotations.jsonl.gz"
171
+ download>
172
+ <i class="fa-regular fa-circle-down"></i> Genewise Phenotype Annotations (JSONL.gz)
173
+ </a>
174
+ <a class="resource-btn"
175
+ href="https://github.com/larc-tsukuba/tsumugi/raw/refs/heads/main/data/pairwise_similarity_annotations.jsonl.gz"
176
+ download>
177
+ <i class="fa-regular fa-circle-down"></i> Pairwise Similarity Annotations (JSONL.gz)
178
+ </a>
179
+ </div>
180
+ </div>
181
+ </div>
182
+
183
+ <!-- ======================================== -->
184
+ <!-- Footer -->
185
+ <!-- ======================================== -->
186
+ <footer>
187
+ <p>TSUMUGI version TSUMUGI_VERSION</p>
188
+ <!-- <p><i class="fa-regular fa-newspaper"></i><a href="https://example.com" target="_blank">Article</a> </p>-->
189
+ <p>
190
+ &copy; 2026
191
+ <a href="https://www.md.tsukuba.ac.jp/LabAnimalResCNT/public_E/index.html" target="_blank">Laboratory Animal
192
+ Resource Center, University of Tsukuba</a>
193
+ </p>
194
+ </footer>
195
+ </body>
196
+
197
+ </html>
@@ -0,0 +1,150 @@
1
+ from __future__ import annotations
2
+
3
+ import shutil
4
+ from importlib.resources import as_file, files
5
+ from pathlib import Path
6
+
7
+ ###########################################################
8
+ # Select targetted phenotypes and gene symbols
9
+ ###########################################################
10
+
11
+
12
+ def select_targetted_phenotypes(TEMPDIR: Path) -> set[str]:
13
+ mp_terms_file = Path(TEMPDIR, "webapp", "available_mp_terms.txt")
14
+ targetted_phenotypes = mp_terms_file.read_text().splitlines() if mp_terms_file.exists() else []
15
+
16
+ return set(targetted_phenotypes)
17
+
18
+
19
+ def select_targetted_genes(TEMPDIR: Path) -> set[str]:
20
+ gene_symbols_file = Path(TEMPDIR, "webapp", "available_gene_symbols.txt")
21
+ targetted_genes = gene_symbols_file.read_text().splitlines() if gene_symbols_file.exists() else []
22
+
23
+ return set(targetted_genes)
24
+
25
+
26
+ ###########################################################
27
+ # Prepare files
28
+ ###########################################################
29
+
30
+
31
+ def _prepare_directories(output_dir: str | Path) -> None:
32
+ Path(output_dir / "data" / "phenotype").mkdir(parents=True, exist_ok=True)
33
+ Path(output_dir / "data" / "genesymbol").mkdir(parents=True, exist_ok=True)
34
+
35
+
36
+ def _generate_index_html(output_dir: str | Path, TSUMUGI_VERSION: str) -> None:
37
+ output_dir = Path(output_dir)
38
+ output_dir.mkdir(parents=True, exist_ok=True)
39
+ output_path = output_dir / "index.html"
40
+ temp_file = files("TSUMUGI") / "web" / "template" / "template_index.html"
41
+
42
+ with as_file(temp_file) as template_path:
43
+ with template_path.open("r", encoding="utf-8") as src, output_path.open("w", encoding="utf-8") as dst:
44
+ for line in src:
45
+ if "REMOVE_THIS_LINE" in line:
46
+ continue
47
+ line = line.replace("TSUMUGI_VERSION", TSUMUGI_VERSION)
48
+ dst.write(line)
49
+
50
+
51
+ def _write_version_file(output_dir: str | Path, TSUMUGI_VERSION: str) -> None:
52
+ output_dir = Path(output_dir)
53
+ output_dir.mkdir(parents=True, exist_ok=True)
54
+ version_file = output_dir / "version.txt"
55
+ version_file.write_text(TSUMUGI_VERSION, encoding="utf-8")
56
+
57
+
58
+ def _copy_directories(output_dir: str | Path) -> None:
59
+ # Copy css and js directories
60
+ for asset in ["css", "js"]:
61
+ dst_dir = output_dir / asset
62
+ dst_dir.mkdir(parents=True, exist_ok=True)
63
+ temp_file = files("TSUMUGI") / "web" / asset
64
+ with as_file(temp_file) as src_dir:
65
+ shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True)
66
+
67
+ for asset in ["css", "js"]:
68
+ dst_dir = output_dir / "app" / asset
69
+ dst_dir.mkdir(parents=True, exist_ok=True)
70
+ temp_file = files("TSUMUGI") / "web" / "app" / asset
71
+ with as_file(temp_file) as src_dir:
72
+ shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True)
73
+
74
+ # Copy shared app entry files
75
+ for filename in ["viewer.html", "viewer.js"]:
76
+ dst_file = output_dir / "app" / filename
77
+ dst_file.parent.mkdir(parents=True, exist_ok=True)
78
+ temp_file = files("TSUMUGI") / "web" / "app" / filename
79
+ shutil.copy(temp_file, dst_file)
80
+
81
+ # Copy the image directory
82
+ dst_dir = output_dir / "image"
83
+ dst_dir.mkdir(parents=True, exist_ok=True)
84
+ temp_file = files("TSUMUGI") / "web" / "image"
85
+ with as_file(temp_file) as src_dir:
86
+ shutil.copytree(src_dir, dst_dir, dirs_exist_ok=True)
87
+
88
+
89
+ def _copy_json_files(targetted_phenotypes, targetted_genes, TEMPDIR: Path, output_dir: str | Path) -> None:
90
+ src_phenotype_dir = Path(TEMPDIR, "network", "phenotype")
91
+ src_gene_dir = Path(TEMPDIR, "network", "genesymbol")
92
+
93
+ dst_phenotype_dir = output_dir / "data" / "phenotype"
94
+ dst_gene_dir = output_dir / "data" / "genesymbol"
95
+
96
+ dst_phenotype_dir.mkdir(parents=True, exist_ok=True)
97
+ dst_gene_dir.mkdir(parents=True, exist_ok=True)
98
+
99
+ for pheno in targetted_phenotypes:
100
+ pheno = pheno.replace(" ", "_")
101
+ src_file = src_phenotype_dir / f"{pheno}.json.gz"
102
+ if src_file.exists():
103
+ shutil.copy(src_file, dst_phenotype_dir / src_file.name)
104
+
105
+ for gene in targetted_genes:
106
+ src_file = src_gene_dir / f"{gene}.json.gz"
107
+ if src_file.exists():
108
+ shutil.copy(src_file, dst_gene_dir / src_file.name)
109
+
110
+
111
+ def _copy_webapp_files(TEMPDIR: Path, output_dir: str | Path) -> None:
112
+ data_dir = output_dir / "data"
113
+ ROOT_DIR = Path(TEMPDIR).parent
114
+
115
+ file_map = {
116
+ Path(TEMPDIR, "webapp", "available_mp_terms.json"): data_dir / "available_mp_terms.json",
117
+ Path(TEMPDIR, "webapp", "available_mp_terms.txt"): data_dir / "available_mp_terms.txt",
118
+ Path(TEMPDIR, "webapp", "available_gene_symbols.txt"): data_dir / "available_gene_symbols.txt",
119
+ Path(TEMPDIR, "webapp", "marker_symbol_accession_id.json"): data_dir / "marker_symbol_accession_id.json",
120
+ Path(TEMPDIR, "webapp", "binary_phenotypes.txt"): data_dir / "binary_phenotypes.txt",
121
+ Path(TEMPDIR, "webapp", "mp_term_id_lookup.json"): data_dir / "mp_term_id_lookup.json",
122
+ Path(ROOT_DIR / "genewise_phenotype_annotations.jsonl.gz"): data_dir
123
+ / "genewise_phenotype_annotations.jsonl.gz",
124
+ Path(ROOT_DIR / "pairwise_similarity_annotations.jsonl.gz"): data_dir
125
+ / "pairwise_similarity_annotations.jsonl.gz",
126
+ }
127
+
128
+ for src, dst in file_map.items():
129
+ shutil.copy(src, dst)
130
+
131
+ # Copy webapp launchers
132
+ for file_name in ["open_webapp_mac.command", "open_webapp_windows.bat", "open_webapp_linux.sh", "serve_index.py"]:
133
+ temp_file = files("TSUMUGI") / "web" / file_name
134
+ shutil.copy(temp_file, output_dir / file_name)
135
+
136
+
137
+ def prepare_files(
138
+ targetted_phenotypes, targetted_genes, TEMPDIR: Path, output_dir: str | Path, TSUMUGI_VERSION: str
139
+ ) -> None:
140
+ _prepare_directories(output_dir)
141
+ _copy_directories(output_dir)
142
+ _copy_json_files(targetted_phenotypes, targetted_genes, TEMPDIR, output_dir)
143
+ _copy_webapp_files(TEMPDIR, output_dir)
144
+ _generate_index_html(output_dir, TSUMUGI_VERSION)
145
+ _write_version_file(Path(output_dir, "app"), TSUMUGI_VERSION)
146
+
147
+
148
+ ###########################################################
149
+ # Generate HTML and JS for web application
150
+ ###########################################################