當前位置: 首頁>>代碼示例>>Python>>正文


Python AlignmentList.iter_alignments方法代碼示例

本文整理匯總了Python中process.sequence.AlignmentList.iter_alignments方法的典型用法代碼示例。如果您正苦於以下問題:Python AlignmentList.iter_alignments方法的具體用法?Python AlignmentList.iter_alignments怎麽用?Python AlignmentList.iter_alignments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在process.sequence.AlignmentList的用法示例。


在下文中一共展示了AlignmentList.iter_alignments方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: LoadAlignmentsTest

# 需要導入模塊: from process.sequence import AlignmentList [as 別名]
# 或者: from process.sequence.AlignmentList import iter_alignments [as 別名]

#.........這裏部分代碼省略.........
    def test_load_single_loci(self):

        single_aln = Alignment(dna_data_loci[0], sql_cursor=self.aln_obj.cur,
                               db_idx=self.aln_obj._idx + 1)

    def test_load_nexus_par(self):

        self.aln_obj = AlignmentList(concatenated_medium_nexus, sql_db=sql_db)
        self.assertTrue(self.aln_obj.partitions.partitions)

    def test_load_wrong_type(self):

        self.aln_obj = AlignmentList(bad_file, sql_db=sql_db)
        self.assertTrue(self.aln_obj.bad_alignments)

    def test_duplicate_files(self):

        self.aln_obj = AlignmentList(dna_data_loci + dna_data_loci,
                                     sql_db=sql_db)
        self.assertTrue(self.aln_obj.duplicate_alignments)

    def test_unequal_length(self):

        self.aln_obj = AlignmentList(unequal_file, sql_db=sql_db)
        self.assertTrue(self.aln_obj.non_alignments)

    def test_bad_file_removal_from_db(self):

        self.aln_obj = AlignmentList(unequal_file, sql_db=sql_db)
        self.aln_obj.add_alignment_files(dna_data_fas)

        s = 0

        for tx, _, _ in self.aln_obj.iter_alignments():
            if tx == "Seq1":
                s += 1

        self.assertEqual(s, 0)

    def test_load_no_data(self):

        self.aln_obj = AlignmentList(no_data, sql_db=sql_db)

    def test_alternative_missing(self):

        self.aln_obj = AlignmentList(alternative_missing, sql_db=sql_db)

        aln = self.aln_obj.alignments.values()[0]

        self.assertEqual(aln.sequence_code[1], "?")

    def test_dna_missing_default(self):

        self.aln_obj = AlignmentList(single_dna, sql_db=sql_db)

        aln = self.aln_obj.alignments.values()[0]

        self.assertEqual(aln.sequence_code[1], "n")

    def test_protein_missing_default(self):

        self.aln_obj = AlignmentList(protein_no_missing, sql_db=sql_db)

        aln = self.aln_obj.alignments.values()[0]

        self.assertEqual(aln.sequence_code[1], "x")
開發者ID:ODiogoSilva,項目名稱:TriFusion,代碼行數:70,代碼來源:test_load_process_data.py

示例2: AlignmentCodonFilters

# 需要導入模塊: from process.sequence import AlignmentList [as 別名]
# 或者: from process.sequence.AlignmentList import iter_alignments [as 別名]
class AlignmentCodonFilters(unittest.TestCase):

    def setUp(self):

        if not os.path.exists(temp_dir):
            os.makedirs(temp_dir)

        self.aln_obj = AlignmentList([],sql_db=sql_db)

    def tearDown(self):

        self.aln_obj.clear_alignments()
        self.aln_obj.con.close()
        shutil.rmtree(temp_dir)

    def test_codon_filter_pos1(self):

        self.aln_obj.add_alignment_files(codon_filter)

        self.aln_obj.filter_codon_positions([True, False, False],
                                            table_out="master_out")

        s = []
        for _, seq, _ in self.aln_obj.iter_alignments("master_out"):
            s.append(seq)

        self.assertEqual(s, ["a" * 16] * 10)

    def test_codon_filter_pos2(self):

        self.aln_obj.add_alignment_files(codon_filter)

        self.aln_obj.filter_codon_positions([False, True, False],
                                            table_out="master_out")

        s = []
        for _, seq, _ in self.aln_obj.iter_alignments("master_out"):
            s.append(seq)

        self.assertEqual(s, ["t" * 16] * 10)

    def test_codon_filter_pos3(self):

        self.aln_obj.add_alignment_files(codon_filter)

        self.aln_obj.filter_codon_positions([False, False, True],
                                            table_out="master_out")

        s = []
        for _, seq, _ in self.aln_obj.iter_alignments("master_out"):
            s.append(seq)

        self.assertEqual(s, ["g" * 16] * 10)

    def test_codon_filter_pos12(self):

        self.aln_obj.add_alignment_files(codon_filter)

        self.aln_obj.filter_codon_positions([True, True, False],
                                            table_out="master_out")

        s = []
        for _, seq, _ in self.aln_obj.iter_alignments("master_out"):
            s.append(seq)

        self.assertEqual(s, ["at" * 16] * 10)

    def test_codon_filter_pos13(self):

        self.aln_obj.add_alignment_files(codon_filter)

        self.aln_obj.filter_codon_positions([True, False, True],
                                            table_out="master_out")

        s = []
        for _, seq, _ in self.aln_obj.iter_alignments("master_out"):
            s.append(seq)

        self.assertEqual(s, ["ag" * 16] * 10)

    def test_codon_filter_all(self):

        self.aln_obj.add_alignment_files(codon_filter)

        self.aln_obj.filter_codon_positions([True, True, True])

        s = []
        for _, seq, _ in self.aln_obj.iter_alignments():
            s.append(seq)

        self.assertEqual(s, ["atg" * 16] * 10)
開發者ID:ODiogoSilva,項目名稱:TriFusion,代碼行數:93,代碼來源:test_process_filters.py


注:本文中的process.sequence.AlignmentList.iter_alignments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。