Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable direct import of CST from package root #353

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ See the [installation instructions](https://coolseqtool.readthedocs.io/latest/in
All CoolSeqTool resources can be initialized by way of a top-level class instance:

```pycon
>>> from cool_seq_tool.app import CoolSeqTool
>>> from cool_seq_tool import CoolSeqTool
>>> from cool_seq_tool.schemas import AnnotationLayer, ResidueMode
>>> cst = CoolSeqTool()
>>> result = await cst.mane_transcript.get_mane_transcript(
Expand Down
6 changes: 3 additions & 3 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The core :py:class:`CoolSeqTool <cool_seq_tool.app.CoolSeqTool>` class encapsula

.. code-block:: pycon

>>> from cool_seq_tool.app import CoolSeqTool
>>> from cool_seq_tool import CoolSeqTool
>>> cst = CoolSeqTool()
>>> cst.seqrepo_access.translate_alias("NM_002529.3")[0][-1]
'ga4gh:SQ.RSkww1aYmsMiWbNdNnOTnVDAM3ZWp1uA'
Expand All @@ -34,7 +34,7 @@ Descriptions and examples of functions can be found in the :ref:`API Reference <

.. code-block:: python

from cool_seq_tool.app import CoolSeqTool
from cool_seq_tool import CoolSeqTool

async def do_thing():
mane_mapper = CoolSeqTool().mane_transcript
Expand All @@ -50,7 +50,7 @@ Descriptions and examples of functions can be found in the :ref:`API Reference <
.. code-block:: pycon

>>> import asyncio
>>> from cool_seq_tool.app import cool_seq_tool
>>> from cool_seq_tool import cool_seq_tool
>>> mane_mapper = CoolSeqTool().mane_transcript
>>> result = asyncio.run(mane_mapper.g_to_grch38("NC_000001.11", 100, 200))
>>> print(result)
Expand Down
6 changes: 6 additions & 0 deletions src/cool_seq_tool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
__version__ = "unknown"
finally:
del version, PackageNotFoundError


# must import after __version__ declaration to prevent ImportError
from cool_seq_tool.app import CoolSeqTool

__all__ = ["CoolSeqTool", "__version__"]
2 changes: 1 addition & 1 deletion src/cool_seq_tool/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(

Initialization with default resource locations is straightforward:

>>> from cool_seq_tool.app import CoolSeqTool
>>> from cool_seq_tool import CoolSeqTool
>>> cst = CoolSeqTool()

By default, this will attempt to fetch the latest versions of static resources,
Expand Down
6 changes: 3 additions & 3 deletions src/cool_seq_tool/mappers/exon_genomic_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(
A lot of resources are required for initialization, so when defaults are enough,
it's easiest to let the core CoolSeqTool class handle it for you:

>>> from cool_seq_tool.app import CoolSeqTool
>>> from cool_seq_tool import CoolSeqTool
>>> egc = CoolSeqTool().ex_g_coords_mapper

Note that this class's public methods are all defined as ``async``, so they will
Expand Down Expand Up @@ -103,7 +103,7 @@ async def transcript_to_genomic_coordinates(
By default, transcript data is aligned to the GRCh38 assembly.

>>> import asyncio
>>> from cool_seq_tool.app import CoolSeqTool
>>> from cool_seq_tool import CoolSeqTool
>>> egc = CoolSeqTool().ex_g_coords_mapper
>>> tpm3 = asyncio.run(
... egc.transcript_to_genomic_coordinates(
Expand Down Expand Up @@ -252,7 +252,7 @@ async def genomic_to_transcript_exon_coordinates(
supplied. ``gene`` must be given in order to retrieve MANE Transcript data.

>>> import asyncio
>>> from cool_seq_tool.app import CoolSeqTool
>>> from cool_seq_tool import CoolSeqTool
>>> from cool_seq_tool.schemas import Strand
>>> egc = CoolSeqTool().ex_g_coords_mapper
>>> result = asyncio.run(
Expand Down
8 changes: 4 additions & 4 deletions src/cool_seq_tool/mappers/mane_transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(
A handful of resources are required for initialization, so when defaults are
enough, it's easiest to let the core CoolSeqTool class handle it for you:

>>> from cool_seq_tool.app import CoolSeqTool
>>> from cool_seq_tool import CoolSeqTool
>>> mane_mapper = CoolSeqTool().mane_transcript

Note that most methods are defined as Python coroutines, so they must be called
Expand Down Expand Up @@ -700,7 +700,7 @@ async def get_longest_compatible_transcript(
information.

>>> import asyncio
>>> from cool_seq_tool.app import CoolSeqTool
>>> from cool_seq_tool import CoolSeqTool
>>> from cool_seq_tool.schemas import AnnotationLayer, ResidueMode
>>> mane_mapper = CoolSeqTool().mane_transcript
>>> mane_transcripts = {
Expand Down Expand Up @@ -974,7 +974,7 @@ async def get_mane_transcript(
``AnnotationLayer.GENOMIC`` GRCh38 representation if ``gene`` is NOT
provided.

>>> from cool_seq_tool.app import CoolSeqTool
>>> from cool_seq_tool import CoolSeqTool
>>> from cool_seq_tool.schemas import AnnotationLayer, ResidueMode
>>> import asyncio
>>> mane_mapper = CoolSeqTool().mane_transcript
Expand Down Expand Up @@ -1231,7 +1231,7 @@ async def g_to_mane_c(
"""Return MANE Transcript on the c. coordinate.

>>> import asyncio
>>> from cool_seq_tool.app import CoolSeqTool
>>> from cool_seq_tool import CoolSeqTool
>>> cst = CoolSeqTool()
>>> result = asyncio.run(
... cst.mane_transcript.g_to_mane_c(
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from cool_seq_tool.app import CoolSeqTool
from cool_seq_tool import CoolSeqTool
from cool_seq_tool.schemas import ManeGeneData, Strand


Expand Down