Skip to content

Commit

Permalink
Fix on saving box2taxon when it is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
iquasere committed Jan 4, 2024
1 parent 4ebe9c2 commit 2ecfae9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion keggcharter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python

import argparse
from argparse import ArgumentParser, ArgumentTypeError
from multiprocessing import Manager, cpu_count
Expand Down Expand Up @@ -204,8 +205,8 @@ def further_information(
cog2ko_file=cog2ko_file, threads=threads)
main_column = kegg_column if kegg_column is not None else ko_column if ko_column is not None else ec_column
data = condense_data(data, main_column)
timed_message(f'Saving new information to: {output}')
data.to_csv(output, sep='\t', index=False)
timed_message(f'New information saved to {output}')
return data, main_column


Expand Down
8 changes: 5 additions & 3 deletions keggpathway_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ def pathway_boxes_differential(self, df, colormap_name="viridis"):
if self.orthologs[boxidx].graphics[0].width is not None: # TODO - should check more deeply why sometimes width is None
create_tile_box(self.orthologs[boxidx])


def grey_boxes(self, box_list):
for i in box_list:
set_bgcolor(self.orthologs[i], "#7c7272")
Expand Down Expand Up @@ -416,8 +415,11 @@ def genomic_potential_taxa(
f'{output}/maps/potential_{name}.pdf', f'{output}/maps/potential_{name}_legend.png',
f'{output}/maps/potential_{self.title.replace("/", "|")}.png')
box2taxon = {key: ','.join(set(value)) if type(value) != str else value for key, value in box2taxon.items()}
df = pd.DataFrame.from_dict(box2taxon, orient='index').reset_index()
df.columns = ['Box', 'Taxonomies']
if len(box2taxon) > 0:
df = pd.DataFrame.from_dict(box2taxon, orient='index').reset_index()
df.columns = ['Box', 'Taxonomies']
else:
df = pd.DataFrame(columns=['Box', 'Taxonomies'])
df.to_csv(f'{output}/tsvs/potential_{name}.tsv', sep='\t', index=False)

def differential_colorbar(self, df, filename, colormap_name='viridis'):
Expand Down

0 comments on commit 2ecfae9

Please sign in to comment.