File: test_shell.py

package info (click to toggle)
python-screed 1.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 820 kB
  • sloc: python: 3,356; makefile: 169; sh: 32; javascript: 16
file content (141 lines) | stat: -rw-r--r-- 4,433 bytes parent folder | download
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
from __future__ import absolute_import
from . import test_fasta
from . import test_fastq
import os
import subprocess
import screed
from screed.DBConstants import fileExtension
from . import screed_tst_utils as utils
import shutil


class Test_fa_shell_command(test_fasta.Test_fasta):
    """
    Tests the functionality of the 'db' command in creating a
    screed database correctly from the shell
    """

    def setup_method(self):
        thisdir = os.path.dirname(__file__)

        self._testfa = utils.get_temp_filename('test.fa')
        shutil.copy(utils.get_test_data('test.fa'), self._testfa)

        cmd = ['screed', 'db', self._testfa]
        ret = subprocess.check_call(cmd, stdout=subprocess.PIPE)
        assert ret == 0, ret
        self.db = screed.ScreedDB(self._testfa)

    def teardown_method(self):
        os.unlink(self._testfa + fileExtension)


class Test_fq_shell_command(test_fastq.Test_fastq):

    """
    Tests the functionality of the 'db' command in creating a
    screed database correctly from the shell
    """

    def setup_method(self):
        thisdir = os.path.dirname(__file__)

        self._testfq = utils.get_temp_filename('test.fastq')
        shutil.copy(utils.get_test_data('test.fastq'), self._testfq)

        cmd = ['screed', 'db', self._testfq]
        ret = subprocess.check_call(cmd, stdout=subprocess.PIPE)
        assert ret == 0, ret
        self.db = screed.ScreedDB(self._testfq)

    def teardown_method(self):
        os.unlink(self._testfq + fileExtension)


class Test_fa_shell_module(test_fasta.Test_fasta):

    """
    Tests the functionality of the 'db' command in creating a
    screed database correctly from the shell
    """

    def setup_method(self):
        thisdir = os.path.dirname(__file__)

        self._testfa = utils.get_temp_filename('test.fa')
        shutil.copy(utils.get_test_data('test.fa'), self._testfa)

        cmd = ['python3', '-m', 'screed', 'db', self._testfa]
        ret = subprocess.check_call(cmd, stdout=subprocess.PIPE)
        assert ret == 0, ret
        self.db = screed.ScreedDB(self._testfa)

    def teardown_method(self):
        os.unlink(self._testfa + fileExtension)


class Test_fq_shell_module(test_fastq.Test_fastq):

    """
    Tests the functionality of the 'db' command in creating a
    screed database correctly from the shell
    """

    def setup_method(self):
        thisdir = os.path.dirname(__file__)

        self._testfq = utils.get_temp_filename('test.fastq')
        shutil.copy(utils.get_test_data('test.fastq'), self._testfq)

        cmd = ['python3', '-m', 'screed', 'db', self._testfq]
        ret = subprocess.check_call(cmd, stdout=subprocess.PIPE)
        assert ret == 0, ret
        self.db = screed.ScreedDB(self._testfq)

    def teardown_method(self):
        os.unlink(self._testfq + fileExtension)


class Test_convert_shell(test_fasta.Test_fasta):

    """
    Tests the ability to convert a fasta db to a fastq file, parse it into
    a fastq db, save to a fasta file, parse the fasta file into a fasta
    db and then run the fasta suite, all from the command line.
    """

    def setup_method(self):

        self._fqName = utils.get_temp_filename('fa_to_fq')
        self._faName = utils.get_temp_filename('fq_to_fa')
        self._testfa = utils.get_temp_filename('test.fa')
        shutil.copy(utils.get_test_data('test.fa'), self._testfa)

        cmd = ['screed', 'db', self._testfa]
        ret = subprocess.check_call(cmd, stdout=subprocess.PIPE)
        assert ret == 0, ret

        cmd = ['screed', 'dump_fastq', self._testfa, self._fqName]
        ret = subprocess.check_call(cmd, stdout=subprocess.PIPE)
        assert ret == 0, ret

        cmd = ['screed', 'db', self._fqName]
        ret = subprocess.check_call(cmd, stdout=subprocess.PIPE)
        assert ret == 0, ret

        cmd = ['screed', 'dump_fasta', self._fqName, self._faName]
        ret = subprocess.check_call(cmd, stdout=subprocess.PIPE)
        assert ret == 0, ret

        cmd = ['screed', 'db', self._faName]
        ret = subprocess.check_call(cmd, stdout=subprocess.PIPE)
        assert ret == 0, ret

        self.db = screed.ScreedDB(self._faName)

    def teardown_method(self):
        os.unlink(self._fqName)
        os.unlink(self._fqName + fileExtension)
        os.unlink(self._faName)
        os.unlink(self._faName + fileExtension)
        os.unlink(self._testfa + fileExtension)