本文整理汇总了Python中bcftbx.TabFile.append方法的典型用法代码示例。如果您正苦于以下问题:Python TabFile.append方法的具体用法?Python TabFile.append怎么用?Python TabFile.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bcftbx.TabFile
的用法示例。
在下文中一共展示了TabFile.append方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_append_line
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_append_line(self):
"""Append a line to a file
"""
tabfile = TabFile('test',self.fp,first_line_is_header=True,delimiter=',')
line = 'chr3,10,9,8'
tabfile.append(tabdata=line)
self.assertEqual(str(tabfile[-1]),line)
示例2: test_append_line_as_data
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_append_line_as_data(self):
"""Append a line to a file with data supplied as a list
"""
tabfile = TabFile('test',self.fp,first_line_is_header=True,delimiter=',')
data = ['chr3','10','9','8']
tabfile.append(data=data)
self.assertEqual(str(tabfile[-1]),','.join([str(x) for x in data]))
示例3: test_add_tab_data_to_new_tabfile
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_add_tab_data_to_new_tabfile(self):
"""Test adding data as a tab-delimited line to a new empty TabFile
"""
data = 'chr1\t10000\t20000\t+'
tabfile = TabFile()
tabfile.append(tabdata=data)
self.assertEqual(len(tabfile),1,"TabFile should now have one line")
self.assertEqual(str(tabfile[0]),data)
示例4: test_add_data_to_new_tabfile
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_add_data_to_new_tabfile(self):
"""Test adding data as a list of items to a new empty TabFile
"""
data = ['chr1',10000,20000,'+']
tabfile = TabFile()
tabfile.append(data=data)
self.assertEqual(len(tabfile),1,"TabFile should now have one line")
for i in range(len(data)):
self.assertEqual(tabfile[0][i],data[i])
示例5: test_convert_values_to_str_append_tabdata
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_convert_values_to_str_append_tabdata(self):
"""Convert all input values to strings when appending tabdata
"""
tabfile = TabFile('test',self.fp,first_line_is_header=True,
convert=False)
tabfile.append(tabdata="chr3\t5678\t7.9")
for line in tabfile:
for value in line:
self.assertTrue(isinstance(value,str))
示例6: test_convert_values_to_type_append_tabdata
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_convert_values_to_type_append_tabdata(self):
"""Convert input values to appropriate types (e.g. integer) when appending tabdata
"""
tabfile = TabFile('test',self.fp,first_line_is_header=True)
tabfile.append(tabdata="chr3\t5678\t7.9")
for line in tabfile:
self.assertTrue(isinstance(line[0],str))
self.assertTrue(isinstance(line[1],(int,long)))
self.assertTrue(isinstance(line[2],float))
示例7: test_convert_values_to_str_append_list
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_convert_values_to_str_append_list(self):
"""Convert all input values to strings when appending a list
"""
tabfile = TabFile('test',self.fp,first_line_is_header=True,
convert=False)
tabfile.append(data=["chr3","5678","7.9"])
tabfile.append(data=["chr3",5678,7.9])
for line in tabfile:
for value in line:
self.assertTrue(isinstance(value,str))
示例8: test_convert_values_to_type_append_list
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_convert_values_to_type_append_list(self):
"""Convert input values to appropriate types (e.g. integer) when appending a list
"""
tabfile = TabFile('test',self.fp,first_line_is_header=True)
tabfile.append(data=["chr3","5678","7.9"])
tabfile.append(data=["chr3",5678,7.9])
for line in tabfile:
self.assertTrue(isinstance(line[0],str))
self.assertTrue(isinstance(line[1],(int,long)))
self.assertTrue(isinstance(line[2],float))
示例9: test_append_empty_line
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_append_empty_line(self):
"""Append a blank line to a TabFile
"""
tabfile = TabFile('test',self.fp)
self.assertEqual(len(tabfile),3)
line = tabfile.append()
self.assertEqual(len(tabfile),4)
# Check new line is empty
for i in range(len(line)):
self.assertTrue(str(line[i]) == '')
示例10: test_append_tab_data_line
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_append_tab_data_line(self):
"""Append a TabDataLine to a TabFile
"""
tabfile = TabFile('test',self.fp)
self.assertEqual(len(tabfile),3)
tabdataline = TabDataLine('chr1\t10000\t20000\t+')
line = tabfile.append(tabdataline=tabdataline)
self.assertEqual(len(tabfile),4)
# Check new line is correct
self.assertTrue(line is tabdataline)
示例11: test_append_line_with_tab_data
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_append_line_with_tab_data(self):
"""Append line to a TabFile populated from tabbed data
"""
data = 'chr1\t10000\t20000\t+'
tabfile = TabFile('test',self.fp)
self.assertEqual(len(tabfile),3)
line = tabfile.append(tabdata=data)
self.assertEqual(len(tabfile),4)
# Check new line is correct
self.assertTrue(str(line) == data)
示例12: test_append_line_with_data
# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import append [as 别名]
def test_append_line_with_data(self):
"""Append line to a TabFile populated with data
"""
data = ['chr1',678,901,6.1]
tabfile = TabFile('test',self.fp)
self.assertEqual(len(tabfile),3)
line = tabfile.append(data=data)
self.assertEqual(len(tabfile),4)
# Check new line is correct
for i in range(len(data)):
self.assertTrue(line[i] == data[i])