INNER CODE UNIT · Python
append_tbl
steineggerlab/Metabuli · util/gtdb_to_taxdump.py:214
def append_tbl(self, table_file, join_column):
""" appending to table """
# creating index: name : [taxID, rank]
idx = {}
self.__seen = {}
idx['root'] = str(self.__graph_nodeIDs['root'])
self._to_tbl_iter_idx('root', idx)
# appending to file
out_file = os.path.splitext(table_file)[0] + '_wTaxIDs.tsv'
header = OrderedDict()
with open(table_file) as inF, open(out_file, 'w') as outF:
for i,line in enumerate(inF):
line = line.rstrip().split('\t')
if i == 0:
header = {x:i for i,x in enumerate(line)}
header['gtdb_taxid'] = len(header.keys()) + 1
if not join_column in header.keys():