From 799b9c8e78262ff9cd9e084123249d4d5eb4ce16 Mon Sep 17 00:00:00 2001 From: Madeline Scyphers Date: Thu, 15 Oct 2026 13:08:06 -0600 Subject: [PATCH 1/2] package: restructure package for conda and submodule usage --- pyproject.toml | 9 +- src/__main__.py | 4 - src/{ => dram_rules}/__init__.py | 2 +- src/dram_rules/__main__.py | 4 + src/{ => dram_rules}/apps/__init__.py | 0 src/{ => dram_rules}/apps/heatmap.py | 4 +- src/{ => dram_rules}/data/.gitignore | 0 src/{ => dram_rules}/data/rules.tsv | 0 src/{ => dram_rules}/data/rules_ag.tsv | 0 src/{ => dram_rules}/data/rules_aquatic.tsv | 0 src/{ => dram_rules}/data/rules_bgc.tsv | 0 src/{ => dram_rules}/data/rules_eng_sys.tsv | 0 src/{ => dram_rules}/data/rules_gut.tsv | 0 src/{ => dram_rules}/definitions.py | 0 src/{ => dram_rules}/make_product.py | 8 +- src/{ => dram_rules}/processing/__init__.py | 0 .../processing/process_annotations.py | 2 +- src/{ => dram_rules}/rule_parser/__init__.py | 0 src/{ => dram_rules}/rule_parser/rules.lark | 0 src/{ => dram_rules}/rule_parser/rules.py | 0 .../rule_parser/rules_common.tsv | 99 +++++-------------- tests/test_heatmap_polars.py | 2 +- tests/test_parsing.py | 2 +- tests/test_taxonomy_filter.py | 4 +- 24 files changed, 46 insertions(+), 94 deletions(-) delete mode 100644 src/__main__.py rename src/{ => dram_rules}/__init__.py (78%) create mode 100644 src/dram_rules/__main__.py rename src/{ => dram_rules}/apps/__init__.py (100%) rename src/{ => dram_rules}/apps/heatmap.py (99%) rename src/{ => dram_rules}/data/.gitignore (100%) rename src/{ => dram_rules}/data/rules.tsv (100%) rename src/{ => dram_rules}/data/rules_ag.tsv (100%) rename src/{ => dram_rules}/data/rules_aquatic.tsv (100%) rename src/{ => dram_rules}/data/rules_bgc.tsv (100%) rename src/{ => dram_rules}/data/rules_eng_sys.tsv (100%) rename src/{ => dram_rules}/data/rules_gut.tsv (100%) rename src/{ => dram_rules}/definitions.py (100%) rename src/{ => dram_rules}/make_product.py (98%) rename src/{ => dram_rules}/processing/__init__.py (100%) rename src/{ => dram_rules}/processing/process_annotations.py (98%) rename src/{ => dram_rules}/rule_parser/__init__.py (100%) rename src/{ => dram_rules}/rule_parser/rules.lark (100%) rename src/{ => dram_rules}/rule_parser/rules.py (100%) rename src/{ => dram_rules}/rule_parser/rules_common.tsv (90%) diff --git a/pyproject.toml b/pyproject.toml index 94a7fb7..9b9e82f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,17 +52,18 @@ dev = [ include-package-data = true [tool.setuptools.packages.find] -include = ["dram_viz*"] +where = ["src"] +include = ["dram_rules*"] [tool.setuptools.package-data] "*" = ["*.tsv", "*.lark"] [project.scripts] -"dram_viz" = "dram_viz.__main__:main" -"dram.viz" = "dram_viz.__main__:main" +"dram_viz" = "dram_rules.make_product:main" +"dram.viz" = "dram_rules.make_product:main" [tool.setuptools_scm] -write_to = "dram_viz/_version.py" +write_to = "src/dram_rules/_version.py" [tool.ruff] diff --git a/src/__main__.py b/src/__main__.py deleted file mode 100644 index 792de85..0000000 --- a/src/__main__.py +++ /dev/null @@ -1,4 +0,0 @@ -from src.make_product import main - -if __name__ == "__main__": - main() diff --git a/src/__init__.py b/src/dram_rules/__init__.py similarity index 78% rename from src/__init__.py rename to src/dram_rules/__init__.py index c7e9f1b..12a9297 100644 --- a/src/__init__.py +++ b/src/dram_rules/__init__.py @@ -1,5 +1,5 @@ try: - from src._version import __version__ + from dram_rules._version import __version__ except ImportError: # package not installed diff --git a/src/dram_rules/__main__.py b/src/dram_rules/__main__.py new file mode 100644 index 0000000..88ee364 --- /dev/null +++ b/src/dram_rules/__main__.py @@ -0,0 +1,4 @@ +from dram_rules.make_product import main + +if __name__ == "__main__": + main() diff --git a/src/apps/__init__.py b/src/dram_rules/apps/__init__.py similarity index 100% rename from src/apps/__init__.py rename to src/dram_rules/apps/__init__.py diff --git a/src/apps/heatmap.py b/src/dram_rules/apps/heatmap.py similarity index 99% rename from src/apps/heatmap.py rename to src/dram_rules/apps/heatmap.py index 37505e6..ea82eda 100644 --- a/src/apps/heatmap.py +++ b/src/dram_rules/apps/heatmap.py @@ -16,8 +16,8 @@ from bokeh.transform import factor_cmap, linear_cmap, log_cmap from panel_material_ui import Tree -from src.definitions import NO_TAXONOMY_RANKS, TAXONOMY_RANKS_REGEX -from src.rule_parser.rules import get_val_col +from dram_rules.definitions import NO_TAXONOMY_RANKS, TAXONOMY_RANKS_REGEX +from dram_rules.rule_parser.rules import get_val_col pn.extension("tabulator", "katex", template="bootstrap") diff --git a/src/data/.gitignore b/src/dram_rules/data/.gitignore similarity index 100% rename from src/data/.gitignore rename to src/dram_rules/data/.gitignore diff --git a/src/data/rules.tsv b/src/dram_rules/data/rules.tsv similarity index 100% rename from src/data/rules.tsv rename to src/dram_rules/data/rules.tsv diff --git a/src/data/rules_ag.tsv b/src/dram_rules/data/rules_ag.tsv similarity index 100% rename from src/data/rules_ag.tsv rename to src/dram_rules/data/rules_ag.tsv diff --git a/src/data/rules_aquatic.tsv b/src/dram_rules/data/rules_aquatic.tsv similarity index 100% rename from src/data/rules_aquatic.tsv rename to src/dram_rules/data/rules_aquatic.tsv diff --git a/src/data/rules_bgc.tsv b/src/dram_rules/data/rules_bgc.tsv similarity index 100% rename from src/data/rules_bgc.tsv rename to src/dram_rules/data/rules_bgc.tsv diff --git a/src/data/rules_eng_sys.tsv b/src/dram_rules/data/rules_eng_sys.tsv similarity index 100% rename from src/data/rules_eng_sys.tsv rename to src/dram_rules/data/rules_eng_sys.tsv diff --git a/src/data/rules_gut.tsv b/src/dram_rules/data/rules_gut.tsv similarity index 100% rename from src/data/rules_gut.tsv rename to src/dram_rules/data/rules_gut.tsv diff --git a/src/definitions.py b/src/dram_rules/definitions.py similarity index 100% rename from src/definitions.py rename to src/dram_rules/definitions.py diff --git a/src/make_product.py b/src/dram_rules/make_product.py similarity index 98% rename from src/make_product.py rename to src/dram_rules/make_product.py index 107c52c..4f3e8fb 100644 --- a/src/make_product.py +++ b/src/dram_rules/make_product.py @@ -16,8 +16,8 @@ import polars as pl import polars.selectors as cs -from src.apps.heatmap import Dashboard -from src.definitions import ( +from dram_rules.apps.heatmap import Dashboard +from dram_rules.definitions import ( BACKUP_ALIAS_COLUMNS, BACKUP_FASTA_COLUMNS, BACKUP_GROUPBY_COLUMNS, @@ -27,13 +27,13 @@ DEFAULT_GROUPBY_COLUMN, DEFAULT_LABEL_COLUMN, ) -from src.processing.process_annotations import ( +from dram_rules.processing.process_annotations import ( build_tax_edge_df_pl, build_tax_tree_selected_recurse, build_taxonomy_df_pl, build_tree_pl, ) -from src.rule_parser.rules import ( +from dram_rules.rule_parser.rules import ( ID_EXPR_DICT, CompiledRules, build_present_map, diff --git a/src/processing/__init__.py b/src/dram_rules/processing/__init__.py similarity index 100% rename from src/processing/__init__.py rename to src/dram_rules/processing/__init__.py diff --git a/src/processing/process_annotations.py b/src/dram_rules/processing/process_annotations.py similarity index 98% rename from src/processing/process_annotations.py rename to src/dram_rules/processing/process_annotations.py index 221a2a0..c64ce17 100644 --- a/src/processing/process_annotations.py +++ b/src/dram_rules/processing/process_annotations.py @@ -5,7 +5,7 @@ import pandas as pd import polars as pl -from src.definitions import DEFAULT_FASTA_COLUMN +from dram_rules.definitions import DEFAULT_FASTA_COLUMN logger = logging.getLogger("dram.viz") diff --git a/src/rule_parser/__init__.py b/src/dram_rules/rule_parser/__init__.py similarity index 100% rename from src/rule_parser/__init__.py rename to src/dram_rules/rule_parser/__init__.py diff --git a/src/rule_parser/rules.lark b/src/dram_rules/rule_parser/rules.lark similarity index 100% rename from src/rule_parser/rules.lark rename to src/dram_rules/rule_parser/rules.lark diff --git a/src/rule_parser/rules.py b/src/dram_rules/rule_parser/rules.py similarity index 100% rename from src/rule_parser/rules.py rename to src/dram_rules/rule_parser/rules.py diff --git a/src/rule_parser/rules_common.tsv b/src/dram_rules/rule_parser/rules_common.tsv similarity index 90% rename from src/rule_parser/rules_common.tsv rename to src/dram_rules/rule_parser/rules_common.tsv index 336f863..1e34af2 100644 --- a/src/rule_parser/rules_common.tsv +++ b/src/dram_rules/rule_parser/rules_common.tsv @@ -1,78 +1,29 @@ name alias rule - Acetate-Final @Acetate-1 | @Acetate-2 | @Acetate-3 - Acetate-1 [[@Acetate-sub1 & [K00163 | K00161 | K00162] & K00627] | [K00174 | K00175] | [K00169 | K00170 | K00172 | K00189 | K00171 | K03737]] & [K01905 | K22224 | K24012] - Acetate-2 @Acetate-sub1 & K01568 & [K00138 | K00128 | K14085 | K00149 | K00129] - Acetate-3 K001895 | K01913 - Acetate-sub1 [K00163 | K00161 | K00162 | K01568] - - Propionate-Final @Propionate-1 | @Propionate-2 | @Propionate-3 - Propionate-1 "[ - [K01899 | K01900 | K01902 | K01903 | K01899] - & [K01847 | K01849 | K01848] - & [K00140 | [K05606 & [K11264 | K03416 | K18426]]] - & @Propionate-sub2 - ] - | @Propionate-sub1" - Propionate-2 [K01026 & [K20626 | K20627] & [K00248 | K00232] & @Propionate-sub2] | @Propionate-sub1 - Propionate-3 [[K01699 | K13919 | K13920] & K13922 & @Propionate-sub2] | @Propionate-sub1 - Propionate-sub1 "[ - [K01206 | K01905 | K22224 | K24012] - | [ - [ - [K13788 | K00625 | K15024 | K13923] - | [K00169 | K00170 | K00172 | K00189 | K00171] - | K00656 - ] - & [K00925 | K00932 | K19697] - ] - ]" - Propionate-sub2 [K01895 | K01908] - - Butyrate-Final @Butyrate-1 | @Butyrate-2 | @Butyrate-3 | @Butyrate-4 - Butyrate-1 K00626 & [K00074 | K00022 | K07516 | K01825 | K01782 | K07514] & [K01692 | K01825 | K01782 | K07515 | K07514 | K07511 | K01715] & @Butyrate-sub1 - Butyrate-2 [K00135 | K08324 | K00135 | K00139 | K17761 | K08324] & @Butyrate-sub2 & @Butyrate-sub1 - Butyrate-3 K01580 & [K13524 | K07250 | K14268 | K00823 | K16871] & @Butyrate-sub2 & @Butyrate-sub1 - Butyrate-4 "K01843 - & [K01844 | K18011] - & K18012 - & K18013 - & [ - [K01034 | K01035] - | [ - K18014 - & [K01692 | K01825 | K01782 | K07515 | K07514 | K07511] - & [K00022 | K01825 | K01782 | K07514] - ] - ] - & @Butyrate-1" - Butyrate-sub1 [K00209 | K17829] & [K01034 | K01035 | K19709] - Butyrate-sub2 [K00043 | K08318 | K18120 | K18121] & K18122 & K14534 - - Lactate-Final @Lactate-1 | @Lactate-2 | @Lactate-3 - Lactate-1 "@Lactate-sub1 - & [ - [ - [K00134 | K00150] - & [K00927 | K01837] - & [K01834 | K15633 | K15634 | K15635 | K01837] - ] - | [ - [K11389 | K00131 | K18978] - & [K01834 | K15633 | K15634 | K15635 | K01837] - ] - | [ - [K00134 | K00150] - & K01837 & K03103 - ] - ] - & [K01689 | K27394 | K00873 | K12406] - & K00016" - Lactate-2 K00016 - Lactate-3 [K18124 | K18125 | K00115 | K19813 | K00117] & K01053 & K05308 & [K11395 | K18127] & K00016 - Lactate-sub1 "[K00844 | K00886 | K08074 | K00918 | K12407 | K00845 | K25026] - & [K01810 | K06859 | K13810 | K15916] - & [K24182 | K00850 | K16370 | K21071 | K00918 | K00895 | K21071] - & [K01623 | K01624 | K01622 | K11645 | K16305 | K16306]" + Acetate-Final @Acetate-1 | @Acetate-2 | @Acetate-3 | @Acetate-4 | @Acetate-5 Acetate-associated metabolism + Acetate-1 K24012 | [K01905 & K22224] Acetyl-CoA ↔ acetate; shared activity with propionate + Acetate-2 K01568 & [K00138 | K00128 | K14085 | K00149 | K00129] Pyruvate → acetaldehyde → acetate + Acetate-3 [K00625 | K13788 | K15024] & K00925 Acetyl-CoA ↔ acetyl-phosphate ↔ acetate + Acetate-4 K01621 & K00925 Xylulose-5-phosphate/fructose-6-phosphate → acetyl-phosphate → acetate + Acetate-5 K01895 | K01913 Acetate → acetyl-CoA; not acetate specific + + Propionate-Final @Propionate-1 | @Propionate-2 | @Propionate-3 | @Propionate-4 Propionate-associated metabolism + Propionate-1 [K01847 | [K01848 & K01849]] & K05606 & [K11264 | K18426] & @Propionate-terminal Succinyl-CoA → methylmalonyl-CoA → propionyl-CoA → propionate + Propionate-2 K20626 & K20627 & K00248 & @Propionate-terminal Lactate → lactoyl-CoA → acryloyl-CoA → propionyl-CoA → propionate + Propionate-3 K01699 & K13919 & K13920 & K13922 & @Propionate-terminal 1,2-Propanediol → propionaldehyde → propionyl-CoA → propionate + Propionate-4 K01908 Propionate → propionyl-CoA + Propionate-terminal K01026 | K24012 | [K01905 & K22224] | [K13923 & [K00932 | K19697]] Propionyl-CoA ↔ propionate; broad alternatives require pathway context + + Butyrate-Final @Butyrate-1 | @Butyrate-2 | @Butyrate-3 Butyrate-associated metabolism + Butyrate-1 K00634 & K00929 Butyryl-CoA ↔ butyryl-phosphate ↔ butyrate + Butyrate-2 [[K01034 & K01035] | K19709] Acetyl-CoA ↔ butyryl-CoA ↔ butyrate through CoA transfer; context-supported, not uniquely specific + Butyrate-3 K01913 Butyrate → butyryl-CoA; not butyrate specific + Acetyl-CoAtoButyryl-CoA K00626 & [K00074 | K00022 | K07516 | K01825 | K01782 | K07514] & [K01692 | K01825 | K01782 | K07515 | K07514 | K07511 | K01715] & K00248 Acetyl-CoA ↔ acetoacetyl-CoA ↔ 3-hydroxybutyryl-CoA ↔ crotonyl-CoA ↔ butyryl-CoA + + Lactate-Final @Lactate-1 | @Lactate-2 | @Lactate-3 | @Lactate-4 Lactate-associated metabolism + Lactate-1 K00016 Pyruvate ↔ L-lactate; NAD-dependent LDH + Lactate-2 K03778 Pyruvate ↔ D-lactate; NAD-dependent LDH + Lactate-3 K00101 | K29125 L-lactate → pyruvate; cytochrome-/quinone-dependent LDH + Lactate-4 K00102 D-lactate → pyruvate; cytochrome-dependent LDH phototroph @Phototroph-Oxygenic | @Phototroph-AnoxygenicType2 | @Phototroph-AnoxygenicType1 Phototroph-Oxygenic [K02703 & K02706] & [K02689 & K02690] diff --git a/tests/test_heatmap_polars.py b/tests/test_heatmap_polars.py index 0fd5187..9f7745e 100644 --- a/tests/test_heatmap_polars.py +++ b/tests/test_heatmap_polars.py @@ -4,7 +4,7 @@ import polars as pl from bokeh.models import CategoricalColorMapper, LinearColorMapper, LogColorMapper -from src.apps.heatmap import heatmap +from dram_rules.apps.heatmap import heatmap class PolarsHeatmapTests(unittest.TestCase): diff --git a/tests/test_parsing.py b/tests/test_parsing.py index cc9082a..258fe4f 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -2,7 +2,7 @@ import polars as pl -from src.rule_parser.rules import ( +from dram_rules.rule_parser.rules import ( And, Call, CompiledRules, diff --git a/tests/test_taxonomy_filter.py b/tests/test_taxonomy_filter.py index 7a690d4..4f6e41f 100644 --- a/tests/test_taxonomy_filter.py +++ b/tests/test_taxonomy_filter.py @@ -9,8 +9,8 @@ from panel.io.state import set_curdoc from panel_material_ui import Tree -from src.apps.heatmap import Dashboard -from src.processing.process_annotations import ( +from dram_rules.apps.heatmap import Dashboard +from dram_rules.processing.process_annotations import ( build_tax_edge_df_pl, build_tax_tree_selected_recurse, build_tree_pl, From 043337a7868ed67ee10e2f557768af9c0870f96f Mon Sep 17 00:00:00 2001 From: Madeline Scyphers Date: Thu, 15 Oct 2026 13:10:22 -0600 Subject: [PATCH 2/2] package: update and lint common rules --- src/dram_rules/rule_parser/rules_common.tsv | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dram_rules/rule_parser/rules_common.tsv b/src/dram_rules/rule_parser/rules_common.tsv index 1e34af2..ef9d390 100644 --- a/src/dram_rules/rule_parser/rules_common.tsv +++ b/src/dram_rules/rule_parser/rules_common.tsv @@ -4,21 +4,21 @@ name alias rule Acetate-2 K01568 & [K00138 | K00128 | K14085 | K00149 | K00129] Pyruvate → acetaldehyde → acetate Acetate-3 [K00625 | K13788 | K15024] & K00925 Acetyl-CoA ↔ acetyl-phosphate ↔ acetate Acetate-4 K01621 & K00925 Xylulose-5-phosphate/fructose-6-phosphate → acetyl-phosphate → acetate - Acetate-5 K01895 | K01913 Acetate → acetyl-CoA; not acetate specific - + Acetate-5 K01895 | K01913 Acetate → acetyl-CoA; not acetate specific + Propionate-Final @Propionate-1 | @Propionate-2 | @Propionate-3 | @Propionate-4 Propionate-associated metabolism Propionate-1 [K01847 | [K01848 & K01849]] & K05606 & [K11264 | K18426] & @Propionate-terminal Succinyl-CoA → methylmalonyl-CoA → propionyl-CoA → propionate Propionate-2 K20626 & K20627 & K00248 & @Propionate-terminal Lactate → lactoyl-CoA → acryloyl-CoA → propionyl-CoA → propionate Propionate-3 K01699 & K13919 & K13920 & K13922 & @Propionate-terminal 1,2-Propanediol → propionaldehyde → propionyl-CoA → propionate Propionate-4 K01908 Propionate → propionyl-CoA Propionate-terminal K01026 | K24012 | [K01905 & K22224] | [K13923 & [K00932 | K19697]] Propionyl-CoA ↔ propionate; broad alternatives require pathway context - + Butyrate-Final @Butyrate-1 | @Butyrate-2 | @Butyrate-3 Butyrate-associated metabolism Butyrate-1 K00634 & K00929 Butyryl-CoA ↔ butyryl-phosphate ↔ butyrate Butyrate-2 [[K01034 & K01035] | K19709] Acetyl-CoA ↔ butyryl-CoA ↔ butyrate through CoA transfer; context-supported, not uniquely specific Butyrate-3 K01913 Butyrate → butyryl-CoA; not butyrate specific Acetyl-CoAtoButyryl-CoA K00626 & [K00074 | K00022 | K07516 | K01825 | K01782 | K07514] & [K01692 | K01825 | K01782 | K07515 | K07514 | K07511 | K01715] & K00248 Acetyl-CoA ↔ acetoacetyl-CoA ↔ 3-hydroxybutyryl-CoA ↔ crotonyl-CoA ↔ butyryl-CoA - + Lactate-Final @Lactate-1 | @Lactate-2 | @Lactate-3 | @Lactate-4 Lactate-associated metabolism Lactate-1 K00016 Pyruvate ↔ L-lactate; NAD-dependent LDH Lactate-2 K03778 Pyruvate ↔ D-lactate; NAD-dependent LDH