File: test_transformseq.py

package info (click to toggle)
python-weblogo 3.7.12-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,700 kB
  • sloc: xml: 14,455; python: 10,327; sh: 140; makefile: 61
file content (60 lines) | stat: -rw-r--r-- 1,339 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from subprocess import PIPE, Popen

import weblogo._transformseq

from . import data_stream


def _exec(args, outputtext, returncode=0, stdin=None):  # type: ignore
    if not stdin:
        stdin = data_stream("cap.fa")
    args = ["transformseq"] + args
    p = Popen(args, stdin=stdin, stdout=PIPE, stderr=PIPE)
    (out, err) = p.communicate()
    if returncode == 0 and p.returncode > 0:
        print(err)
    assert returncode == p.returncode
    if returncode == 0:
        assert len(err) == 0

    out = out.decode()

    for item in outputtext:
        assert item in out

    stdin.close()


def test_malformed_options() -> None:
    _exec(["--notarealoption"], [], 2)
    _exec(["extrajunk"], [], 2)
    _exec(["-I"], [], 2)


def test_help_option() -> None:
    _exec(["-h"], ["options"])
    _exec(["--help"], ["options"])


def test_version_option() -> None:
    _exec(["--version"], weblogo._transformseq.__version__)


def test_clustal() -> None:
    _exec(["-F", "clustal"], ["TCTTGTGATGTGGTTAACCAAT"])


def test_reverse() -> None:
    _exec(["--reverse"], ["TAACCAATTGGTGTAGTGTTCT"])


def test_complement() -> None:
    _exec(["--complement"], ["AGAACACTACACCAATTGGTTA"])


def test_seg() -> None:
    _exec(["--seg"], ["XXXXXXXXXXXXXXXXXXXXXX"])


def test_subsample() -> None:
    _exec(["--subsample", "0.4"], [])