本文整理匯總了Python中process.sequence.AlignmentList.write_to_file方法的典型用法代碼示例。如果您正苦於以下問題:Python AlignmentList.write_to_file方法的具體用法?Python AlignmentList.write_to_file怎麽用?Python AlignmentList.write_to_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類process.sequence.AlignmentList
的用法示例。
在下文中一共展示了AlignmentList.write_to_file方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: AlignmentManipulationTest
# 需要導入模塊: from process.sequence import AlignmentList [as 別名]
# 或者: from process.sequence.AlignmentList import write_to_file [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)