本文整理汇总了Python中process.sequence.AlignmentList.concatenate方法的典型用法代码示例。如果您正苦于以下问题:Python AlignmentList.concatenate方法的具体用法?Python AlignmentList.concatenate怎么用?Python AlignmentList.concatenate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类process.sequence.AlignmentList
的用法示例。
在下文中一共展示了AlignmentList.concatenate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AlignmentManipulationTest
# 需要导入模块: from process.sequence import AlignmentList [as 别名]
# 或者: from process.sequence.AlignmentList import concatenate [as 别名]
#.........这里部分代码省略.........
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]
self.aln_obj.remove_taxa(taxa_list)
self.assertEqual(self.aln_obj.taxa_names, expected_taxa)
def test_remove_taxa_from_file(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]
self.aln_obj.remove_taxa(taxa_to_remove)
self.assertEqual(self.aln_obj.taxa_names, expected_taxa)
def test_remove_taxa_from_list_inverse(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]
self.aln_obj.remove_taxa(taxa_list, mode="inverse")
self.assertEqual(self.aln_obj.taxa_names, taxa_list)
#
# def test_retrieve_alignment(self):
#
# aln = self.aln_obj.retrieve_alignment("BaseConc1.fas")
#
# aln2 = Alignment(dna_data_fas[0], dest="new_one")
#
# self.assertTrue(compare_inst(aln, aln2,
# ["log_progression", "locus_length",
# "_partitions"]))
def test_concatenation(self):
self.aln_obj.concatenate()
self.aln_obj.write_to_file(["fasta"], output_file="test")
with open("trifusion/tests/data/BaseConcatenation.fas") as fh1, \
open("test.fas") as fh2:
self.assertEqual(sorted(fh1.readlines()), sorted(fh2.readlines()))
os.remove("test.fas")
def test_concatention_after_removal(self):
fl = [x for x in self.aln_obj.alignments][3:]
self.aln_obj.remove_file(fl)
self.aln_obj.concatenate()
self.assertEqual(len(self.aln_obj.alignments), 1)
示例2: PartitonsTest
# 需要导入模块: from process.sequence import AlignmentList [as 别名]
# 或者: from process.sequence.AlignmentList import concatenate [as 别名]
class PartitonsTest(ExpectingTestCase):
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)
self.aln_obj.partitions.reset(cur=self.aln_obj.cur,)
def tearDown(self):
self.aln_obj.clear_alignments()
self.aln_obj.con.close()
shutil.rmtree(temp_dir)
def test_read_from_nexus(self):
self.aln_obj.partitions.read_from_file(concatenated_small_parNex[0],
no_aln_check=True)
self.assertEqual(len(self.aln_obj.partitions.partitions), 7)
def test_read_from_phylip(self):
self.aln_obj.partitions.read_from_file(concatenated_small_par[0],
no_aln_check=True)
self.assertEqual(len(self.aln_obj.partitions.partitions), 7)
def test_bad_partitions_phy(self):
e = self.aln_obj.partitions.read_from_file(partition_bad_phy[0],
no_aln_check=True)
self.assertTrue(isinstance(e, InvalidPartitionFile))
def test_unsorted_part_phylip(self):
self.aln_obj.partitions.read_from_file(partition_unsorted_phy[0],
no_aln_check=True)
data = [self.aln_obj.partitions.partitions.keys(),
self.aln_obj.partitions.counter]
self.assertEqual(data, [["BaseConc1.fas", "BaseConc2.fas",
"BaseConc3.fas", "BaseConc4.fas",
"BaseConc5.fas", "BaseConc6.fas",
"BaseConc7.fas"],
595])
def test_phylip_dot_notation(self):
self.aln_obj.partitions.read_from_file(partition_dot_not[0],
no_aln_check=True)
data = [self.aln_obj.partitions.partitions.keys(),
self.aln_obj.partitions.counter]
self.assertEqual(data, [["BaseConc1.fas", "BaseConc2.fas",
"BaseConc3.fas", "BaseConc4.fas",
"BaseConc5.fas", "BaseConc6.fas",
"BaseConc7.fas"],
595])
def test_nexus_dot_notation(self):
self.aln_obj.partitions.read_from_file(dot_notation_nex[0],
no_aln_check=True)
data = [self.aln_obj.partitions.partitions.keys(),
self.aln_obj.partitions.counter]
self.assertEqual(data, [["BaseConc1.fas", "BaseConc2.fas",
"BaseConc3.fas", "BaseConc4.fas",
"BaseConc5.fas", "BaseConc6.fas",
"BaseConc7.fas"],
595])
def test_import_new_partscheme(self):
self.aln_obj.clear_alignments()
self.aln_obj.con.close()
self.aln_obj = AlignmentList(concatenated_medium_nexus,
sql_db=sql_db)
self.aln_obj.partitions.reset()
self.aln_obj.partitions.read_from_file(concatenated_small_par[0],
no_aln_check=True)
res = self.aln_obj.partitions.get_partition_names()
self.assertEqual(res, ["BaseConc1.fas", "BaseConc2.fas",
"BaseConc3.fas", "BaseConc4.fas",
"BaseConc5.fas", "BaseConc6.fas",
"BaseConc7.fas"])
def test_add_duplicate_name(self):
#.........这里部分代码省略.........
示例3: AlignmentMissingFiltersTest
# 需要导入模块: from process.sequence import AlignmentList [as 别名]
# 或者: from process.sequence.AlignmentList import concatenate [as 别名]
class AlignmentMissingFiltersTest(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_filter_default(self):
self.aln_obj.add_alignment_files(
["trifusion/tests/data/missing_data.phy",
"trifusion/tests/data/missing_data2.phy"]
)
self.aln_obj.filter_missing_data(25, 50)
s = []
for aln in self.aln_obj:
s.append(aln.locus_length)
self.assertEqual(s, [42, 43])
def test_filter_and_concat(self):
self.aln_obj.add_alignment_files(
["trifusion/tests/data/missing_data.phy",
"trifusion/tests/data/missing_data2.phy"]
)
self.aln_obj.filter_missing_data(25, 50, table_out="master_out")
self.aln_obj.concatenate(table_in="master_out")
self.assertEqual(self.aln_obj.size, 85)
def test_no_filters(self):
self.aln_obj.add_alignment_files(
["trifusion/tests/data/missing_data.phy",
"trifusion/tests/data/missing_data2.phy"]
)
self.aln_obj.filter_missing_data(100, 100)
s = []
for aln in self.aln_obj:
s.append(aln.locus_length)
self.assertEqual(s, [50, 50])
def test_no_missing(self):
self.aln_obj.add_alignment_files(
["trifusion/tests/data/missing_data.phy",
"trifusion/tests/data/missing_data2.phy"]
)
self.aln_obj.filter_missing_data(0, 0)
s = []
for aln in self.aln_obj:
s.append(aln.locus_length)
self.assertEqual(s, [0, 19])
def test_no_data_aln_default_filters(self):
self.aln_obj.add_alignment_files(
["trifusion/tests/data/missing_data3.phy"]
)
self.aln_obj.filter_missing_data(25, 50)
s = None
for aln in self.aln_obj:
s = aln.locus_length
self.assertEqual(s, 0)
def test_no_data_aln_no_filters(self):
self.aln_obj.add_alignment_files(
["trifusion/tests/data/missing_data3.phy"]
)
self.aln_obj.filter_missing_data(100, 100)
s = None
for aln in self.aln_obj:
s = aln.locus_length
self.assertEqual(s, 50)