コード例 #1
0
ファイル: test_sample.py プロジェクト: cogent3/cogent3
    def test_concat_validates_type(self):
        """raises TypeError if not known alignment type"""
        data = [
            {
                "seq1": "AAA",
                "seq2": "AAA",
                "seq3": "AAA"
            },
            make_aligned_seqs(
                data={
                    "seq1": "TTT",
                    "seq2": "TTT",
                    "seq3": "TTT",
                    "seq4": "TTT"
                },
                moltype=DNA,
            ),
        ]
        ccat = sample.concat()
        # triggered by first record
        with self.assertRaises(TypeError):
            ccat(data)

        # triggered by second record
        with self.assertRaises(TypeError):
            ccat(data[::-1])

        # triggered by no data
        with self.assertRaises(ValueError):
            ccat([])
コード例 #2
0
ファイル: test_sample.py プロジェクト: cogent3/cogent3
 def test_concat_handles_moltype(self):
     """coerces to type"""
     alns = [
         make_aligned_seqs(data=d, moltype=DNA) for d in [
             {
                 "seq1": "AAA",
                 "seq2": "AAA",
                 "seq3": "AAA"
             },
             {
                 "seq1": "TTT",
                 "seq2": "TTT",
                 "seq3": "TTT",
                 "seq4": "TTT"
             },
             {
                 "seq1": "CC",
                 "seq2": "CC",
                 "seq3": "CC"
             },
         ]
     ]
     ccat = sample.concat()
     got = ccat(alns)
     self.assertIsInstance(got.moltype, type(DNA))
コード例 #3
0
ファイル: test_sample.py プロジェクト: rahulghangas/cogent3
    def test_concat(self):
        """returns concatenated alignment"""
        alns = [
            make_aligned_seqs(data=d, moltype=DNA) for d in [
                {
                    "seq1": "AAA",
                    "seq2": "AAA",
                    "seq3": "AAA"
                },
                {
                    "seq1": "TTT",
                    "seq2": "TTT",
                    "seq3": "TTT",
                    "seq4": "TTT"
                },
                {
                    "seq1": "CC",
                    "seq2": "CC",
                    "seq3": "CC"
                },
            ]
        ]
        ccat = sample.concat(intersect=True)
        got = ccat(alns)
        self.assertEqual(got.to_dict(), {
            "seq1": "AAATTTCC",
            "seq2": "AAATTTCC",
            "seq3": "AAATTTCC"
        })

        ccat = sample.concat(intersect=False)
        got = ccat(alns)
        self.assertEqual(
            got.to_dict(),
            {
                "seq1": "AAATTTCC",
                "seq2": "AAATTTCC",
                "seq3": "AAATTTCC",
                "seq4": "???TTT??",
            },
        )