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
|
"""
Copyright 2020 Kat Holt
Copyright 2020 Ryan Wick (rrwick@gmail.com)
https://github.com/katholt/Kleborate/
This file is part of Kleborate. Kleborate is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version. Kleborate is distributed in
the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details. You should have received a copy of the GNU General Public License along with Kleborate. If
not, see <http://www.gnu.org/licenses/>.
"""
import collections
import unittest
from kleborate.__main__ import get_iro_mlst_results
class TestIro(unittest.TestCase):
"""
Tests salmochelin ST calls.
"""
def setUp(self):
self.data_dir = 'test/test_iro/data'
Args = collections.namedtuple('Args', ['min_coverage', 'min_identity',
'min_spurious_coverage', 'min_spurious_identity'])
self.args = Args(min_coverage=80.0, min_identity=90.0,
min_spurious_coverage=40.0, min_spurious_identity=80.0)
def test_iro_random(self):
"""
This test has just random sequence and should give no iro call.
"""
results = get_iro_mlst_results(self.data_dir, 'test/test_iro/test_random.fasta', self.args)
self.assertEqual(results['iroB'], '-')
self.assertEqual(results['iroC'], '-')
self.assertEqual(results['iroD'], '-')
self.assertEqual(results['iroN'], '-')
self.assertEqual(results['Salmochelin'], '-')
self.assertEqual(results['SmST'], '0')
def test_iro_exact_33(self):
"""
This test is an exact match for SmST33.
"""
results = get_iro_mlst_results(self.data_dir, 'test/test_iro/test_iro_1.fasta', self.args)
self.assertEqual(results['iroB'], '22-29%')
self.assertEqual(results['iroC'], '33-4%')
self.assertEqual(results['iroD'], '12')
self.assertEqual(results['iroN'], '15')
self.assertEqual(results['Salmochelin'], 'iro 4 (truncated)')
self.assertEqual(results['SmST'], '33')
def test_iro_inexact(self):
"""
This test is an inexact match for SmST33. There are single base changes in iroC and in
iroN.
"""
results = get_iro_mlst_results(self.data_dir, 'test/test_iro/test_iro_2.fasta', self.args)
self.assertEqual(results['iroB'], '22-29%')
self.assertEqual(results['iroC'], '33*-4%')
self.assertEqual(results['iroD'], '12')
self.assertEqual(results['iroN'], '15*')
self.assertEqual(results['Salmochelin'], 'iro 4 (truncated)')
self.assertEqual(results['SmST'], '33-2LV')
def test_iro_novel(self):
"""
This test is an exact match for alleles, but an unknown combination.
"""
results = get_iro_mlst_results(self.data_dir, 'test/test_iro/test_iro_3.fasta', self.args)
self.assertEqual(results['iroB'], '11')
self.assertEqual(results['iroC'], '1')
self.assertEqual(results['iroD'], '18')
self.assertEqual(results['iroN'], '5')
self.assertEqual(results['Salmochelin'], 'iro unknown')
self.assertEqual(results['SmST'], '0')
def test_iro_incomplete(self):
"""
This test is an exact match for only one allele.
"""
results = get_iro_mlst_results(self.data_dir, 'test/test_iro/test_iro_4.fasta', self.args)
self.assertEqual(results['iroB'], '-')
self.assertEqual(results['iroC'], '1')
self.assertEqual(results['iroD'], '-')
self.assertEqual(results['iroN'], '-')
self.assertEqual(results['Salmochelin'], '-')
self.assertEqual(results['SmST'], '0')
def test_iro_exact_1(self):
"""
This test is an exact match for SmST1.
"""
results = get_iro_mlst_results(self.data_dir, 'test/test_iro/test_iro_5.fasta', self.args)
self.assertEqual(results['iroB'], '1')
self.assertEqual(results['iroC'], '1')
self.assertEqual(results['iroD'], '1')
self.assertEqual(results['iroN'], '1')
self.assertEqual(results['Salmochelin'], 'iro 1')
self.assertEqual(results['SmST'], '1')
def test_iro_missing_1(self):
"""
This test is a match for SmST1, except that it's missing iroN.
"""
results = get_iro_mlst_results(self.data_dir, 'test/test_iro/test_iro_6.fasta', self.args)
self.assertEqual(results['iroB'], '1')
self.assertEqual(results['iroC'], '1')
self.assertEqual(results['iroD'], '1')
self.assertEqual(results['iroN'], '-')
self.assertEqual(results['Salmochelin'], 'iro 1 (incomplete)')
self.assertEqual(results['SmST'], '1-1LV')
|