Skip to content

Commit

Permalink
Add example to pyopal.align docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Jan 17, 2024
1 parent ffffb94 commit d53586a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
8 changes: 8 additions & 0 deletions pyopal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ def align(
``score``, `EndResult` for mode ``end`` and `FullResult` for
mode ``full``.
Example:
>>> targets = ["AACCGCTG", "ATGCGCT", "TTATTACG"]
>>> for result in pyopal.align("ACCTG", targets, gap_open=2):
... print(result.score, targets[result.target_index])
41 AACCGCTG
31 ATGCGCT
23 TTATTACG
"""
# derive default parameters
if threads == 0:
Expand Down
19 changes: 13 additions & 6 deletions pyopal/tests/test_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
import warnings
from unittest import mock

try:
import numpy
except ImportError:
numpy = None

import pyopal


Expand Down Expand Up @@ -70,13 +65,25 @@ def tearDown(self):
packages = [None, pyopal]

for pkg in iter(packages.pop, None):
globs = dict(pyopal=pyopal, Bio=Bio, **pkg.__dict__)
tests.addTests(
doctest.DocTestSuite(
pkg,
globs=globs,
setUp=setUp,
tearDown=tearDown,
optionflags=+doctest.ELLIPSIS,
)
)
for (_, subpkgname, subispkg) in pkgutil.walk_packages(pkg.__path__):
# do not import __main__ module to avoid side effects!
if subpkgname == "__main__" or subpkgname.startswith("tests"):
continue
# import the submodule and add it to the tests
module = importlib.import_module(".".join([pkg.__name__, subpkgname]))
globs = dict(pyopal=pyopal, numpy=numpy, Bio=Bio, **module.__dict__)
if hasattr(module, "__test__"):
del module.__test__
globs = dict(pyopal=pyopal, Bio=Bio, **module.__dict__)
tests.addTests(
doctest.DocTestSuite(
module,
Expand Down

0 comments on commit d53586a

Please sign in to comment.