From c5ae578d8f5615e837235ac2019b682c008f28e7 Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Wed, 16 Oct 2024 17:19:33 +0200 Subject: [PATCH 1/2] Update package structure --- src/fancypackage/__init__.py | 7 ++- src/fancypackage/core/__init__.py | 3 - src/fancypackage/pl/__init__.py | 1 + src/fancypackage/pl/basic.py | 63 +++++++++++++++++++ src/fancypackage/pp/__init__.py | 1 + src/fancypackage/pp/basic.py | 17 +++++ src/fancypackage/tl/__init__.py | 1 + src/fancypackage/tl/basic.py | 17 +++++ src/fancypackage/ul/__init__.py | 1 + .../{core/_constants.py => ul/constants.py} | 0 10 files changed, 106 insertions(+), 5 deletions(-) delete mode 100644 src/fancypackage/core/__init__.py create mode 100644 src/fancypackage/pl/__init__.py create mode 100644 src/fancypackage/pl/basic.py create mode 100644 src/fancypackage/pp/__init__.py create mode 100644 src/fancypackage/pp/basic.py create mode 100644 src/fancypackage/tl/__init__.py create mode 100644 src/fancypackage/tl/basic.py create mode 100644 src/fancypackage/ul/__init__.py rename src/fancypackage/{core/_constants.py => ul/constants.py} (100%) diff --git a/src/fancypackage/__init__.py b/src/fancypackage/__init__.py index 298947e..084105a 100644 --- a/src/fancypackage/__init__.py +++ b/src/fancypackage/__init__.py @@ -1,3 +1,6 @@ -from .core import DATA_DIR, FIG_DIR +from importlib.metadata import version -__all__ = ["DATA_DIR", "FIG_DIR"] +from . import pl, pp, tl, ul + +__all__ = ["pl", "pp", "tl", "ul"] +__version__ = version("fancypackage") diff --git a/src/fancypackage/core/__init__.py b/src/fancypackage/core/__init__.py deleted file mode 100644 index 54d77ea..0000000 --- a/src/fancypackage/core/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from ._constants import DATA_DIR, FIG_DIR - -__all__ = ["DATA_DIR", "FIG_DIR"] diff --git a/src/fancypackage/pl/__init__.py b/src/fancypackage/pl/__init__.py new file mode 100644 index 0000000..c2315dd --- /dev/null +++ b/src/fancypackage/pl/__init__.py @@ -0,0 +1 @@ +from .basic import BasicClass, basic_plot diff --git a/src/fancypackage/pl/basic.py b/src/fancypackage/pl/basic.py new file mode 100644 index 0000000..ed390ef --- /dev/null +++ b/src/fancypackage/pl/basic.py @@ -0,0 +1,63 @@ +from anndata import AnnData + + +def basic_plot(adata: AnnData) -> int: + """Generate a basic plot for an AnnData object. + + Parameters + ---------- + adata + The AnnData object to preprocess. + + Returns + ------- + Some integer value. + """ + print("Import matplotlib and implement a plotting function here.") + return 0 + + +class BasicClass: + """A basic class. + + Parameters + ---------- + adata + The AnnData object to preprocess. + """ + + my_attribute: str = "Some attribute." + my_other_attribute: int = 0 + + def __init__(self, adata: AnnData): + print("Implement a class here.") + + def my_method(self, param: int) -> int: + """A basic method. + + Parameters + ---------- + param + A parameter. + + Returns + ------- + Some integer value. + """ + print("Implement a method here.") + return 0 + + def my_other_method(self, param: str) -> str: + """Another basic method. + + Parameters + ---------- + param + A parameter. + + Returns + ------- + Some integer value. + """ + print("Implement a method here.") + return "" diff --git a/src/fancypackage/pp/__init__.py b/src/fancypackage/pp/__init__.py new file mode 100644 index 0000000..5e7e293 --- /dev/null +++ b/src/fancypackage/pp/__init__.py @@ -0,0 +1 @@ +from .basic import basic_preproc diff --git a/src/fancypackage/pp/basic.py b/src/fancypackage/pp/basic.py new file mode 100644 index 0000000..5db1ec0 --- /dev/null +++ b/src/fancypackage/pp/basic.py @@ -0,0 +1,17 @@ +from anndata import AnnData + + +def basic_preproc(adata: AnnData) -> int: + """Run a basic preprocessing on the AnnData object. + + Parameters + ---------- + adata + The AnnData object to preprocess. + + Returns + ------- + Some integer value. + """ + print("Implement a preprocessing function here.") + return 0 diff --git a/src/fancypackage/tl/__init__.py b/src/fancypackage/tl/__init__.py new file mode 100644 index 0000000..95a32cd --- /dev/null +++ b/src/fancypackage/tl/__init__.py @@ -0,0 +1 @@ +from .basic import basic_tool diff --git a/src/fancypackage/tl/basic.py b/src/fancypackage/tl/basic.py new file mode 100644 index 0000000..d215ade --- /dev/null +++ b/src/fancypackage/tl/basic.py @@ -0,0 +1,17 @@ +from anndata import AnnData + + +def basic_tool(adata: AnnData) -> int: + """Run a tool on the AnnData object. + + Parameters + ---------- + adata + The AnnData object to preprocess. + + Returns + ------- + Some integer value. + """ + print("Implement a tool to run on the AnnData object.") + return 0 diff --git a/src/fancypackage/ul/__init__.py b/src/fancypackage/ul/__init__.py new file mode 100644 index 0000000..014120e --- /dev/null +++ b/src/fancypackage/ul/__init__.py @@ -0,0 +1 @@ +from .constants import DATA_DIR, FIG_DIR diff --git a/src/fancypackage/core/_constants.py b/src/fancypackage/ul/constants.py similarity index 100% rename from src/fancypackage/core/_constants.py rename to src/fancypackage/ul/constants.py From 31a542404b4171bcfae9d14a585299a2ab2112c8 Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Wed, 16 Oct 2024 17:33:48 +0200 Subject: [PATCH 2/2] Update the sample notebook --- ...> [INITIALS]-[DATE]_sample_notebook.ipynb} | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) rename analysis/{ML-2024-04-24_sample_notebook.ipynb => [INITIALS]-[DATE]_sample_notebook.ipynb} (89%) diff --git a/analysis/ML-2024-04-24_sample_notebook.ipynb b/analysis/[INITIALS]-[DATE]_sample_notebook.ipynb similarity index 89% rename from analysis/ML-2024-04-24_sample_notebook.ipynb rename to analysis/[INITIALS]-[DATE]_sample_notebook.ipynb index fee0051..07a4239 100644 --- a/analysis/ML-2024-04-24_sample_notebook.ipynb +++ b/analysis/[INITIALS]-[DATE]_sample_notebook.ipynb @@ -50,14 +50,23 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2021-05-31T09:25:02.307098Z", "start_time": "2021-05-31T09:25:02.291254Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The autoreload extension is already loaded. To reload it, use:\n", + " %reload_ext autoreload\n" + ] + } + ], "source": [ "%load_ext autoreload\n", "%autoreload 2" @@ -72,7 +81,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2021-05-31T09:25:05.984402Z", @@ -84,7 +93,7 @@ "source": [ "# import single-cell packages\n", "import scanpy as sc\n", - "from fancypackage import DATA_DIR, FIG_DIR" + "from fancypackage.ul import DATA_DIR, FIG_DIR" ] }, { @@ -96,14 +105,14 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Running Scanpy 1.9.3, on 2024-04-24 17:16.\n" + "Running Scanpy 1.10.3, on 2024-10-16 17:32.\n" ] } ], @@ -120,7 +129,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -158,14 +167,14 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "/Users/mlange/Projects/analysis_template/data\n" + "/nas/groups/treutlein/USERS/mlange/github/analysis_template/data\n" ] } ], @@ -188,7 +197,7 @@ ], "metadata": { "kernelspec": { - "display_name": "py310", + "display_name": "analysis_template", "language": "python", "name": "python3" }, @@ -202,7 +211,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.11.10" }, "toc": { "base_numbering": 1,