Skip to content

Commit

Permalink
update docstrings to pass the doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
akikuno committed Nov 24, 2023
1 parent 2bfc6e9 commit d37a56a
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 11 deletions.
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ classifiers = [
[tool.poetry.dependencies]
python = "^3.8"
weasyprint = ">=52.5"

[tool.pytest.ini_options]
addopts = [
"--doctest-modules",
"--doctest-glob=README.md",
"--ignore=examples",
"--verbose",
"-ra",
"--color=yes",
]
doctest_optionflags = "NORMALIZE_WHITESPACE"
pythonpath = "src"
testpaths = ["tests"]
2 changes: 1 addition & 1 deletion src/cstag/consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def consensus(cs_tags: list[str], positions: list[int], prefix: bool = False) ->
>>> cs_tags = ["=ACGT", "=AC*gt=T", "=C*gt=T", "=C*gt=T", "=ACT+ccc=T"]
>>> positions = [1,1,1,2,1]
>>> cstag.consensus(cs_tags, positions)
=AC*gt=T
'=AC*gt=T'
"""
if not (len(cs_tags) == len(positions) > 0):
raise ValueError("Element numbers of each argument must be the same")
Expand Down
2 changes: 1 addition & 1 deletion src/cstag/lengthen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def lengthen(cs_tag: str, cigar: str, seq: str, prefix: bool = False) -> str:
>>> cigar = "8M"
>>> seq = "ACGTACGT"
>>> cstag.lengthen(cs, cigar, seq)
=ACGT*ag=CGT
'=ACGT*ag=CGT'
"""
validate_cs_tag(cs_tag)
validate_short_format(cs_tag)
Expand Down
4 changes: 2 additions & 2 deletions src/cstag/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def mask(cs_tag: str, cigar: str, qual: str, threshold: int = 10, prefix: bool =
>>> cs_tag = "=ACGT*ac+gg-cc=T"
>>> cigar = "5M2I2D1M"
>>> qual = "AA!!!!AA"
>>> cstag.mask(cs_tag, qual)
=ACNN*an+ng-cc=T
>>> cstag.mask(cs_tag, cigar, qual)
'=ACNN*an+ng-cc=T'
"""
validate_cs_tag(cs_tag)
validate_long_format(cs_tag)
Expand Down
2 changes: 1 addition & 1 deletion src/cstag/revcomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def revcomp(cs_tag: str, prefix: bool = False) -> str:
>>> import cstag
>>> cs = "=AAAA*ag=CTG"
>>> cstag.revcomp(cs)
=CAG*tc=TTTT
'=CAG*tc=TTTT'
"""
pattern = r"(\=[ACGTN]+|:[0-9]+|\*[acgtn][acgtn]|\+[acgtn]+|\-[acgtn]+|\~[acgtn]{2}[0-9]+[acgtn]{2})"
cs_tag_revcomp = []
Expand Down
2 changes: 1 addition & 1 deletion src/cstag/shorten.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def shorten(cs_tag: str, prefix: bool = False) -> str:
>>> import cstag
>>> cs = "=ACGT*ag=CGT"
>>> cstag.shorten(cs, prefix=True)
cs:Z::4*ag:3
'cs:Z::4*ag:3'
"""
cstags = re.split(r"([-+*~=])", cs_tag.replace("cs:Z:", ""))[1:]
cstags = [i + j for i, j in zip(cstags[0::2], cstags[1::2])]
Expand Down
2 changes: 1 addition & 1 deletion src/cstag/split.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def split(cs_tag: str, prefix: bool = False) -> list[str]:
>>> import cstag
>>> cs = ":4*ag:3"
>>> cstag.split(cs)
[":4", "*ag", ":3"]
[':4', '*ag', ':3']
"""
cs_tag = cs_tag.replace("cs:Z:", "")

Expand Down
2 changes: 1 addition & 1 deletion src/cstag/to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def to_html(cs_tag: str, description: str = "") -> str:
HTML string
Example:
>>> import cstag
>>> cs_tag = "=AC+GGG=T-ACGT*at~gt10cg=GNNN"
>>> cs_tag = "=AC+ggg=T-acgt*at~gt10cg=GNNN"
>>> description = "Example"
>>> html_string = cstag.to_html(cs_tag, description)
"""
Expand Down
2 changes: 1 addition & 1 deletion src/cstag/to_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def to_pdf(cs_tag: str, description: str, path_out: str | Path) -> None:
Examples:
>>> import cstag
>>> cs_tag = "=AC+GGG=T-ACGT*at~gt10cg=GNNN"
>>> cs_tag = "=AC+ggg=T-acgt*at~gt10cg=GNNN"
>>> description = "Example"
>>> path_out = "report.pdf"
>>> to_pdf(cs_tag, description, path_out)
Expand Down
2 changes: 1 addition & 1 deletion src/cstag/to_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def to_sequence(cs_tag: str) -> str:
>>> import cstag
>>> cs_tag = "=AC*gt=T-gg=C+tt=A"
>>> cstag.to_sequence(cs_tag)
"ACTTCTTA"
'ACTTCTTA'
"""
validate_cs_tag(cs_tag)
validate_long_format(cs_tag)
Expand Down
2 changes: 1 addition & 1 deletion src/cstag/to_vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def to_vcf(cs_tags: str | list[str], chroms: str | int | list[str] | list[int],
>>> cs_tag = "=AC*gt=T-gg=C+tt=A"
>>> chrom = "chr1"
>>> pos = 1
>>> print(cstag.to_vcf(cstag, chrom, pos))
>>> print(cstag.to_vcf(cs_tag, chrom, pos))
##fileformat=VCFv4.2
#CHROM POS ID REF ALT QUAL FILTER INFO
chr1 3 . G T . . .
Expand Down

0 comments on commit d37a56a

Please sign in to comment.