INNER CODE UNIT · Python
get_taxa_cols
hahnlab/CAFE5 · scripts/remove_taxa.py:3
def get_taxa_cols(header_order_dict, taxa_list):
taxa_cols = [header_order_dict[taxon_name] for taxon_name in taxa_list]
return taxa_cols
def remove_taxa(input_file_path, output_file_path, taxa_to_remove):
taxa_list = taxa_to_remove.split(',')
header_order = dict() # node name:idx
node_name_idx = 0
with open(output_file_path, 'w') as output_file:
with open(input_file_path, 'r') as input_file:
for line in input_file:
line = line.rstrip()
if line.startswith('#'):
node_name = line.lstrip('#')
if not node_name in taxa_list: