Exemplo n.º 1
0
 def test_parse_loc_str_invalid(self):
     length = 12
     examples = [
         'abc',
         '3-8']
     for example in examples:
         with self.assertRaisesRegex(GenBankFormatError,
                                     'Could not parse location string: '
                                     '"%s"' % example):
             _parse_loc_str(example, length)
Exemplo n.º 2
0
    def test_parse_loc_str(self):
        length = 12

        examples = [
            "",
            "9",  # a single base in the presented sequence
            "3..8",
            "<3..8",
            "1..>8",
            "complement(3..8)",
            "complement(join(3..5,7..9))",
            "join(3..5,7..9)",
            "J00194.1:1..9",
            "1.9",
            "1^9",
        ]

        expects = [
            (
                {"right_partial_": False, "left_partial_": False, "rc_": False},
                np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=bool),
            ),
            (
                {"right_partial_": False, "left_partial_": False, "rc_": False},
                np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], dtype=bool),
            ),
            (
                {"right_partial_": False, "left_partial_": False, "rc_": False},
                np.array([0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], dtype=bool),
            ),
            (
                {"right_partial_": False, "left_partial_": True, "rc_": False},
                np.array([0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], dtype=bool),
            ),
            (
                {"right_partial_": True, "left_partial_": False, "rc_": False},
                np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], dtype=bool),
            ),
            (
                {"right_partial_": False, "left_partial_": False, "rc_": True},
                np.array([0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], dtype=bool),
            ),
            (
                {"right_partial_": False, "left_partial_": False, "rc_": True},
                np.array([0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0], dtype=bool),
            ),
            (
                {"right_partial_": False, "left_partial_": False, "rc_": False},
                np.array([0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0], dtype=bool),
            ),
            ({"right_partial_": False, "left_partial_": False, "rc_": False}, np.zeros(length, dtype=bool)),
            ({"right_partial_": False, "left_partial_": False, "rc_": False}, np.zeros(length, dtype=bool)),
            ({"right_partial_": False, "left_partial_": False, "rc_": False}, np.zeros(length, dtype=bool)),
        ]
        for example, expect in zip(examples, expects):
            parsed = _parse_loc_str(example, length)
            self.assertDictEqual(parsed[0], expect[0])
            npt.assert_equal(parsed[1], expect[1])
Exemplo n.º 3
0
    def test_parse_loc_str(self):
        length = 12

        examples = [
            '',
            '9',  # a single base in the presented sequence
            '3..8',
            '<3..8',
            '1..>8',
            'complement(3..8)',
            'complement(join(3..5,7..9))',
            'join(3..5,7..9)',
            'J00194.1:1..9',
            '1.9',
            '1^9']

        expects = [
            ({'right_partial_': False, 'left_partial_': False, 'rc_': False},
             np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=bool)),
            ({'right_partial_': False, 'left_partial_': False, 'rc_': False},
             np.array([0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], dtype=bool)),
            ({'right_partial_': False, 'left_partial_': False, 'rc_': False},
             np.array([0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], dtype=bool)),
            ({'right_partial_': False, 'left_partial_': True, 'rc_': False},
             np.array([0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], dtype=bool)),
            ({'right_partial_': True, 'left_partial_': False, 'rc_': False},
             np.array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], dtype=bool)),
            ({'right_partial_': False, 'left_partial_': False, 'rc_': True},
             np.array([0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], dtype=bool)),
            ({'right_partial_': False, 'left_partial_': False, 'rc_': True},
             np.array([0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0], dtype=bool)),
            ({'right_partial_': False, 'left_partial_': False, 'rc_': False},
             np.array([0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0], dtype=bool)),
            ({'right_partial_': False, 'left_partial_': False, 'rc_': False},
             np.zeros(length, dtype=bool)),
            ({'right_partial_': False, 'left_partial_': False, 'rc_': False},
             np.zeros(length, dtype=bool)),
            ({'right_partial_': False, 'left_partial_': False, 'rc_': False},
             np.zeros(length, dtype=bool))]
        for example, expect in zip(examples, expects):
            parsed = _parse_loc_str(example, length)
            self.assertDictEqual(parsed[0], expect[0])
            npt.assert_equal(parsed[1], expect[1])
Exemplo n.º 4
0
 def test_parse_loc_str_invalid(self):
     length = 12
     examples = ["abc", "3-8"]
     for example in examples:
         with six.assertRaisesRegex(self, GenBankFormatError, "Could not parse location string: " '"%s"' % example):
             _parse_loc_str(example, length)