本文整理汇总了Python中skbio.io.format.stockholm._tabular_msa_to_stockholm函数的典型用法代码示例。如果您正苦于以下问题:Python _tabular_msa_to_stockholm函数的具体用法?Python _tabular_msa_to_stockholm怎么用?Python _tabular_msa_to_stockholm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_tabular_msa_to_stockholm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_msa_to_stockholm_multiple_references
def test_msa_to_stockholm_multiple_references(self):
fp = get_data_path('stockholm_multiple_references')
msa = TabularMSA(
[],
metadata={'RN': [OrderedDict([('RM', '123456789'),
('RT', 'Title 1'),
('RA', 'Author 1'),
('RL', 'Location 1'),
('RC', 'Comment 1')]),
OrderedDict([('RM', '987654321'),
('RT', 'Title 2'),
('RA', 'Author 2'),
('RL', 'Location 2'),
('RC', 'Comment 2')]),
OrderedDict([('RM', '132465879'),
('RT', 'Title 3'),
('RA', 'Author 3'),
('RL', 'Location 3'),
('RC', 'Comment 3')])]})
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
obs = fh.getvalue()
fh.close()
with io.open(fp) as fh:
exp = fh.read()
self.assertEqual(obs, exp)
示例2: test_rn_not_list_of_refs_error
def test_rn_not_list_of_refs_error(self):
msa = TabularMSA([], metadata={'RN': '1'})
with self.assertRaisesRegex(StockholmFormatError,
r"Expected 'RN'.*list of reference"
".*got '1'"):
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
示例3: test_msa_to_stockholm_extensive
def test_msa_to_stockholm_extensive(self):
fp = get_data_path('stockholm_all_data_types')
msa = TabularMSA([DNA('GAGGCCATGCCCAGGTGAAG',
metadata=OrderedDict([('DT', 'February 1, 2016'),
('NM', 'Unknown')])),
DNA('ACCTGAGCCACAGTAGAAGT'),
DNA('CCCTTCGCTGGAAATGTATG',
metadata={'DT': 'Unknown'},
positional_metadata=OrderedDict([('AS',
list('CCGAAAGT'
'CGTTCGA'
'AAATG')),
('SS',
list('GGCGAGTC'
'GTTCGAGC'
'TGG'
'C'))]))],
metadata=OrderedDict([('NM', 'Kestrel Gorlick'),
('DT', 'February 11, 2016'),
('FN', 'Writer test file')]),
positional_metadata=OrderedDict([('AS_cons',
list('CGTTCGTTCTAAC'
'AATTCCA')),
('SS_cons',
list('GGCGCTACGACCT'
'ACGACCG'))]),
index=['seq1', 'seq2', 'seq3'])
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
obs = fh.getvalue()
fh.close()
with io.open(fp) as fh:
exp = fh.read()
self.assertEqual(obs, exp)
示例4: test_unoriginal_index_error
def test_unoriginal_index_error(self):
msa = TabularMSA([DNA('ATCGCCAGCT'), DNA('TTGTGCTGGC')],
index=['seq1', 'seq1'])
with self.assertRaisesRegex(StockholmFormatError,
'index labels must be unique.'):
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
示例5: test_invalid_reference_tag_error
def test_invalid_reference_tag_error(self):
msa = TabularMSA([], metadata={'RN': [OrderedDict([('RL', 'Flagstaff'),
('foo', 'bar')])]})
with self.assertRaisesRegex(StockholmFormatError,
r"Invalid reference.*foo' found "
"in.*1.*Valid reference tags are:"):
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
示例6: test_round_trip_nonstring_index_values
def test_round_trip_nonstring_index_values(self):
fp = get_data_path('stockholm_nonstring_labels')
msa = _stockholm_to_tabular_msa(fp, constructor=DNA)
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
obs = fh.getvalue()
fh.close()
with io.open(fp) as fh:
exp = fh.read()
self.assertEqual(obs, exp)
示例7: test_round_trip_empty
def test_round_trip_empty(self):
fp = get_data_path('stockholm_no_data')
msa = _stockholm_to_tabular_msa(fp, constructor=Protein)
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
obs = fh.getvalue()
fh.close()
with io.open(fp) as fh:
exp = fh.read()
self.assertEqual(obs, exp)
示例8: test_msa_to_stockholm_single_tree
def test_msa_to_stockholm_single_tree(self):
fp = get_data_path('stockholm_single_tree_without_id')
msa = TabularMSA([], metadata=OrderedDict([('NH', 'ABCD')]))
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
obs = fh.getvalue()
fh.close()
with io.open(fp) as fh:
exp = fh.read()
self.assertEqual(obs, exp)
示例9: test_msa_to_stockholm_minimal
def test_msa_to_stockholm_minimal(self):
fp = get_data_path('stockholm_minimal')
msa = TabularMSA([DNA('TGTGTCGCAGTTGTCGTTTG')], index=['0235244'])
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
obs = fh.getvalue()
fh.close()
with io.open(fp) as fh:
exp = fh.read()
self.assertEqual(obs, exp)
示例10: test_rn_data_not_in_dict_error
def test_rn_data_not_in_dict_error(self):
msa = TabularMSA([], metadata={'RN': [OrderedDict([('RL',
'Flagstaff')]),
'Incorrect Item']})
with self.assertRaisesRegex(StockholmFormatError,
r"Expected reference information.*stored"
" as a dictionary, found.*2 stored as "
"'str'"):
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
示例11: test_msa_to_stockholm_empty
def test_msa_to_stockholm_empty(self):
fp = get_data_path('stockholm_no_data')
msa = TabularMSA([])
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
obs = fh.getvalue()
fh.close()
with io.open(fp) as fh:
exp = fh.read()
self.assertEqual(obs, exp)
示例12: test_msa_to_stockholm_single_tree_as_dict
def test_msa_to_stockholm_single_tree_as_dict(self):
fp = get_data_path('stockholm_single_tree_with_id')
msa = TabularMSA([], metadata={'NH': {'tree1': 'ABCD'}})
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
obs = fh.getvalue()
fh.close()
with io.open(fp) as fh:
exp = fh.read()
self.assertEqual(obs, exp)
示例13: test_msa_to_stockholm_data_only
def test_msa_to_stockholm_data_only(self):
fp = get_data_path('stockholm_data_only')
msa = TabularMSA([RNA('ACUCCGACAUGCUCC'),
RNA('UAGUGCCGAACGCUG'),
RNA('GUGUGGGCGUGAUUC')],
index=['seq1', 'seq2', 'seq3'])
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
obs = fh.getvalue()
fh.close()
with io.open(fp) as fh:
exp = fh.read()
self.assertEqual(obs, exp)
示例14: test_gc_wrong_dataframe_item_length_error
def test_gc_wrong_dataframe_item_length_error(self):
seq1 = list('GAGCAAGCCACTAGA')
seq1.append('GG')
pos_metadata_dataframe = pd.DataFrame({'AC': seq1,
'SS': list('TCCTTGAACTACCCGA'),
'AS': list('TCAGCTCTGCAGCGTT')})
msa = TabularMSA([DNA('TCCTTGAACTACCCGA')],
positional_metadata=pos_metadata_dataframe)
with self.assertRaisesRegex(StockholmFormatError,
'Multiple sequence alignment positional '
'metadata.*must contain a single character'
'.*Found value\(s\) in column AC'):
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
示例15: test_msa_to_stockholm_single_reference
def test_msa_to_stockholm_single_reference(self):
fp = get_data_path('stockholm_single_reference')
msa = TabularMSA(
[],
metadata={'RN': [OrderedDict([('RM', '123456789'),
('RT', 'A Title'),
('RA', 'The Author'),
('RL', 'A Location'),
('RC', 'Comment')])]})
fh = io.StringIO()
_tabular_msa_to_stockholm(msa, fh)
obs = fh.getvalue()
fh.close()
with io.open(fp) as fh:
exp = fh.read()
self.assertEqual(obs, exp)