There appears to be a problem when appending columns to a TabFile which contains data but which doesn't already have any column names assigned.
Example: create a new (empty) TabFile with no header and add a line of data - it reports the number of columns as zero and the header as an empty list:
>>> from bcftbx.TabFile import TabFile
>>> t = TabFile()
>>> t.append(data=[1,2,3])
1 2 3
>>> t.nColumns()
0
>>> t.header()
[]
Now append a new column - only the new column is reported:
>>> t.appendColumn('extra')
>>> t
1 2 3
>>> t.header()
['extra']
Output the data to stdout:
>>> import sys
>>> t.write(fp=sys.stdout,include_header=True)
#extra
1 2 3
Add data to the extra column and output to stdout again - now the first column is overwritten:
>>> t[0]['extra'] = 4
>>> t.write(fp=sys.stdout,include_header=True)
#extra
4 2 3
There appears to be a problem when appending columns to a
TabFilewhich contains data but which doesn't already have any column names assigned.Example: create a new (empty)
TabFilewith no header and add a line of data - it reports the number of columns as zero and the header as an empty list:Now append a new column - only the new column is reported:
Output the data to
stdout:Add data to the
extracolumn and output tostdoutagain - now the first column is overwritten: