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


Python TabFile.header方法代码示例

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


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

示例1: test_append_column

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_append_column(self):
     """Append new column to a Tabfile
     """
     tabfile = TabFile('test',self.fp,first_line_is_header=True)
     self.assertEqual(len(tabfile.header()),4)
     tabfile.appendColumn('new')
     self.assertEqual(len(tabfile.header()),5)
     self.assertEqual(tabfile.header()[4],'new')
     self.assertEqual(tabfile[0]['new'],'')
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:11,代码来源:test_TabFile.py

示例2: test_compute_and_overwrite_existing_column_integer_index

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_compute_and_overwrite_existing_column_integer_index(self):
     """Compute new values for an existing column referenced using integer index
     """
     tabfile = TabFile('test',self.fp,first_line_is_header=True)
     # Check number of columns and header items
     self.assertEqual(tabfile.nColumns(),4)
     self.assertEqual(tabfile.header(),['chr','start','end','data'])
     # Compute new values for data column
     tabfile.computeColumn(3,lambda line: line['end'] - line['start'])
     self.assertEqual(tabfile.nColumns(),4)
     self.assertEqual(tabfile.header(),['chr','start','end','data'])
     results = [233,323,4444]
     for i in range(len(tabfile)):
         self.assertEqual(tabfile[i]['data'],results[i])
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:16,代码来源:test_TabFile.py

示例3: test_compute_midpoint

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_compute_midpoint(self):
     """Compute the midpoint of the start and end columns
     """
     tabfile = TabFile('test',self.fp,first_line_is_header=True)
     # Check number of columns and header items
     self.assertEqual(tabfile.nColumns(),4)
     self.assertEqual(tabfile.header(),['chr','start','end','data'])
     # Compute midpoint of start and end
     tabfile.computeColumn('midpoint',lambda line: (line['end'] + line['start'])/2.0)
     self.assertEqual(tabfile.nColumns(),5)
     self.assertEqual(tabfile.header(),['chr','start','end','data','midpoint'])
     results = [117.5,728.5,3456]
     for i in range(len(tabfile)):
         self.assertEqual(tabfile[i]['midpoint'],results[i])
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:16,代码来源:test_TabFile.py

示例4: test_set_column_to_constant_value

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_set_column_to_constant_value(self):
     """Set a column to a constant value using transformColumn
     """
     tabfile = TabFile('test',self.fp,first_line_is_header=True)
     # Check number of columns and header items
     self.assertEqual(tabfile.nColumns(),4)
     self.assertEqual(tabfile.header(),['chr','start','end','data'])
     # Add a strand column
     tabfile.appendColumn('strand')
     self.assertEqual(tabfile.nColumns(),5)
     self.assertEqual(tabfile.header(),['chr','start','end','data','strand'])
     # Set all values to '+'
     tabfile.transformColumn('strand',lambda x: '+')
     for line in tabfile:
         self.assertEqual(line['strand'],'+')
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:17,代码来源:test_TabFile.py

示例5: test_reorder_columns

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_reorder_columns(self):
     """Reorder columns in a TabFile
     """
     tabfile = TabFile('test',self.fp,first_line_is_header=True)
     # Check number of columns and header items
     self.assertEqual(tabfile.nColumns(),4)
     self.assertEqual(tabfile.header(),['chr','start','end','data'])
     # Reorder
     new_columns = ['chr','data','start','end']
     tabfile = tabfile.reorderColumns(new_columns)
     self.assertEqual(tabfile.nColumns(),4)
     self.assertEqual(tabfile.header(),new_columns)
     self.assertEqual(str(tabfile[0]),"chr1\t4.6\t1\t234")
     self.assertEqual(str(tabfile[1]),"chr1\t5.7\t567\t890")
     self.assertEqual(str(tabfile[2]),"chr2\t6.8\t1234\t5678")
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:17,代码来源:test_TabFile.py

示例6: test_load_data_with_header

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_load_data_with_header(self):
     """Create and load Tabfile using first line as header
     """
     tabfile = TabFile('test',self.fp,first_line_is_header=True)
     self.assertEqual(len(tabfile),3,"Input has 3 lines of data")
     self.assertEqual(tabfile.header(),['chr','start','end','data'],"Wrong header")
     self.assertEqual(str(tabfile[0]),"chr1\t1\t234\t4.6","Incorrect string representation")
     self.assertEqual(tabfile[2]['chr'],'chr2',"Incorrect data")
     self.assertEqual(tabfile.nColumns(),4)
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:11,代码来源:test_TabFile.py

示例7: test_reorder_columns_empty_cells

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_reorder_columns_empty_cells(self):
     """Reorder columns where some lines have empty cells at the start
     """
     tabfile = TabFile('test',self.fp,first_line_is_header=True)
     # Check number of columns and header items
     self.assertEqual(tabfile.nColumns(),4)
     self.assertEqual(tabfile.header(),['chr','start','end','data'])
     # Reset some cells to empty
     tabfile[0]['chr'] = ''
     tabfile[2]['chr'] = ''
     # Reorder
     new_columns = ['chr','data','start','end']
     tabfile = tabfile.reorderColumns(new_columns)
     self.assertEqual(tabfile.nColumns(),4)
     self.assertEqual(tabfile.header(),new_columns)
     self.assertEqual(str(tabfile[0]),"\t4.6\t1\t234")
     self.assertEqual(str(tabfile[1]),"chr1\t5.7\t567\t890")
     self.assertEqual(str(tabfile[2]),"\t6.8\t1234\t5678")
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:20,代码来源:test_TabFile.py

示例8: test_unexpected_uncommented_header

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_unexpected_uncommented_header(self):
     """Test reading in a tab file with an unexpected uncommented header
     """
     tabfile = TabFile('test',self.fp)
     self.assertEqual(len(tabfile),4,"Input has 4 lines of data")
     self.assertEqual(tabfile.header(),[],"Wrong header")
     self.assertEqual(str(tabfile[0]),"chr\tstart\tend\tdata","Incorrect string representation")
     self.assertRaises(KeyError,tabfile[3].__getitem__,'chr')
     self.assertEqual(tabfile.nColumns(),4)
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:11,代码来源:test_TabFile.py

示例9: test_expected_uncommented_header

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_expected_uncommented_header(self):
     """Test reading in a tab file with an expected uncommented header
     """
     tabfile = TabFile('test',self.fp,first_line_is_header=True)
     self.assertEqual(len(tabfile),3,"Input has 3 lines of data")
     self.assertEqual(tabfile.header(),['chr','start','end','data'],"Wrong header")
     self.assertEqual(str(tabfile[0]),"chr1\t1\t234\t4.6","Incorrect string representation")
     self.assertEqual(tabfile[2]['chr'],'chr2',"Incorrect data")
     self.assertEqual(tabfile.nColumns(),4)
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:11,代码来源:test_TabFile.py

示例10: test_load_data_setting_explicit_header

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_load_data_setting_explicit_header(self):
     """Create and load TabFile setting the header explicitly
     """
     tabfile = TabFile('test',self.fp,first_line_is_header=True,
                       column_names=('CHROM','START','STOP','VALUES'))
     self.assertEqual(len(tabfile),3,"Input has 3 lines of data")
     self.assertEqual(tabfile.header(),['CHROM','START','STOP','VALUES'],"Wrong header")
     self.assertEqual(str(tabfile[0]),"chr1\t1\t234\t4.6","Incorrect string representation")
     self.assertEqual(tabfile[2]['CHROM'],'chr2',"Incorrect data")
     self.assertEqual(tabfile.nColumns(),4)
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:12,代码来源:test_TabFile.py

示例11: test_load_data

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_load_data(self):
     """Create and load new TabFile instance
     """
     tabfile = TabFile('test',self.fp,delimiter=',')
     self.assertEqual(len(tabfile),3,"Input has 3 lines of data")
     self.assertEqual(tabfile.header(),[],"Header should be empty")
     self.assertEqual(str(tabfile[0]),"chr1,1,234,4.6","Incorrect string representation")
     self.assertEqual(tabfile[2][0],'chr2',"Incorrect data")
     self.assertEqual(tabfile.nColumns(),4)
     self.assertEqual(tabfile.filename(),'test')
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:12,代码来源:test_TabFile.py

示例12: test_apply_operation_to_column

# 需要导入模块: from bcftbx import TabFile [as 别名]
# 或者: from bcftbx.TabFile import header [as 别名]
 def test_apply_operation_to_column(self):
     """Divide values in a column by 10
     """
     tabfile = TabFile('test',self.fp,first_line_is_header=True)
     # Check number of columns and header items
     self.assertEqual(tabfile.nColumns(),4)
     self.assertEqual(tabfile.header(),['chr','start','end','data'])
     # Divide data column by 10
     tabfile.transformColumn('data',lambda x: x/10)
     results = [0.46,0.57,0.68]
     for i in range(len(tabfile)):
         self.assertEqual(tabfile[i]['data'],results[i])
开发者ID:marcelcaraciolo,项目名称:genomics,代码行数:14,代码来源:test_TabFile.py


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