From 8de639b0ea06815b9b98b0c28ad35aed149b2c60 Mon Sep 17 00:00:00 2001 From: js2264 Date: Mon, 29 Jul 2024 13:53:15 +0200 Subject: [PATCH] First commit --- .github/codecov.yml | 18 ++ .github/dependabot.yml | 11 + .github/workflows/ci.yml | 40 +++ .github/workflows/documentation.yml | 38 +++ .github/workflows/publish.yml | 35 +++ .gitignore | 36 +++ .readthedocs.yml | 28 ++ CHANGES.md | 8 + CITATION.cff | 32 +++ LICENSE | 407 ++++++++++++++++++++++++++++ README.md | 1 + docs/Makefile | 195 +++++++++++++ docs/source/conf.py | 73 +++++ docs/source/glossary.rst | 6 + docs/source/index.rst | 30 ++ pyproject.toml | 147 ++++++++++ src/momics/__init__.py | 18 ++ src/momics/_version.py | 11 + src/momics/api.py | 87 ++++++ tests/conftest.py | 4 + tests/test_main.py | 18 ++ 21 files changed, 1243 insertions(+) create mode 100644 .github/codecov.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/documentation.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .gitignore create mode 100644 .readthedocs.yml create mode 100644 CHANGES.md create mode 100644 CITATION.cff create mode 100644 LICENSE create mode 100644 README.md create mode 100644 docs/Makefile create mode 100644 docs/source/conf.py create mode 100644 docs/source/glossary.rst create mode 100644 docs/source/index.rst create mode 100644 pyproject.toml create mode 100644 src/momics/__init__.py create mode 100644 src/momics/_version.py create mode 100644 src/momics/api.py create mode 100644 tests/conftest.py create mode 100644 tests/test_main.py diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..deebed5 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,18 @@ +codecov: + notify: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: 70..100 + + status: + project: + default: + target: 90% + threshold: 1% + patch: no + changes: no + +comment: off \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..d8e8d4d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +--- +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7640a6f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: [ devel ] + pull_request: + branches: [ devel ] + +jobs: + + Test: + strategy: + matrix: + os: [ubuntu-latest] + python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ] + include: + - os: ubuntu-latest + python-version: "3.12" + # - os: windows-latest + # python-version: "3.12" + - os: macos-latest + python-version: "3.12" + + runs-on: ${{ matrix.os }} + steps: + + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Run tests on ${{ matrix.os }} + run: | + python -m pip install --upgrade pip + pip install -e .[dev] + # stop the build if there are Python syntax errors or undefined names + ruff check . --select=E9,F63,F7,F82 + pytest diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..81638c7 --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,38 @@ +name: documentation + +on: [push, pull_request, workflow_dispatch] + +permissions: + contents: write + +jobs: + docs: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: 3.12 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[dev,docs] + # stop the build if there are Python syntax errors or undefined names + ruff check . --select=E9,F63,F7,F82 + pytest + + - name: Sphinx build + run: | + sphinx-build docs/source/ docs/build + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/devel' }} + with: + publish_branch: gh-pages + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/build/ + force_orphan: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..4d1ec78 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Publish Python Package to PyPI + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + Publish: + # prevents this action from running on forks + if: github.repository == 'js2264/momics' + + runs-on: ubuntu-latest + permissions: + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + + - name: Build + run: python -m build + + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8d3d828 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +*.swp +*.swo +*~ + +*.py[cod] +__pycache__ + +# test and coverage artifacts +.cache +.pytest_cache +.coverage +.coverage.* +coverage.xml +htmlcov/ + +# setup and build artifacts +docs/_* +*.egg-info/ +dist/ +build/ +MANIFEST + +# dev and virtual environment +.venv/ +venv/ +.idea/ + +# OS-generated files +.DS_Store +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +tmp/ +_scratch/ \ No newline at end of file diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..f2bdf6a --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,28 @@ +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3.10" +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/source/conf.py + +# Build documentation with MkDocs +#mkdocs: +# configuration: mkdocs.yml + +# Optionally build your docs in additional formats such as PDF and ePub +formats: all + +# Optionally set the version of Python and requirements required to build your docs +python: + install: + - method: pip + path: . + extra_requirements: + - dev + - docs diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..ce3d50d --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,8 @@ +# Release notes # + +## [v0.1.0](https://github.com/js2264/momics/releases/tag/v0.1) + +Date: 2024-07-29 + +* Working initial prototype + diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..e3522d4 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,32 @@ +cff-version: 1.2.0 +type: software +title: momics +message: >- + Please cite this software using the metadata from "preferred-citation". +abstract: >- + momics is a cloud-native, TileDB-based format for multi-omics data. + Follow momics development on GitHub. +license: "BSD-3-Clause" +# doi: "10.5281/zenodo.597976" +url: "https://js2264.github.io/momics" +repository-code: "https://github.com/js2264/momics" +keywords: + - multi-omics + - genomics + - epigenomics + - Tile-DB + - bioinformatics + - matrix + - sparse + - format +authors: + - given-names: Jacques + family-names: Serizay + orcid: "https://orcid.org/0000-0002-4295-0624" +preferred-citation: + type: software + title: "momics: a cloud-native, TileDB-based format for multi-omics data" + authors: + - given-names: Jacques + family-names: Serizay + orcid: "https://orcid.org/0000-0002-4295-0624" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c657cab --- /dev/null +++ b/LICENSE @@ -0,0 +1,407 @@ +Attribution-NonCommercial 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution-NonCommercial 4.0 International Public +License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-NonCommercial 4.0 International Public License ("Public +License"). To the extent this Public License may be interpreted as a +contract, You are granted the Licensed Rights in consideration of Your +acceptance of these terms and conditions, and the Licensor grants You +such rights in consideration of benefits the Licensor receives from +making the Licensed Material available under these terms and +conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + i. NonCommercial means not primarily intended for or directed towards + commercial advantage or monetary compensation. For purposes of + this Public License, the exchange of the Licensed Material for + other material subject to Copyright and Similar Rights by digital + file-sharing or similar means is NonCommercial provided there is + no payment of monetary compensation in connection with the + exchange. + + j. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + k. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + l. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part, for NonCommercial purposes only; and + + b. produce, reproduce, and Share Adapted Material for + NonCommercial purposes only. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties, including when + the Licensed Material is used other than for NonCommercial + purposes. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database for NonCommercial purposes + only; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3dc7d6a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# momics diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..43a0c52 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,195 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " coverage to run coverage check of the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/cooler.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/cooler.qhc" + +applehelp: + $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp + @echo + @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." + @echo "N.B. You won't be able to view it unless you put it in" \ + "~/Library/Documentation/Help or install it in your application" \ + "bundle." + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/cooler" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/cooler" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +coverage: + $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage + @echo "Testing of coverage in the sources finished, look at the " \ + "results in $(BUILDDIR)/coverage/python.txt." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." + +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..e46d426 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python + +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +from datetime import datetime +from importlib.metadata import metadata + +info = metadata("momics") +project = info["Name"] +author = "Jacques Serizay" +copyright = f"2023-{datetime.now():%Y}, {author}." +copyright = f"{datetime.now():%Y}, {author}." +release = info["Version"] +version = release.rsplit(".", maxsplit=1)[0] + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.doctest", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.mathjax", + "sphinx.ext.ifconfig", + "sphinx.ext.viewcode", + "sphinx.ext.autosummary", + "sphinx.ext.napoleon", + "recommonmark", +] + +numpydoc_show_class_members = False +napoleon_use_rtype = False +autodoc_typehints = "description" +autodoc_class_signature = "separated" +templates_path = ['_templates'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] +source_suffix = { + ".rst": "restructuredtext", + ".md": "markdown", +} +pygments_style = "sphinx" +todo_include_todos = False +master_doc = "index" + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'alabaster' +html_static_path = ['_static'] +htmlhelp_basename = "momicsdoc" + +# -- Options for manual page output --------------------------------------- +man_pages = [(master_doc, "momics", "momics Documentation", [author], 1)] + +# -- Options for Texinfo output ------------------------------------------- +texinfo_documents = [ + ( + master_doc, + "momics", + "momics Documentation", + author, + "momics", + "One line description of project.", + "Miscellaneous", + ), +] diff --git a/docs/source/glossary.rst b/docs/source/glossary.rst new file mode 100644 index 0000000..3db0d4e --- /dev/null +++ b/docs/source/glossary.rst @@ -0,0 +1,6 @@ +.. _Glossary: + +Glossary +-------- + +* momics is a general purpose binary container format for multi-omics datasets. diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..796b97c --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,30 @@ +.. momics documentation master file, created by + sphinx-quickstart on Mon Jul 29 11:05:32 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +momics +====== + +`momics` is a Python support library for .momics files. + +The `momics` package aims to facilitate: + +* Creation: ingestion of genomic files into `momics` files; +* Querying: sequential and range query patterns and tabular and array retrieval; +* Scalable: cloud-native, out-of-core operations on the data; +* Export: data export. + +Follow cooler development on `GitHub `_. + +Contents: + +.. toctree:: + :maxdepth: 2 + + api + Glossary + +* :ref:`genindex` +* :ref:`Glossary` + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9a8679c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,147 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "momics" +version = "0.1.0" +description = "A package to create and manage genome-related TileDB arrays" +requires-python = ">=3.8" +license = {text = "CC BY-NC 4.0"} +readme = "README.md" +authors = [ + {name = "Jacques Serizay", email = "jacques.serizay@pasteur.fr"} +] +keywords = [ + "multi-omics", + "genomics", + "epigenomics", + "Tile-DB", + "bioinformatics", + "matrix", + "sparse", + "format" +] +classifiers = [ + "Operating System :: OS Independent", + "Programming Language :: Python :: 3" +] +dependencies = [ + "tiledb", + "pyBigWig", + "numpy", + "pandas" +] + +[project.urls] +homepage = "https://js2264.github.io/momics" +documentation = "https://momics.readthedocs.io" +repository = "https://github.com/js2264/momics" +changelog = "https://github.com/js2264/momics/blob/devel/CHANGES.md" + +[project.scripts] +momics = "momics.cli:cli" + +[tool.hatch.version] +path = "src/momics/_version.py" + +[tool.hatch.metadata] +allow-direct-references = true + +[project.optional-dependencies] +all = [ + "biopython", + "dask[array,dataframe]", + "matplotlib", + "psutil", +] +test = [ + "coverage[toml]", + "isort", + "pytest", + "pytest-cov", + "ruff", +] +dev = [ + "momics[all,test]", + "pre-commit" +] +docs = [ + "autodocsumm", + "m2r", + "recommonmark", + "Sphinx>=1.6", + "sphinx-autobuild", + "sphinx_rtd_theme", +] + +[tool.ruff] +src = ["src"] +exclude = [ + ".venv", + "__main__.py", +] + +[tool.ruff.lint] +extend-select = [ + "B", # bugbear + "E", # style errors + "F", # pyflakes + "I", # isort + "RUF", # ruff-specific rules + "UP", # pyupgrade + "W", # style warnings +] + +[tool.ruff.lint.isort] +known-first-party = ["momics"] + +[tool.ruff.lint.pydocstyle] +convention = "numpy" + +[tool.pytest.ini_options] +minversion = "7" +log_cli_level = "INFO" +xfail_strict = true +addopts = [ + "-ra", + "--strict-config", + "--strict-markers", + "--cov=momics", + "--cov-config=pyproject.toml", + "--cov-report=term-missing", + "--cov-report=html", + "--cov-report=xml", +] +filterwarnings = ["ignore::PendingDeprecationWarning"] +testpaths = ["tests"] + +[tool.coverage.run] +source = ["momics"] + +omit = [ + "*/momics/__main__.py", + "*/momics/_version.py", + "*/momics/sandbox/*", + "*/momics/cli/csort.py" +] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "return NotImplemented", + "raise NotImplementedError" +] + +[tool.hatch.envs.default.scripts] +fix = "ruff check --fix src tests" +lint = "ruff check src tests" +test = "pytest ." +docs = "sphinx-autobuild docs docs/_build/html" + +[tool.hatch.envs.test] +features = ["dev"] + +[[tool.hatch.envs.test.matrix]] +python = ["3.8", "3.9", "3.10", "3.11", "3.12"] + diff --git a/src/momics/__init__.py b/src/momics/__init__.py new file mode 100644 index 0000000..2c97e2e --- /dev/null +++ b/src/momics/__init__.py @@ -0,0 +1,18 @@ +""" +momics +~~~~~~ + +Cloud-native, TileDB-based multi-omics data format. + +:author: Jacques Serizay +:license: CC BY-NC 4.0 + +""" + +from ._version import __format_version__, __version__ +from .api import Momics + +__all__ = [ + "__version__", + "__format_version__", +] diff --git a/src/momics/_version.py b/src/momics/_version.py new file mode 100644 index 0000000..a6fd942 --- /dev/null +++ b/src/momics/_version.py @@ -0,0 +1,11 @@ +try: + from importlib.metadata import PackageNotFoundError, version +except ImportError: + from importlib_metadata import PackageNotFoundError, version + +try: + __version__ = version("momics") +except PackageNotFoundError: + __version__ = "unknown" + +__format_version__ = 1 diff --git a/src/momics/api.py b/src/momics/api.py new file mode 100644 index 0000000..68e75d0 --- /dev/null +++ b/src/momics/api.py @@ -0,0 +1,87 @@ +import os +import tiledb +import numpy as np +import pandas as pd + +__all__ = ["Momics"] + +class Momics: + """ + A convenient interface to a momics data collection. + + Parameters + ---------- + store : str, Path to a momics file (URI string) + kwargs : Options passed to methods. + + Notes + ----- + If ``store`` is a file path, the file will be opened temporarily in + when performing operations. This allows :py:class:`Momics` objects to be + serialized for multiprocess and distributed computations. + + Table selectors, created using :py:meth:`genome`, :py:meth:`scores`, and + :py:meth:`intervals`, perform range queries over table rows, + returning :py:class:`pd.DataFrame`, :py:class:`pd.Series` or + :py:class:`numpy.ndarray` + + Metadata is accessible as a dictionary through the :py:attr:`info` + property. + + """ + + def __init__(self, store: str): + self._refresh() + + def _refresh(self) -> None: + try: + None + except KeyError: + raise KeyError("err_msg") from None + + def genome(self, **kwargs): + """Genome array selector + + Returns + ------- + Array + + """ + + return self + + def scores(self, **kwargs): + """Scores array selector + + Returns + ------- + Array + + """ + + return self + + def intervals(self, **kwargs): + """Intervals array selector + + Returns + ------- + Array + + """ + + return self + + # @property + # def info(self) -> dict: + # """File information and metadata + # + # Returns + # ------- + # dict + # + # """ + # with open_hdf5(self.store, **self.open_kws) as h5: + # grp = h5[self.root] + # return info(grp) + diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..54737f6 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,4 @@ +from unittest import mock + +import numpy as np +import pytest diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 0000000..d9b1c88 --- /dev/null +++ b/tests/test_main.py @@ -0,0 +1,18 @@ +import os + +import tiledb +import numpy as np +import pytest + +import momics +from momics import api + +testdir = os.path.dirname(os.path.realpath(__file__)) + +@pytest.mark.parametrize( + "file_path", + [(os.path.join(testdir, "data", "test.momics"))], +) +def test_api(file_path): + clr = momics.api.Momics(file_path) + print(clr)