当前位置: 首页>>代码示例>>Python>>正文


Python AlignmentList.update_active_alignments方法代码示例

本文整理汇总了Python中process.sequence.AlignmentList.update_active_alignments方法的典型用法代码示例。如果您正苦于以下问题:Python AlignmentList.update_active_alignments方法的具体用法?Python AlignmentList.update_active_alignments怎么用?Python AlignmentList.update_active_alignments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在process.sequence.AlignmentList的用法示例。


在下文中一共展示了AlignmentList.update_active_alignments方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PartitonsTest

# 需要导入模块: from process.sequence import AlignmentList [as 别名]
# 或者: from process.sequence.AlignmentList import update_active_alignments [as 别名]

#.........这里部分代码省略.........
        key_data = [self.aln_obj.partitions.partitions_alignments["one"],
                    self.aln_obj.partitions.partitions_alignments["two"]]

        self.assertEqual(key_data,
                         [['BaseConc1.fas'],
                          ['BaseConc1.fas', 'BaseConc3.fas', 'BaseConc2.fas']])

    def test_merge_and_custom_split2(self):

        self.aln_obj.partitions.read_from_file(concatenated_small_parNex[0],
                                               no_aln_check=True)

        self.aln_obj.partitions.merge_partitions(
            ["BaseConc1.fas", "BaseConc2.fas", "BaseConc3.fas"], "new_part")

        self.aln_obj.partitions.split_partition("new_part",
                                                [(0, 84), (85, 254)],
                                                ["one", "two"])

        key_data = [self.aln_obj.partitions.partitions_alignments["one"],
                    self.aln_obj.partitions.partitions_alignments["two"]]

        self.assertEqual(key_data,
                         [['BaseConc1.fas'],
                          ['BaseConc3.fas', 'BaseConc2.fas']])

    def test_concat_custom_fileset_from_phy_partfile(self):

        self.aln_obj.clear_alignments()
        self.aln_obj.con.close()
        self.aln_obj = AlignmentList(dna_data_fas, sql_db=sql_db)
        self.aln_obj.partitions.read_from_file(concatenated_small_par[0])

        self.aln_obj.update_active_alignments(
            [join(data_path, "BaseConc1.fas"),
             join(data_path, "BaseConc2.fas")])

        self.aln_obj.concatenate()

        key_data = [
            sorted(self.aln_obj.partitions.partitions.keys()),
            sorted(self.aln_obj.partitions.partitions_alignments.keys()),
            sorted(self.aln_obj.partitions.models.keys())]

        self.expect_equal(key_data, [["BaseConc1.fas", "BaseConc2.fas"]] * 3)

    def test_concat_custom_fileset_from_phy_partfile(self):

        self.aln_obj.clear_alignments()
        self.aln_obj.con.close()
        self.aln_obj = AlignmentList(dna_data_fas, sql_db=sql_db)
        self.aln_obj.partitions.read_from_file(concatenated_small_parNex[0])

        self.aln_obj.update_active_alignments(
            [join(data_path, "BaseConc1.fas"),
             join(data_path, "BaseConc2.fas")])

        self.aln_obj.concatenate()

        key_data = [
            sorted(self.aln_obj.partitions.partitions.keys()),
            sorted(self.aln_obj.partitions.partitions_alignments.keys()),
            sorted(self.aln_obj.partitions.models.keys())]

        self.expect_equal(key_data, [["BaseConc1.fas", "BaseConc2.fas"]] * 3)
开发者ID:ODiogoSilva,项目名称:TriFusion,代码行数:69,代码来源:test_partitions.py

示例2: SeconaryOpsTest

# 需要导入模块: from process.sequence import AlignmentList [as 别名]
# 或者: from process.sequence.AlignmentList import update_active_alignments [as 别名]
class SeconaryOpsTest(unittest.TestCase):

    def setUp(self):

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

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

    def tearDown(self):

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

    def test_summary_stats_all(self):

        sum_table, table_data = self.aln_obj.get_summary_stats()

        self.assertEqual([sum_table, table_data],
                         [{'missing': '5 (0.04%)', 'taxa': 24, 'genes': 7,
                           'informative': '0 (0.0%)', 'gaps': '0 (0.0%)',
                           'avg_gaps': 0.0, 'avg_missing': 1.0, 'variable': '7 (1.18%)',
                           'seq_len': 595, 'avg_var': 1.0, 'avg_inf': 0.0},
                          [['Genes', 'Taxa', 'Alignment length', 'Gaps',
                            'Gaps per gene', 'Missing data',
                            'Missing data per gene', 'Variable sites',
                            'Variable sites per gene', 'Informative sites',
                            'Informative sites per gene'],
                           [7, 24, 595, '0 (0.0%)', 0.0, '5 (0.04%)', 1.0,
                            '7 (1.18%)', 1.0, '0 (0.0%)', 0.0]]])

    def test_summary_stats_one_active(self):

        sum_table, table_data = self.aln_obj.get_summary_stats([
            join(data_path, "BaseConc1.fas")])

        self.assertEqual([sum_table, table_data],
                         [{'missing': '1 (0.05%)', 'taxa': 24, 'genes': 1,
                           'informative': '0 (0.0%)', 'gaps': '0 (0.0%)',
                           'avg_gaps': 0.0, 'avg_missing': 1.0, 'variable': '1 (1.18%)',
                           'seq_len': 85, 'avg_var': 1.0, 'avg_inf': 0.0},
                          [['Genes', 'Taxa', 'Alignment length', 'Gaps',
                            'Gaps per gene', 'Missing data',
                            'Missing data per gene', 'Variable sites',
                            'Variable sites per gene', 'Informative sites',
                            'Informative sites per gene'],
                           [1, 24, 85, '0 (0.0%)', 0.0, '1 (0.05%)', 1.0,
                            '1 (1.18%)', 1.0, '0 (0.0%)', 0.0]]])

    def test_single_aln_outlier_mdata(self):

        self.aln_obj.update_active_alignments([dna_data_fas[0]])

        self.assertEqual(self.aln_obj.outlier_missing_data(),
                         {"exception": "single_alignment"})

    def test_single_aln_outlier_mdata_sp(self):

        self.aln_obj.update_active_alignments([dna_data_fas[0]])

        print(self.aln_obj.alignments)

        self.assertEqual(self.aln_obj.outlier_missing_data_sp(),
                         {"exception": "single_alignment"})

    def test_single_aln_outlier_seg(self):

        self.aln_obj.update_active_alignments([dna_data_fas[0]])

        self.assertEqual(self.aln_obj.outlier_segregating(),
                         {"exception": "single_alignment"})

    def test_single_aln_outlier_seg_sp(self):

        self.aln_obj.update_active_alignments([dna_data_fas[0]])

        print(self.aln_obj.alignments)

        self.assertEqual(self.aln_obj.outlier_segregating_sp(),
                         {"exception": "single_alignment"})

    def test_single_aln_outlier_seqsize(self):

        self.aln_obj.update_active_alignments([dna_data_fas[0]])

        self.assertEqual(self.aln_obj.outlier_sequence_size(),
                         {"exception": "single_alignment"})

    def test_single_aln_outlier_seqsize_sp(self):

        self.aln_obj.update_active_alignments([dna_data_fas[0]])

        self.assertEqual(self.aln_obj.outlier_sequence_size_sp(),
                         {"exception": "single_alignment"})

    def test_single_aln_average_seqsize_per_species(self):

        self.aln_obj.update_active_alignments([dna_data_fas[0]])

#.........这里部分代码省略.........
开发者ID:ODiogoSilva,项目名称:TriFusion,代码行数:103,代码来源:test_stats.py

示例3: AlignmentManipulationTest

# 需要导入模块: from process.sequence import AlignmentList [as 别名]
# 或者: from process.sequence.AlignmentList import update_active_alignments [as 别名]
class AlignmentManipulationTest(unittest.TestCase):

    def setUp(self):

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

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

    def tearDown(self):

        try:
            self.aln_obj.clear_alignments()
        except:
            pass
        self.aln_obj.con.close()
        shutil.rmtree(temp_dir)

    def test_clear_alns(self):

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

        self.assertTrue(compare_inst(self.aln_obj, aln, ["log_progression",
                                                         "locus_length",
                                                         "partitions",
                                                         "cur",
                                                         "con"]))

    def test_update_act_anls(self):

        self.aln_obj.update_active_alignments([join(data_path,
                                                    "BaseConc1.fas"),
                                               join(data_path,
                                                    "BaseConc2.fas")])

        self.assertEqual(list(self.aln_obj.alignments.keys()),
                         [join(data_path, "BaseConc1.fas"),
                          join(data_path, "BaseConc2.fas")])

    def test_update_act_alns_err(self):

        self.aln_obj.update_active_alignments([join(data_path,
                                                    "BaseConc1.fas"),
                                               join(data_path,
                                                    "BaseConc2.fas"),
                                               join(data_path,
                                                    "Wrong_name")])

        self.assertEqual(list(self.aln_obj.alignments.keys()),
                         [join(data_path, "BaseConc1.fas"),
                          join(data_path, "BaseConc2.fas")])

    def test_update_aln_shelve(self):

        self.aln_obj.update_active_alignment(join(data_path, "BaseConc1.fas"),
                                             "shelve")

        self.assertEqual(list(self.aln_obj.alignments.keys()),
                         [join(data_path, "BaseConc2.fas"),
                          join(data_path, "BaseConc3.fas"),
                          join(data_path, "BaseConc4.fas"),
                          join(data_path, "BaseConc5.fas"),
                          join(data_path, "BaseConc6.fas"),
                          join(data_path, "BaseConc7.fas")])

    def test_update_aln_act(self):

        self.aln_obj.update_active_alignments([])
        self.aln_obj.update_active_alignment(join(data_path, "BaseConc1.fas"),
                                             "active")

        self.assertEqual(list(self.aln_obj.alignments.keys()),
                         [join(data_path, "BaseConc1.fas")])

    def test_add_aln_obj(self):

        fl = self.aln_obj.alignments.keys()

        aln = Alignment(dna_data_loci[0], sql_cursor=self.aln_obj.cur,
                        sql_con=self.aln_obj.con,
                        db_idx=self.aln_obj._idx + 1, temp_dir=temp_dir)

        self.aln_obj.add_alignments([aln])

        self.assertEqual(self.aln_obj.alignments.keys(),
                         fl + [join(data_path, "c97d5m4p2.loci")])

    def test_remove_taxa_from_list(self):

        taxa_list = [
            "1285_RAD_original",
            "130a_RAD_original",
            "137a_RAD_original",
            "1427_RAD_original",
            "167a_RAD_original"
        ]

        expected_taxa = [tx for tx in self.aln_obj.taxa_names if
                         tx not in taxa_list]
#.........这里部分代码省略.........
开发者ID:ODiogoSilva,项目名称:TriFusion,代码行数:103,代码来源:test_load_process_data.py


注:本文中的process.sequence.AlignmentList.update_active_alignments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。